Database2Sharp重要更新之生成Winform框架界面代码
2011-09-05 22:49
621 查看
Database2Sharp是一款代码生成工具和数据库文档生成工具,该工具一直伴随着我及我的粉丝们经历过各种各样的项目开发,在实际开发中能带来效率的提高及编程的快乐。不过自上个6.0版本以来,我一直忙于各种项目及研究中,很少继续把新的思想整合进去,最近在做我的Winform开发框架的整理工作,觉得应该改进这段时间来发现的问题,并融入已经逐渐完善的Winform开发框架基础上来,于是经过几天的努力,把该代码生成工具的一些缺陷修复并增加了Winform界面代码生成的功能(以前一直只是生成底层及Web界面层),并重新命名版本号为7.0。以后再继续完善后,在此大版本上再继续升级吧。 View Code using System;
using System.Text;
using System.Data;
using System.Drawing;
using System.Windows.Forms;
using System.ComponentModel;
using System.Collections.Generic;
using WHC.Dictionary;
using WHC.OrderWater.Commons;
using WHC.TestProject.BLL;
using WHC.TestProject.Entity;
namespace WHC.TestProject.UI
{
public partial class FrmEditItemDetail : BaseEditForm
{
public FrmEditItemDetail()
{
InitializeComponent();
}
/// <summary>
/// 实现控件输入检查的函数
/// </summary>
/// <returns></returns>
public override bool CheckInput()
{
bool result = true;//默认是可以通过
#region MyRegion
if (this.txtItemNo.Text.Trim().Length == 0)
{
MessageUtil.ShowTips("请输入备件编号");
this.txtItemNo.Focus();
result = false;
}
else if (this.txtItemName.Text.Trim().Length == 0)
{
MessageUtil.ShowTips("请输入备件名称");
this.txtItemName.Focus();
result = false;
}
else if (this.txtManufacture.Text.Trim().Length == 0)
{
MessageUtil.ShowTips("请输入供货商");
this.txtManufacture.Focus();
result = false;
}
#endregion
return result;
}
/// <summary>
/// 初始化数据字典
/// </summary>
private void InitDictItem()
{
//初始化代码
}
/// <summary>
/// 数据显示的函数
/// </summary>
public override void DisplayData()
{
InitDictItem();//数据字典加载(公用)
if (!string.IsNullOrEmpty(ID))
{
#region 显示客户信息
ItemDetailInfo info = BLLFactory<ItemDetail>.Instance.FindByID(ID);
if (info != null)
{
txtItemNo.Text = info.ItemNo;
txtItemName.Text = info.ItemName;
txtManufacture.Text = info.Manufacture;
txtMapNo.Text = info.MapNo;
txtSpecification.Text = info.Specification;
txtMaterial.Text = info.Material;
txtItemBigType.Text = info.ItemBigType;
txtItemType.Text = info.ItemType;
txtUnit.Text = info.Unit;
txtPrice.Text = info.Price;
txtSource.Text = info.Source;
txtStoragePos.Text = info.StoragePos;
txtUsagePos.Text = info.UsagePos;
txtNote.Text = info.Note;
txtWareHouse.Text = info.WareHouse;
txtDept.Text = info.Dept;
}
#endregion
//this.btnOK.Enabled = Portal.gc.HasFunction("ItemDetail/Edit");
}
else
{
//this.btnOK.Enabled = Portal.gc.HasFunction("ItemDetail/Add");
}
}
/// <summary>
/// 编辑或者保存状态下取值函数
/// </summary>
/// <param name="info"></param>
private void SetInfo(ItemDetailInfo info)
{
info.ItemNo = txtItemNo.Text;
info.ItemName = txtItemName.Text;
info.Manufacture = txtManufacture.Text;
info.MapNo = txtMapNo.Text;
info.Specification = txtSpecification.Text;
info.Material = txtMaterial.Text;
info.ItemBigType = txtItemBigType.Text;
info.ItemType = txtItemType.Text;
info.Unit = txtUnit.Text;
info.Price = txtPrice.Text;
info.Source = txtSource.Text;
info.StoragePos = txtStoragePos.Text;
info.UsagePos = txtUsagePos.Text;
info.Note = txtNote.Text;
info.WareHouse = txtWareHouse.Text;
info.Dept = txtDept.Text;
}
/// <summary>
/// 新增状态下的数据保存
/// </summary>
/// <returns></returns>
public override bool SaveAddNew()
{
ItemDetailInfo info = new ItemDetailInfo();
SetInfo(info);
try
{
#region 新增数据
//检查是否还有其他相同关键字的记录
bool exist = BLLFactory<ItemDetail>.Instance.IsExistKey("ItemNo", info.ItemNo);
if (exist)
{
MessageUtil.ShowTips("指定的【备件编号】已经存在,不能重复添加,请修改");
return false;
}
bool succeed = BLLFactory<ItemDetail>.Instance.Insert(info);
if (succeed)
{
//可添加其他关联操作
return true;
}
#endregion
}
catch (Exception ex)
{
LogHelper.Error(ex);
MessageUtil.ShowError(ex.Message);
}
return false;
}
/// <summary>
/// 编辑状态下的数据保存
/// </summary>
/// <returns></returns>
public override bool SaveUpdated()
{
//检查不同ID是否还有其他相同关键字的记录
bool exist = BLLFactory<ItemDetail>.Instance.CheckExist(this.txtItemNo.Text, ID);
if (exist)
{
MessageUtil.ShowTips("指定的【备件编号】已经存在,不能重复添加,请修改");
return false;
}
ItemDetailInfo info = BLLFactory<ItemDetail>.Instance.FindByID(ID);
if (info != null)
{
SetInfo(info);
try
{
#region 更新数据
bool succeed = BLLFactory<ItemDetail>.Instance.Update(info, info.ID.ToString());
if (succeed)
{
//可添加其他关联操作
return true;
}
#endregion
}
catch (Exception ex)
{
LogHelper.Error(ex);
MessageUtil.ShowError(ex.Message);
}
}
return false;
}
}
}
DevExpress界面效果图
Database2Sharp代码生成工具已经上传到服务器,需要该代码生成工具的,请到下载地址(http://www.iqidi.com/download/Database2SharpSetup.rar )下载。
using System.Text;
using System.Data;
using System.Drawing;
using System.Windows.Forms;
using System.ComponentModel;
using System.Collections.Generic;
using WHC.Dictionary;
using WHC.OrderWater.Commons;
using WHC.TestProject.BLL;
using WHC.TestProject.Entity;
namespace WHC.TestProject.UI
{
public partial class FrmEditItemDetail : BaseEditForm
{
public FrmEditItemDetail()
{
InitializeComponent();
}
/// <summary>
/// 实现控件输入检查的函数
/// </summary>
/// <returns></returns>
public override bool CheckInput()
{
bool result = true;//默认是可以通过
#region MyRegion
if (this.txtItemNo.Text.Trim().Length == 0)
{
MessageUtil.ShowTips("请输入备件编号");
this.txtItemNo.Focus();
result = false;
}
else if (this.txtItemName.Text.Trim().Length == 0)
{
MessageUtil.ShowTips("请输入备件名称");
this.txtItemName.Focus();
result = false;
}
else if (this.txtManufacture.Text.Trim().Length == 0)
{
MessageUtil.ShowTips("请输入供货商");
this.txtManufacture.Focus();
result = false;
}
#endregion
return result;
}
/// <summary>
/// 初始化数据字典
/// </summary>
private void InitDictItem()
{
//初始化代码
}
/// <summary>
/// 数据显示的函数
/// </summary>
public override void DisplayData()
{
InitDictItem();//数据字典加载(公用)
if (!string.IsNullOrEmpty(ID))
{
#region 显示客户信息
ItemDetailInfo info = BLLFactory<ItemDetail>.Instance.FindByID(ID);
if (info != null)
{
txtItemNo.Text = info.ItemNo;
txtItemName.Text = info.ItemName;
txtManufacture.Text = info.Manufacture;
txtMapNo.Text = info.MapNo;
txtSpecification.Text = info.Specification;
txtMaterial.Text = info.Material;
txtItemBigType.Text = info.ItemBigType;
txtItemType.Text = info.ItemType;
txtUnit.Text = info.Unit;
txtPrice.Text = info.Price;
txtSource.Text = info.Source;
txtStoragePos.Text = info.StoragePos;
txtUsagePos.Text = info.UsagePos;
txtNote.Text = info.Note;
txtWareHouse.Text = info.WareHouse;
txtDept.Text = info.Dept;
}
#endregion
//this.btnOK.Enabled = Portal.gc.HasFunction("ItemDetail/Edit");
}
else
{
//this.btnOK.Enabled = Portal.gc.HasFunction("ItemDetail/Add");
}
}
/// <summary>
/// 编辑或者保存状态下取值函数
/// </summary>
/// <param name="info"></param>
private void SetInfo(ItemDetailInfo info)
{
info.ItemNo = txtItemNo.Text;
info.ItemName = txtItemName.Text;
info.Manufacture = txtManufacture.Text;
info.MapNo = txtMapNo.Text;
info.Specification = txtSpecification.Text;
info.Material = txtMaterial.Text;
info.ItemBigType = txtItemBigType.Text;
info.ItemType = txtItemType.Text;
info.Unit = txtUnit.Text;
info.Price = txtPrice.Text;
info.Source = txtSource.Text;
info.StoragePos = txtStoragePos.Text;
info.UsagePos = txtUsagePos.Text;
info.Note = txtNote.Text;
info.WareHouse = txtWareHouse.Text;
info.Dept = txtDept.Text;
}
/// <summary>
/// 新增状态下的数据保存
/// </summary>
/// <returns></returns>
public override bool SaveAddNew()
{
ItemDetailInfo info = new ItemDetailInfo();
SetInfo(info);
try
{
#region 新增数据
//检查是否还有其他相同关键字的记录
bool exist = BLLFactory<ItemDetail>.Instance.IsExistKey("ItemNo", info.ItemNo);
if (exist)
{
MessageUtil.ShowTips("指定的【备件编号】已经存在,不能重复添加,请修改");
return false;
}
bool succeed = BLLFactory<ItemDetail>.Instance.Insert(info);
if (succeed)
{
//可添加其他关联操作
return true;
}
#endregion
}
catch (Exception ex)
{
LogHelper.Error(ex);
MessageUtil.ShowError(ex.Message);
}
return false;
}
/// <summary>
/// 编辑状态下的数据保存
/// </summary>
/// <returns></returns>
public override bool SaveUpdated()
{
//检查不同ID是否还有其他相同关键字的记录
bool exist = BLLFactory<ItemDetail>.Instance.CheckExist(this.txtItemNo.Text, ID);
if (exist)
{
MessageUtil.ShowTips("指定的【备件编号】已经存在,不能重复添加,请修改");
return false;
}
ItemDetailInfo info = BLLFactory<ItemDetail>.Instance.FindByID(ID);
if (info != null)
{
SetInfo(info);
try
{
#region 更新数据
bool succeed = BLLFactory<ItemDetail>.Instance.Update(info, info.ID.ToString());
if (succeed)
{
//可添加其他关联操作
return true;
}
#endregion
}
catch (Exception ex)
{
LogHelper.Error(ex);
MessageUtil.ShowError(ex.Message);
}
}
return false;
}
}
}
DevExpress界面效果图
Database2Sharp代码生成工具已经上传到服务器,需要该代码生成工具的,请到下载地址(http://www.iqidi.com/download/Database2SharpSetup.rar )下载。
相关文章推荐
- Database2Sharp之混合型Winform框架代码生成
- 代码生成工具更新--快速生成Winform框架的界面项目
- Database2Sharp之混合型Winform框架代码生成
- 代码生成工具更新--快速生成Winform框架的界面项目
- 调整代码生成工具Database2Sharp的Winform界面生成,使其易于列表工具栏的使用。
- 代码生成工具Database2Sharp功能功能完善及更新
- 利用代码生成工具Database2Sharp设计数据编辑界面
- Database2Sharp重要更新之数据库文档的生成(国庆专辑,祝福我们的祖国)
- Database2Sharp重要更新之完善EnterpriseLibrary架构代码
- 基于Metronic的Bootstrap开发框架经验总结(18)-- 在代码生成工具Database2Sharp中集成对Bootstrap-table插件的分页及排序支持
- Web界面和Winform界面生成,代码生成工具
- Database2Sharp版本更新之自定义模板生成
- 很方便的工具——代码生成工具之Winform查询列表界面生成
- Web API应用架构在Winform混合框架中的应用(4)--利用代码生成工具快速开发整套应用
- 代码生成工具Database2Sharp中增加视图的代码生成以及主从表界面生成功能
- MDA框架生成代码流程和图例(UML 正向工程,支持Java, C#, Ansi C++, Delphi, Perl, Php5, Python, Database,Ruby, Hibern)
- Database2Sharp代码生成工具使用心得
- 代码生成工具之Winform查询列表界面生成
- 小菜的系统框架界面设计-XiaoCai.WinformUI代码开源
- Winform开发框架之字典管理模块的更新,附上最新2013年全国最新县及县以上行政区划代码sql脚本