开发技巧-Winform窗体自动生成下一个业务流程的单据|C/S框架网
开发技巧-Winform窗体自动生成下一个业务流程的单据|C/S框架网
本文章详细讲解如何通过一个窗体的数据自动生成下一个业务流程窗体的数据,既A生成B。在B窗体定义一个方法转换数据,如本实例的GenerateFromEC方法(参考下面的代码),转换数据后,将窗体设置为【新增】模式,并提示用户修改并保存数据,若用户点【取消】按钮,则本次操作失效,系统不记录任何数据。
本示例的界面继承数据字典窗体frmBaseDataDictionary(单表资料窗体)。
本示例的界面截图:
C# Code:
private void btnToOrder_Click(object sender, EventArgs e)
{
if (!Msg.AskQuestion("确定要转化订单吗?")) return;
//查找目标窗体是否已打开
frm_EC_Order form = (frm_EC_Order)MdiTools.FindForm(typeof(frm_EC_Order).FullName);
if (form == null)
{
//第一次创建本窗体的实例
form = (frm_EC_Order)MdiTools.OpenChildForm(this.MdiParent as IMdiForm, typeof(frm_EC_Order), "menuEC_Order");
}
else
{
//创建新的界面实例(第n+1个实例)
if (form.IsAddOrEditMode)
form = (frm_EC_Order)MdiTools.OpenChildForm(this.MdiParent as IMdiForm, typeof(frm_EC_Order), "menuEC_Order", false);
}
//调用目标窗体的【生成订单】方法。EC-->EO
form.GenerateFromEC(_BLLInstance.DataBinder);
//激活当前窗体,在主界面显示当前窗体
MdiTools.ActiveChildForm(MdiTools.MainForm, form);
Msg.ShowInformation("转化订单成功,请补充资料并保存!");
}
//来源:C/S框架网(www.csframework.com) QQ:23404761
private void btnToOrder_Click(object sender, EventArgs e)
{
if (!Msg.AskQuestion("确定要转化订单吗?")) return;
//查找目标窗体是否已打开
frm_EC_Order form = (frm_EC_Order)MdiTools.FindForm(typeof(frm_EC_Order).FullName);
if (form == null)
{
//第一次创建本窗体的实例
form = (frm_EC_Order)MdiTools.OpenChildForm(this.MdiParent as IMdiForm, typeof(frm_EC_Order), "menuEC_Order");
}
else
{
//创建新的界面实例(第n+1个实例)
if (form.IsAddOrEditMode)
form = (frm_EC_Order)MdiTools.OpenChildForm(this.MdiParent as IMdiForm, typeof(frm_EC_Order), "menuEC_Order", false);
}
//调用目标窗体的【生成订单】方法。EC-->EO
form.GenerateFromEC(_BLLInstance.DataBinder);
//激活当前窗体,在主界面显示当前窗体
MdiTools.ActiveChildForm(MdiTools.MainForm, form);
Msg.ShowInformation("转化订单成功,请补充资料并保存!");
}
//来源:C/S框架网(www.csframework.com) QQ:23404761
C# Code:
/// <summary>
/// 从《询盘管理》生成《订单管理》
/// </summary>
/// <param name="data"></param>
public void GenerateFromEC(DataTable data)
{
_BLLInstance.CreateDataBinder(null);
DataRow R = _BLLInstance.DataBinderRow;
R[EC_tb_Order.Status] = "Pay";
R[EC_tb_Order.CompanyAddr] = data.Rows[0][EC_tb_Inquire.CompanyAddr];
R[EC_tb_Order.CompanyName] = data.Rows[0][EC_tb_Inquire.CompanyName];
R[EC_tb_Order.Contact] = data.Rows[0][EC_tb_Inquire.Contact];
R[EC_tb_Order.ContactTel] = data.Rows[0][EC_tb_Inquire.ContactTel];
R[EC_tb_Order.ContactType] = data.Rows[0][EC_tb_Inquire.ContactType];
R[EC_tb_Order.CreatedBy] = Loginer.CurrentUser.Account;
R[EC_tb_Order.CreationDate] = DateTime.Now;
R[EC_tb_Order.CustomerName] = data.Rows[0][EC_tb_Inquire.CustomerName];
R[EC_tb_Order.DocDate] = DateTime.Today;
R[EC_tb_Order.ECOD] = "*自动生成*";
R[EC_tb_Order.LastUpdateDate] = DateTime.Now;
R[EC_tb_Order.LastUpdatedBy] = Loginer.CurrentUser.Account;
R[EC_tb_Order.Platform] = data.Rows[0][EC_tb_Inquire.Platform];
R[EC_tb_Order.ProductInfo] = data.Rows[0][EC_tb_Inquire.ProductInfo];
R[EC_tb_Order.Remark] = data.Rows[0][EC_tb_Inquire.Remark];
R[EC_tb_Order.RefIQNO] = data.Rows[0][EC_tb_Inquire.IQNO];
R.AcceptChanges();
R.SetAdded();//调用SetAdded方法之前必须行态是未修改状态
_UpdateType = UpdateType.Add;
this.DoBindingSummaryEditor(_BLLInstance.DataBinder);
this.ButtonStateChanged(_UpdateType);
this.SetEditMode();
this.ShowDetailPage(true);
}
//来源:C/S框架网(www.csframework.com) QQ:23404761
/// <summary>
/// 从《询盘管理》生成《订单管理》
/// </summary>
/// <param name="data"></param>
public void GenerateFromEC(DataTable data)
{
_BLLInstance.CreateDataBinder(null);
DataRow R = _BLLInstance.DataBinderRow;
R[EC_tb_Order.Status] = "Pay";
R[EC_tb_Order.CompanyAddr] = data.Rows[0][EC_tb_Inquire.CompanyAddr];
R[EC_tb_Order.CompanyName] = data.Rows[0][EC_tb_Inquire.CompanyName];
R[EC_tb_Order.Contact] = data.Rows[0][EC_tb_Inquire.Contact];
R[EC_tb_Order.ContactTel] = data.Rows[0][EC_tb_Inquire.ContactTel];
R[EC_tb_Order.ContactType] = data.Rows[0][EC_tb_Inquire.ContactType];
R[EC_tb_Order.CreatedBy] = Loginer.CurrentUser.Account;
R[EC_tb_Order.CreationDate] = DateTime.Now;
R[EC_tb_Order.CustomerName] = data.Rows[0][EC_tb_Inquire.CustomerName];
R[EC_tb_Order.DocDate] = DateTime.Today;
R[EC_tb_Order.ECOD] = "*自动生成*";
R[EC_tb_Order.LastUpdateDate] = DateTime.Now;
R[EC_tb_Order.LastUpdatedBy] = Loginer.CurrentUser.Account;
R[EC_tb_Order.Platform] = data.Rows[0][EC_tb_Inquire.Platform];
R[EC_tb_Order.ProductInfo] = data.Rows[0][EC_tb_Inquire.ProductInfo];
R[EC_tb_Order.Remark] = data.Rows[0][EC_tb_Inquire.Remark];
R[EC_tb_Order.RefIQNO] = data.Rows[0][EC_tb_Inquire.IQNO];
R.AcceptChanges();
R.SetAdded();//调用SetAdded方法之前必须行态是未修改状态
_UpdateType = UpdateType.Add;
this.DoBindingSummaryEditor(_BLLInstance.DataBinder);
this.ButtonStateChanged(_UpdateType);
this.SetEditMode();
this.ShowDetailPage(true);
}
//来源:C/S框架网(www.csframework.com) QQ:23404761
版权声明:本文为开发框架文库发布内容,转载请附上原文出处连接
NewDoc C/S框架网