表单上实现增删改查,除了生成的BLL,DAL和ORM表,还需要处理什么?
表单上实现增删改查,除了生成的BLL,DAL和ORM表,还需要处理什么?
扫一扫加作者微信
比如开发数据字典窗体,当您生成了BLL,DAL,ORM的代码已经完成一半工作量了,最后设计数据操作窗体,可复制开发框架提供的模板界面改名,参考最简单的字典窗体frmProduct.cs
namespace CSFramework3.DataDictionary
{
/// <summary>
/// 产品资料管理类
/// </summary>
public partial class frmProduct : frmBaseDataDictionary
{
private bllProduct _BllInstance; //业务逻辑层对象引用
public frmProduct()
{
InitializeComponent();
}
private void frmProduct_Load(object sender, EventArgs e)
{
this.InitializeForm();
}
protected override void InitializeForm()
{
_SummaryView = new DevGridView(gvSummary);//每个业务窗体必需给这个变量赋值.
_ActiveEditor = txtPcode;
_KeyEditor = txtPcode;
_DetailGroupControl = gcDetailEditor;
_BLL = new bllProduct(); //业务逻辑实例
_BllInstance = _BLL as bllProduct; //本窗体引用
base.InitializeForm();
}
// 检查主表数据是否完整或合法
protected override bool ValidatingData()
{
if (txtPcode.Text == string.Empty)
{
Msg.Warning("编号不能为空!");
txtPcode.Focus();
return false;
}
if (txtPname.Text.Trim() == string.Empty)
{
Msg.Warning("名称不能为空!");
txtPname.Focus();
return false;
}
if (_UpdateType == UpdateType.Add)
{
if (_BLL.CheckNoExists(txtPcode.Text))
{
Msg.Warning("编号已存在!");
txtPcode.Focus();
return false;
}
}
return true;
}
/// <summary>
/// 绑定输入框
/// </summary>
/// <param name="summary"></param>
protected override void DoBindingSummaryEditor(DataTable summary)
{
try
{
if (summary == null) return;
DataBinder.BindingTextEdit(txtPcode, summary, tb_Product.ProductCode);
DataBinder.BindingTextEdit(txtPname, summary, tb_Product.ProductName);
DataBinder.BindingTextEdit(txtPrice, summary, tb_Product.SellPrice);
DataBinder.BindingTextEdit(txtRemark, summary, tb_Product.Remark);
DataBinder.BindingTextEdit(txtSupplier, summary, tb_Product.Supplier);
}
catch (Exception ex)
{ Msg.ShowException(ex); }
}
}
}
// 来源:www.CSFramework.com, C/S结构框架学习网
{
/// <summary>
/// 产品资料管理类
/// </summary>
public partial class frmProduct : frmBaseDataDictionary
{
private bllProduct _BllInstance; //业务逻辑层对象引用
public frmProduct()
{
InitializeComponent();
}
private void frmProduct_Load(object sender, EventArgs e)
{
this.InitializeForm();
}
protected override void InitializeForm()
{
_SummaryView = new DevGridView(gvSummary);//每个业务窗体必需给这个变量赋值.
_ActiveEditor = txtPcode;
_KeyEditor = txtPcode;
_DetailGroupControl = gcDetailEditor;
_BLL = new bllProduct(); //业务逻辑实例
_BllInstance = _BLL as bllProduct; //本窗体引用
base.InitializeForm();
}
// 检查主表数据是否完整或合法
protected override bool ValidatingData()
{
if (txtPcode.Text == string.Empty)
{
Msg.Warning("编号不能为空!");
txtPcode.Focus();
return false;
}
if (txtPname.Text.Trim() == string.Empty)
{
Msg.Warning("名称不能为空!");
txtPname.Focus();
return false;
}
if (_UpdateType == UpdateType.Add)
{
if (_BLL.CheckNoExists(txtPcode.Text))
{
Msg.Warning("编号已存在!");
txtPcode.Focus();
return false;
}
}
return true;
}
/// <summary>
/// 绑定输入框
/// </summary>
/// <param name="summary"></param>
protected override void DoBindingSummaryEditor(DataTable summary)
{
try
{
if (summary == null) return;
DataBinder.BindingTextEdit(txtPcode, summary, tb_Product.ProductCode);
DataBinder.BindingTextEdit(txtPname, summary, tb_Product.ProductName);
DataBinder.BindingTextEdit(txtPrice, summary, tb_Product.SellPrice);
DataBinder.BindingTextEdit(txtRemark, summary, tb_Product.Remark);
DataBinder.BindingTextEdit(txtSupplier, summary, tb_Product.Supplier);
}
catch (Exception ex)
{ Msg.ShowException(ex); }
}
}
}
// 来源:www.CSFramework.com, C/S结构框架学习网
业务单据窗体要复杂很多,因为涉及到多张资料表的开发,框架提供很多模板窗体,跟据业务需求先建立好数据表,明确主外键关系,然后依次生成ORM, DAL, BLL, 操作步骤与字典窗体大致相同。
开发框架V4.x|v5.x版本,代码生成器支持生成FORM,BLL, DAL, MODEL的源码。
C/S系统快速开发框架-旗舰版代码生成器 v5.0
适用开发:C/S系统开发框架企业版V4.5.x、旗舰版V5.0
运行平台:Windows + .NET Framework 4.5
开发工具:Visual Studio 2015,C#语言
数据库:Microsoft SQLServer 2008R2
运行平台:Windows + .NET Framework 4.5
开发工具:Visual Studio 2015,C#语言
数据库:Microsoft SQLServer 2008R2
http://www.csframework.com/cs-code-generator.htm
扫一扫加作者微信
版权声明:本文为开发框架文库发布内容,转载请附上原文出处连接
NewDoc C/S框架网