CS开发框架 - 业务单据自动生成功能设计(原)
CS开发框架 - 业务单据自动生成功能设计(原)
frmBaseBusiness 业务单据基类窗体
实现IDataOperatable, IBusinessSupportableForm接口及定义业务逻辑接口IBusinessManage, 如下图:
生成单据向导窗体仅依赖IGenerateItem接口,LoadItems方法动态加载多个项目定义(IGenerateItem),项目定义由具体的业务窗体指定。
下面的代码是销售报价窗体(QO)生成项目定义:
销售报价窗体(QO)打开自动向导
选择由销售报价单(QO)->生成发货单(DO),生成数据成功并自动打开DO窗体。
扫一扫加作者微信
Source Code for VIP:
摘要:
企业数据库管理应用系统中很多业务功能是按流程运作的,彼此相通,相辅相成,有些业务单据的数据结构基本一致,基于这些共同点,理论上在实际应用中是可以使业务数据自动生成。
进销存系统业务数据自动生成
以进销存系统为例,销售模块有《销售报价》,《销售FA票》,《发货单》,《销售退货》等功能。
销售模块流程如下:
销售报价录入基本资料,如客户资料,制单人,制单日期,金额总计,货品编号,数量,单价等基本资料。客户确认订单后录入销售FA票,而销售FA票的业务数据基本上与销售报价一致,只是增加合同,交货地点等其它数据,这时可以通过销售报价单自动生成销售FA票。
发货单,销售退货单大同小异,都可以参与自动生成功能。
UML图:
接口设计
C# Code:
/// <summary>
/// 生成单据的选择项目.
/// </summary>
public interface IGenerateItem
{
/// <summary>
///项目标题
/// </summary>
string ItemCaption { get; }
/// <summary>
///目标窗体名称
/// </summary>
string TargetFormName { get; }
/// <summary>
/// 打开目标窗体对应的菜单名.
/// </summary>
string TargetFormMenuName { get; }
/// <summary>
///目标窗体类型
/// </summary>
Type TargetFormType { get; }
/// <summary>
/// 标志是否生成成功
/// </summary>
bool IsSuccess { get; }
/// <summary>
/// 由其它单生成本单时需要用户输入来源单号
/// </summary>
bool IsDocNoRequired { get; }
/// <summary>
/// 检查来源单据的单号是否存在
/// </summary>
/// <param name="DocNo">单据号码</param>
/// <returns></returns>
bool IsDocNoExists(string DocNo);
/// <summary>
/// 自动生成数据
/// </summary>
/// <param name="targetBLL">目标单据的业务逻辑层</param>
/// <returns></returns>
bool Generate(IBusinessManage targetBLL);
/// <summary>
/// 设置来源单据的单号
/// </summary>
/// <param name="DocNo">业务单据号码</param>
void SetDocNo(string DocNo);
}
//来源:C/S框架网(www.csframework.com) QQ:1980854898
/// <summary>
/// 生成单据的选择项目.
/// </summary>
public interface IGenerateItem
{
/// <summary>
///项目标题
/// </summary>
string ItemCaption { get; }
/// <summary>
///目标窗体名称
/// </summary>
string TargetFormName { get; }
/// <summary>
/// 打开目标窗体对应的菜单名.
/// </summary>
string TargetFormMenuName { get; }
/// <summary>
///目标窗体类型
/// </summary>
Type TargetFormType { get; }
/// <summary>
/// 标志是否生成成功
/// </summary>
bool IsSuccess { get; }
/// <summary>
/// 由其它单生成本单时需要用户输入来源单号
/// </summary>
bool IsDocNoRequired { get; }
/// <summary>
/// 检查来源单据的单号是否存在
/// </summary>
/// <param name="DocNo">单据号码</param>
/// <returns></returns>
bool IsDocNoExists(string DocNo);
/// <summary>
/// 自动生成数据
/// </summary>
/// <param name="targetBLL">目标单据的业务逻辑层</param>
/// <returns></returns>
bool Generate(IBusinessManage targetBLL);
/// <summary>
/// 设置来源单据的单号
/// </summary>
/// <param name="DocNo">业务单据号码</param>
void SetDocNo(string DocNo);
}
//来源:C/S框架网(www.csframework.com) QQ:1980854898
C# Code:
/// <summary>
/// 支持数据操作功能(增删改查)的窗体
/// </summary>
public interface IDataOperatable
{
/// <summary>
/// 是否修改了数据(未保存)
/// </summary>
bool DataChanged { get; }
/// <summary>
/// 新增
/// </summary>
void DoAdd();
}
/// <summary>
/// 支持数据操作功能(增删改查)的窗体
/// </summary>
public interface IDataOperatable
{
/// <summary>
/// 是否修改了数据(未保存)
/// </summary>
bool DataChanged { get; }
/// <summary>
/// 新增
/// </summary>
void DoAdd();
}
C# Code:
/// <summary>
/// 支持业务单据操作的窗体
/// </summary>
public interface IBusinessSupportableForm
{
/// <summary>
/// 业务操作逻辑层
/// </summary>
IBusinessManage BLL_BusinessManage { get; }
}
/// <summary>
/// 支持业务单据操作的窗体
/// </summary>
public interface IBusinessSupportableForm
{
/// <summary>
/// 业务操作逻辑层
/// </summary>
IBusinessManage BLL_BusinessManage { get; }
}
C# Code:
/// <summary>
/// 业务单据的底层接口
/// </summary>
public interface IBusinessManage
{
/// <summary>
/// 当前业务单据的数据. 第一张数据表为主表,其它为明细表。
/// </summary>
DataTableCollection BusinessTables { get; }
}
/// <summary>
/// 业务单据的底层接口
/// </summary>
public interface IBusinessManage
{
/// <summary>
/// 当前业务单据的数据. 第一张数据表为主表,其它为明细表。
/// </summary>
DataTableCollection BusinessTables { get; }
}
C# Code:
/// <summary>
/// 生成单据项目定义基类
/// </summary>
public class IGenerateItemBase : IGenerateItem
{
protected bool _IsDocNoRequired;
protected string _DocNo;
protected bool _IsSuccess = false;
protected string _TargetFormName;
protected Type _TargetFormType = null;
protected string _ItemCaption;
protected string _TargetFormMenuName;
public IGenerateItemBase() { }
public IGenerateItemBase(string DocNo, bool IsDocNoRequired, Type targetFormType, string targetFormName)
{
_DocNo = DocNo;
_IsDocNoRequired = IsDocNoRequired;
_TargetFormType = targetFormType;
_TargetFormName = targetFormName;
}
public string TargetFormMenuName { get { return _TargetFormMenuName; } }
public string ItemCaption { get { return _ItemCaption; } }
public bool IsSuccess { get { return _IsSuccess; } }
public Type TargetFormType { get { return _TargetFormType; } }
public string TargetFormName { get { return _TargetFormName; } }
public bool IsDocNoRequired { get { return _IsDocNoRequired; } }
public void SetDocNo(string DocNo) { _DocNo = DocNo; }
public virtual bool Generate(IBusinessManage targetBLL) { return false; }
public virtual bool IsDocNoExists(string DocNo) { return false; }
}
//来源:C/S框架网(www.csframework.com) QQ:1980854898
/// <summary>
/// 生成单据项目定义基类
/// </summary>
public class IGenerateItemBase : IGenerateItem
{
protected bool _IsDocNoRequired;
protected string _DocNo;
protected bool _IsSuccess = false;
protected string _TargetFormName;
protected Type _TargetFormType = null;
protected string _ItemCaption;
protected string _TargetFormMenuName;
public IGenerateItemBase() { }
public IGenerateItemBase(string DocNo, bool IsDocNoRequired, Type targetFormType, string targetFormName)
{
_DocNo = DocNo;
_IsDocNoRequired = IsDocNoRequired;
_TargetFormType = targetFormType;
_TargetFormName = targetFormName;
}
public string TargetFormMenuName { get { return _TargetFormMenuName; } }
public string ItemCaption { get { return _ItemCaption; } }
public bool IsSuccess { get { return _IsSuccess; } }
public Type TargetFormType { get { return _TargetFormType; } }
public string TargetFormName { get { return _TargetFormName; } }
public bool IsDocNoRequired { get { return _IsDocNoRequired; } }
public void SetDocNo(string DocNo) { _DocNo = DocNo; }
public virtual bool Generate(IBusinessManage targetBLL) { return false; }
public virtual bool IsDocNoExists(string DocNo) { return false; }
}
//来源:C/S框架网(www.csframework.com) QQ:1980854898
frmBaseBusiness 业务单据基类窗体
实现IDataOperatable, IBusinessSupportableForm接口及定义业务逻辑接口IBusinessManage, 如下图:
C# Code:
/// <summary>
/// 业务单据基类窗体
/// </summary>
public partial class frmBaseBusiness : Form, IDataOperatable, IBusinessSupportableForm
{
/// <summary>
/// 业务单据的底层接口
/// </summary>
protected IBusinessManage _BLL_BusinessManage = null;
public frmBaseBusiness()
{
InitializeComponent();
}
private void btnGenerateBusiness_Click(object sender, EventArgs e)
{
this.DoGenerateBusiness();// 打开单据自动生成向导
}
/// <summary>
/// 打开单据自动生成向导
/// </summary>
public virtual void DoGenerateBusiness()
{
//
}
#region IDataOperatable Members
public bool DataChanged
{
get { return false; }
}
public virtual void DoAdd()
{
Msg.ShowInformation("新增状态。。。。");
}
#endregion
#region IBusinessSupportableForm Members
public IBusinessManage BLL_BusinessManage
{
get { return _BLL_BusinessManage; }
}
#endregion
}
//来源:C/S框架网(www.csframework.com) QQ:1980854898
/// <summary>
/// 业务单据基类窗体
/// </summary>
public partial class frmBaseBusiness : Form, IDataOperatable, IBusinessSupportableForm
{
/// <summary>
/// 业务单据的底层接口
/// </summary>
protected IBusinessManage _BLL_BusinessManage = null;
public frmBaseBusiness()
{
InitializeComponent();
}
private void btnGenerateBusiness_Click(object sender, EventArgs e)
{
this.DoGenerateBusiness();// 打开单据自动生成向导
}
/// <summary>
/// 打开单据自动生成向导
/// </summary>
public virtual void DoGenerateBusiness()
{
//
}
#region IDataOperatable Members
public bool DataChanged
{
get { return false; }
}
public virtual void DoAdd()
{
Msg.ShowInformation("新增状态。。。。");
}
#endregion
#region IBusinessSupportableForm Members
public IBusinessManage BLL_BusinessManage
{
get { return _BLL_BusinessManage; }
}
#endregion
}
//来源:C/S框架网(www.csframework.com) QQ:1980854898
生成单据向导窗体仅依赖IGenerateItem接口,LoadItems方法动态加载多个项目定义(IGenerateItem),项目定义由具体的业务窗体指定。
下面的代码是销售报价窗体(QO)生成项目定义:
C# Code:
public override void DoGenerateBusiness()
{
//由当前单据生成其它单据
string docNO = "QO-2010XX-001"; //便于演示,指定一个单号
//可以由QO生成两种单据
List<IGenerateItem> items = new List<IGenerateItem>();
items.Add(new QO2DO(docNO, docNO == string.Empty, typeof(frmDO), "发货单(Delivery Order)"));
items.Add(new QO2SI(docNO, docNO == string.Empty, typeof(frmSI), "销售FA票(Sales Invoice)"));
frmGenerateWizard.ExecuteWizard("来源单据:" this.Text, items); //调用生成单据向导
}
public override void DoGenerateBusiness()
{
//由当前单据生成其它单据
string docNO = "QO-2010XX-001"; //便于演示,指定一个单号
//可以由QO生成两种单据
List<IGenerateItem> items = new List<IGenerateItem>();
items.Add(new QO2DO(docNO, docNO == string.Empty, typeof(frmDO), "发货单(Delivery Order)"));
items.Add(new QO2SI(docNO, docNO == string.Empty, typeof(frmSI), "销售FA票(Sales Invoice)"));
frmGenerateWizard.ExecuteWizard("来源单据:" this.Text, items); //调用生成单据向导
}
销售报价窗体(QO)打开自动向导
选择由销售报价单(QO)->生成发货单(DO),生成数据成功并自动打开DO窗体。
扫一扫加作者微信
Source Code for VIP:
版权声明:本文为开发框架文库发布内容,转载请附上原文出处连接
NewDoc C/S框架网