You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

143 lines
4.8 KiB
C#

9 months ago
using DevComponents.DotNetBar;
using DevComponents.DotNetBar.SuperGrid;
using POS.Language.Language;
using POSV.Component;
using POSV.Entity;
using POSV.Utils;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace POSV.Report
{
public partial class QdForm : BusinessForm
{
private static NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger();
public QdForm()
{
InitializeComponent();
this.controlBox1.Text = LangProxy.ToLang("挂单列表");
this.controlBox1.ShowApplicationVersion = false;
this.startPicker.Value = DateTime.Parse(Global.Instance.BusinessPlan.StartTimeSimple);
this.endPicker.Value = DateTime.Parse(Global.Instance.BusinessPlan.EndTimeSimple);
}
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
if (this.DesignMode) return;
DefaultGridStyle.setDefaultGridStyle(this.superGridControl1);
this.QueryGd();
}
private void QueryGd()
{
try
{
var startTime = this.startPicker.Value.ToString("yyyy-MM-dd HH:mm:ss");
var endTime = this.endPicker.Value.ToString("yyyy-MM-dd HH:mm:ss");
this.superGridControl1.PrimaryGrid.Rows.Clear();
List <OrderTemp> tempList = null;
using(var db = Global.Instance.OpenDataBase)
{
tempList = db.Query<OrderTemp>("where saleDate >= @0 and saleDate <= @1 order by saleDate desc", startTime, endTime).ToList();
}
List<GridRow> rowList = new List<GridRow>();
decimal totalPaid = 0.00M;
decimal totalQuantity = 0.00M;
foreach(var entity in tempList)
{
totalPaid += entity.Paid;
totalQuantity += entity.TotalQuantity;
GridRow row = new GridRow(entity.SaleDate, entity.TradeNo, LangProxy.ToLang("提取"), entity.Paid, entity.TableName, entity.TotalQuantity, entity.WorkerName);
row.RowHeight = 40;
row.Tag = entity.OrderJson;
rowList.Add(row);
}
//合计
if(rowList.Count > 0)
{
GridRow totalRow = new GridRow(LangProxy.ToLang("合计"), string.Empty, string.Empty, totalPaid, string.Empty, totalQuantity, string.Empty);
totalRow.CellStyles.Default.Background.Color1 = Color.AliceBlue;
totalRow.CellStyles.Default.Font = new Font("宋体", 14.00f, FontStyle.Bold, GraphicsUnit.Pixel);
rowList.Add(totalRow);
}
if (rowList.Count > 0)
{
this.superGridControl1.PrimaryGrid.Rows.AddRange(rowList);
}
}
catch (Exception ex)
{
logger.Error(ex, "获取取单列表异常");
}
}
private void OnTimeButtonClick(object sender, EventArgs e)
{
var obj = sender as ButtonX;
var typeStr = obj.Tag as string;
var type = (ReportQuickDate)Enum.Parse(typeof(ReportQuickDate), typeStr);
var res = DateTimeUtils.CalculateBusinessPlanDate(type, this.startPicker.Value, this.endPicker.Value);
this.startPicker.Value = res.Item1;
this.endPicker.Value = res.Item2;
this.QueryGd();
}
private void OnQueryClick(object sender, EventArgs e)
{
this.QueryGd();
}
private void OnControlBoxCloseClick(object sender, EventArgs e)
{
OnCloseTouchClick(sender, e);
}
private void OnCloseTouchClick(object sender, EventArgs e)
{
//先关闭父窗体
if (this.Owner != null)
{
this.Owner.Close();
}
//再关闭当前窗体
this.Close();
}
private void OnExitClick(object sender, EventArgs e)
{
OnCloseTouchClick(sender, e);
}
private void OnCellClick(object sender, GridCellClickEventArgs e)
{
if(e.GridCell.GridColumn.Name == "operate")
{
var order = e.GridCell.GridRow.Tag;
if (order != null)
{
this.OnAcceptButtonClick(new TransparentEventArgs(TransparentAction.Accept, LangProxy.ToLang("取单"), order.ToString()));
OnCloseTouchClick(sender, e);
}
}
}
}
}