|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
using DevComponents.DotNetBar.SuperGrid;
|
|
|
|
|
using POSV.Utils;
|
|
|
|
|
using POSV.ShoppingCart;
|
|
|
|
|
using POS.Language.Language;
|
|
|
|
|
|
|
|
|
|
namespace POSV.Bill
|
|
|
|
|
{
|
|
|
|
|
[ToolboxItem(true)]
|
|
|
|
|
public partial class BillGrid : BaseUserControl
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 数据集合
|
|
|
|
|
/// </summary>
|
|
|
|
|
private DataSet dataSet = new DataSet("dataSet");
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 支付列表绑定的DataTable的名称
|
|
|
|
|
/// </summary>
|
|
|
|
|
private string PAYMENT_TABLE = "payment_table";
|
|
|
|
|
|
|
|
|
|
public BillGrid()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
|
|
|
|
|
DataTable table = new DataTable(PAYMENT_TABLE);
|
|
|
|
|
//序号
|
|
|
|
|
DataColumn col = new DataColumn();
|
|
|
|
|
col.ColumnName = "order";
|
|
|
|
|
table.Columns.Add(col);
|
|
|
|
|
//名称
|
|
|
|
|
col = new DataColumn();
|
|
|
|
|
col.ColumnName = "name";
|
|
|
|
|
table.Columns.Add(col);
|
|
|
|
|
//金额
|
|
|
|
|
col = new DataColumn();
|
|
|
|
|
col.ColumnName = "amount";
|
|
|
|
|
table.Columns.Add(col);
|
|
|
|
|
//操作
|
|
|
|
|
col = new DataColumn();
|
|
|
|
|
col.ColumnName = "memo";
|
|
|
|
|
table.Columns.Add(col);
|
|
|
|
|
|
|
|
|
|
//行标识
|
|
|
|
|
col = new DataColumn();
|
|
|
|
|
col.ColumnName = "objectId";
|
|
|
|
|
table.Columns.Add(col);
|
|
|
|
|
|
|
|
|
|
this.dataSet.Tables.Add(table);
|
|
|
|
|
|
|
|
|
|
InitializePaymentGrid();
|
|
|
|
|
|
|
|
|
|
foreach (var item in this.superGridControl.PrimaryGrid.Columns)
|
|
|
|
|
{
|
|
|
|
|
var _col = item as GridColumn;
|
|
|
|
|
|
|
|
|
|
if (_col != null)
|
|
|
|
|
{
|
|
|
|
|
_col.HeaderText = LangProxy.ToLang(_col.HeaderText);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void RefreshGrid(List<PayItem> receivedPayment)
|
|
|
|
|
{
|
|
|
|
|
GridPanel panel = this.superGridControl.PrimaryGrid;
|
|
|
|
|
panel.MultiSelect = false;
|
|
|
|
|
|
|
|
|
|
DataSet dataSet = this.superGridControl.PrimaryGrid.DataSource as DataSet;
|
|
|
|
|
DataTable table = dataSet.Tables[this.superGridControl.PrimaryGrid.DataMember];
|
|
|
|
|
table.Rows.Clear();
|
|
|
|
|
|
|
|
|
|
table.BeginLoadData();
|
|
|
|
|
|
|
|
|
|
int inx = 1;
|
|
|
|
|
foreach (var item in receivedPayment)
|
|
|
|
|
{
|
|
|
|
|
item.Order = (inx++);
|
|
|
|
|
|
|
|
|
|
var row = table.NewRow();
|
|
|
|
|
|
|
|
|
|
row["order"] = item.Order;
|
|
|
|
|
row["name"] = string.Format("<div align=\"center\">{0}</div>", LangProxy.ToLang(item.Name));
|
|
|
|
|
row["amount"] = string.Format("<div align=\"center\">{0}</div>", item.PaidAmount);
|
|
|
|
|
row["memo"] = string.Format("<div align=\"center\">{0}</div>", LangProxy.ToLang("删除"));
|
|
|
|
|
//如果是现金支付方式,采用Code,其他采用objectId,解决多种现金支付情况下合并处理
|
|
|
|
|
row["objectId"] = item.Id;
|
|
|
|
|
|
|
|
|
|
table.Rows.Add(row);
|
|
|
|
|
|
|
|
|
|
table.AcceptChanges();
|
|
|
|
|
}
|
|
|
|
|
table.EndLoadData();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void InitializePaymentGrid()
|
|
|
|
|
{
|
|
|
|
|
this.superGridControl.DefaultVisualStyles.CellStyles.Default.Font = Constant.BIG_FONT;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
GridPanel panel = this.superGridControl.PrimaryGrid;
|
|
|
|
|
|
|
|
|
|
panel.MinRowHeight = 35;
|
|
|
|
|
panel.DefaultRowHeight = 0;
|
|
|
|
|
panel.DefaultVisualStyles.CellStyles.Default.Font = this.superGridControl.DefaultVisualStyles.CellStyles.Default.Font;
|
|
|
|
|
panel.NestedListScanTypes = (NestedListScanTypes.Properties | NestedListScanTypes.Fields);
|
|
|
|
|
|
|
|
|
|
panel.VirtualMode = false;
|
|
|
|
|
|
|
|
|
|
//绑定订单数据源
|
|
|
|
|
panel.DataSource = this.dataSet;
|
|
|
|
|
panel.DataMember = PAYMENT_TABLE;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.superGridControl.CellClick += SuperGridControlCellClick;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public event PaymentRowDeleteClickEventHandler PaymentRowDeleteClick;
|
|
|
|
|
private void SuperGridControlCellClick(object sender, GridCellClickEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
//删除操作
|
|
|
|
|
if (e.GridCell.ColumnIndex == 3)
|
|
|
|
|
{
|
|
|
|
|
var obj = e.GridCell.GridRow["objectId"].Value;
|
|
|
|
|
PaymentRowDeleteClick?.Invoke(sender, new PaymentRowDeleteClickEventArgs(StringUtils.GetString(obj)));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public delegate void PaymentRowDeleteClickEventHandler(object sender, PaymentRowDeleteClickEventArgs e);
|
|
|
|
|
|
|
|
|
|
public class PaymentRowDeleteClickEventArgs : EventArgs
|
|
|
|
|
{
|
|
|
|
|
public readonly string ObjectId;
|
|
|
|
|
|
|
|
|
|
public PaymentRowDeleteClickEventArgs(string objectId)
|
|
|
|
|
{
|
|
|
|
|
this.ObjectId = objectId;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|