弹出窗体勾选多条记录自动添加到明细表
弹出窗体勾选多条记录自动添加到明细表
frmSO.cs
扫一扫加作者微信
SearchCallBack.cs
C# Code:
namespace CSFrameworkV4_5.Library.CommonClass
{
/// <summary>
/// 回调函数,当选择一个条记录后关闭窗体时调用
/// </summary>
/// <param name="resultRow">当前选择的条记</param>
public delegate void SearchCallBack(DataRow resultRow);
/// <summary>
/// 回调函数,当选择多条记录后关闭窗体时调用
/// </summary>
/// <param name="resultTable"></param>
public delegate void SearchCallBackTable(DataTable resultTable);
}
//来源:C/S框架网(www.csframework.com) QQ:1980854898
namespace CSFrameworkV4_5.Library.CommonClass
{
/// <summary>
/// 回调函数,当选择一个条记录后关闭窗体时调用
/// </summary>
/// <param name="resultRow">当前选择的条记</param>
public delegate void SearchCallBack(DataRow resultRow);
/// <summary>
/// 回调函数,当选择多条记录后关闭窗体时调用
/// </summary>
/// <param name="resultTable"></param>
public delegate void SearchCallBackTable(DataTable resultTable);
}
//来源:C/S框架网(www.csframework.com) QQ:1980854898
frmSO.cs
C# Code:
private void OnStockCode_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
{
//打开产品查询窗体
frmFuzzySearchProduct.ExecuteTable(sender as ButtonEdit, this.SearchStockCallBackTable);
}
//来源:C/S框架网(www.csframework.com) QQ:1980854898
private void OnStockCode_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
{
//打开产品查询窗体
frmFuzzySearchProduct.ExecuteTable(sender as ButtonEdit, this.SearchStockCallBackTable);
}
//来源:C/S框架网(www.csframework.com) QQ:1980854898
C# Code:
/// <summary>
/// 勾选记录对话框回调函数
/// </summary>
/// <param name="resultTable">返回的表</param>
private void SearchStockCallBackTable(DataTable resultTable)
{
if (resultTable == null || resultTable.Rows.Count == 0) return;
foreach (DataRow resultRow in resultTable.Rows)
{
DataRow row = _BLL.CurrentBusiness.Tables[tb_SOs.__TableName].NewRow();
string order = new GenerateSortID().Generate(gvDetail, colD_Queue); //生成排序编号
row[tb_SOs.Queue] = order; //排序编号
row[tb_SOs.StockCode] = resultRow[tb_Product.ProductCode];
row[tb_SOs.StockName] = resultRow[tb_Product.ProductName]; //参考字段,["StockName"]相同
row[tb_SOs.Price] = resultRow[tb_Product.SellPrice];
row[tb_SOs.Qty] = 1;
_BLL.CurrentBusiness.Tables[tb_SOs.__TableName].Rows.Add(row); //增加一条明细记录
}
gcDetail.RefreshDataSource();
}
//来源:C/S框架网(www.csframework.com) QQ:1980854898
/// <summary>
/// 勾选记录对话框回调函数
/// </summary>
/// <param name="resultTable">返回的表</param>
private void SearchStockCallBackTable(DataTable resultTable)
{
if (resultTable == null || resultTable.Rows.Count == 0) return;
foreach (DataRow resultRow in resultTable.Rows)
{
DataRow row = _BLL.CurrentBusiness.Tables[tb_SOs.__TableName].NewRow();
string order = new GenerateSortID().Generate(gvDetail, colD_Queue); //生成排序编号
row[tb_SOs.Queue] = order; //排序编号
row[tb_SOs.StockCode] = resultRow[tb_Product.ProductCode];
row[tb_SOs.StockName] = resultRow[tb_Product.ProductName]; //参考字段,["StockName"]相同
row[tb_SOs.Price] = resultRow[tb_Product.SellPrice];
row[tb_SOs.Qty] = 1;
_BLL.CurrentBusiness.Tables[tb_SOs.__TableName].Rows.Add(row); //增加一条明细记录
}
gcDetail.RefreshDataSource();
}
//来源:C/S框架网(www.csframework.com) QQ:1980854898
扫一扫加作者微信
版权声明:本文为开发框架文库发布内容,转载请附上原文出处连接
NewDoc C/S框架网