📄 orderstablelogic.cs
字号:
using System;
using System.Data;
using System.Collections.Generic;
using System.Text;
using Orphean.WinFormHelper.Framework.Data;
using Orphean.WinFormHelper.Framework.BusinessLogic;
namespace DataModal
{
public partial class HidaKitDataSet
{
public partial class ORDERSDataTable
{
public CommonLogic CommonLogic = new CommonLogic();
public void InitLogic()
{
TableNewRow += new DataTableNewRowEventHandler(ORDERSDataTable_TableNewRow);
ColumnChanging += new DataColumnChangeEventHandler(CommonLogic.CustomerCheckLogic);
}
void ORDERSDataTable_TableNewRow(object sender, DataTableNewRowEventArgs e)
{
e.Row["ORDER_DATE"] = DateTime.Today;
}
}
public partial class ORDERS_DETAILDataTable
{
public CommonLogic CommonLogic = new CommonLogic();
public void InitLogic()
{
RowDeleting += new DataRowChangeEventHandler(ORDERS_DETAILDataTable_RowDeleting);
RowChanged += new DataRowChangeEventHandler(ORDERS_DETAILDataTable_RowChanged);
ColumnChanged += new DataColumnChangeEventHandler(ORDERS_DETAILDataTable_ColumnChanged);
ColumnChanging += new DataColumnChangeEventHandler(CommonLogic.ProductCheckLogic);
TableNewRow += new DataTableNewRowEventHandler(ORDERS_DETAILDataTable_TableNewRow);
}
void ORDERS_DETAILDataTable_ColumnChanged(object sender, DataColumnChangeEventArgs e)
{
if (e.Column.ColumnName.Equals("PRICE") ||
e.Column.ColumnName.Equals("QTY"))
{
double price = DataRowAccessor.GetDouble(e.Row, "PRICE");
double qty = DataRowAccessor.GetDouble(e.Row, "QTY");
e.Row["SUBTOTAL"] = price * qty;
}
}
void CalculateTotal(DataRow row)
{
DataRow parentRow = row.GetParentRow("FK_ORDERS_ORDERS_DETAIL");
if (parentRow != null)
{
double total = 0;
foreach (DataRow detailRow in parentRow.GetChildRows("FK_ORDERS_ORDERS_DETAIL"))
total += detailRow.IsNull("SUBTOTAL") ? 0 : (double)detailRow["SUBTOTAL"];
parentRow["TOTAL"] = total;
}
}
void ORDERS_DETAILDataTable_TableNewRow(object sender, DataTableNewRowEventArgs e)
{
e.Row["AUTO_ID"] = Guid.NewGuid();
e.Row["PRICE"] = 0;
e.Row["QTY"] = 0;
}
void ORDERS_DETAILDataTable_RowChanged(object sender, DataRowChangeEventArgs e)
{
if (e.Action == DataRowAction.Add || e.Action == DataRowAction.Change)
CalculateTotal(e.Row);
}
void ORDERS_DETAILDataTable_RowDeleting(object sender, DataRowChangeEventArgs e)
{
CalculateTotal(e.Row);
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -