HFSoft FrameWork应用案例(1)
2006-10-19 18:01
246 查看
经过一段时间整合终于把平时开发的东西整成一套基于.NET的应用开发框架,框架主要包括以下几个部分:
HFSoft.DLL
共公类库包括:常用函数、数据绑定和对象属性动太调用等功能。
HFSoft.Data.DLL
数据持久组件,提供灵活的数据库访问操作。
HFSoft.BusinessLogic.DLL
业务逻辑基础组件,用于制定统一的业务逻辑处理规则,提供一些简单的业务逻辑规则模板。
HFSoft.Web.DLL
WEB应用的封装,包括一些简单的自定义控件和基于服务端的JavaScript处理。
在实际应用中可以根据需要选择相应的套件。后期会把HFSoft.Report(JavaScript调Excel进行Web报表输出)和HFSoft.Net(Socket的封装应用)也集成在框架中。
接下来是运用HFSoft FrameWork做的一个简单应用案例,案例的主要内容是对产品、产品类别、供应商的简单管理和销售统计;通过案例可以看到基于HFSoft FrameWork进行应用程序开发是件很简单的事情。
案例是调用SqlServer自带数据库NorthWind,通过修改Web.Config文件来设置数据库访问信息。
基于框架的数据操作逻辑代码:
public class ProductAccess:HFSoft.BusinessLogic.ModelLogicAdapter<NorthWind.Entities.Products,int>
{
protected override void OnAdd()
{
if((DBMapping.Products.ProductName==Item.ProductName).CountOf()>0)
{
throw (new HFSoft.BusinessLogic.LogicException(ConstValue.PRODUCT_ADD_ERROR));
}
base.OnAdd();
}
}
基于框架的数据查询逻辑代码:
public class ProductQuery:HFSoft.BusinessLogic.QueryLogicAdapter<ProductFilter,NorthWind.Entities.ProductsView>
{ }
[Serializable]
public class ProductFilter:HFSoft.BusinessLogic.FilterAdapter
{
protected override HFSoft.Data.Expressions.IExpression OnGetExpression()
{
HFSoft.Data.Expressions.Expression exp = new HFSoft.Data.Expressions.Expression(
NorthWind.Entities.DBMapping.Products);
if (!HFSoft.StaticFunction.IsEmpty(ProductName))
{
exp &= DBMapping.Products.ProductName.Match(ProductName);
}
if (!HFSoft.StaticFunction.IsEmpty(Category))
{
exp &= DBMapping.Products.CategoryID == int.Parse(Category);
}
if (!HFSoft.StaticFunction.IsEmpty(Supplier))
{
exp &= DBMapping.Products.SupplierID == int.Parse(Supplier);
}
return exp;
}
public string ProductName;
public string Category;
public string Supplier;
}
在服务端注册JavaScript脚本:
ShowModalDialog show;
HFSoft.Web.Scripts.RegisterScript.RegiOnClick(
cmdNew, OpenPages.OpenProductEdit());
show = OpenPages.OpenProduceSearch();
show.ReturnElements.Add(
new ReturnElement(editFilter.ClientID, "filter"));
HFSoft.Web.Scripts.RegisterScript.RegiOnClick(
cmdSearch, show);
[b]
下载整个案例代码
[/b]
案例操作演示
HFSoft.DLL
共公类库包括:常用函数、数据绑定和对象属性动太调用等功能。
HFSoft.Data.DLL
数据持久组件,提供灵活的数据库访问操作。
HFSoft.BusinessLogic.DLL
业务逻辑基础组件,用于制定统一的业务逻辑处理规则,提供一些简单的业务逻辑规则模板。
HFSoft.Web.DLL
WEB应用的封装,包括一些简单的自定义控件和基于服务端的JavaScript处理。
在实际应用中可以根据需要选择相应的套件。后期会把HFSoft.Report(JavaScript调Excel进行Web报表输出)和HFSoft.Net(Socket的封装应用)也集成在框架中。
接下来是运用HFSoft FrameWork做的一个简单应用案例,案例的主要内容是对产品、产品类别、供应商的简单管理和销售统计;通过案例可以看到基于HFSoft FrameWork进行应用程序开发是件很简单的事情。
案例是调用SqlServer自带数据库NorthWind,通过修改Web.Config文件来设置数据库访问信息。
基于框架的数据操作逻辑代码:
public class ProductAccess:HFSoft.BusinessLogic.ModelLogicAdapter<NorthWind.Entities.Products,int>
{
protected override void OnAdd()
{
if((DBMapping.Products.ProductName==Item.ProductName).CountOf()>0)
{
throw (new HFSoft.BusinessLogic.LogicException(ConstValue.PRODUCT_ADD_ERROR));
}
base.OnAdd();
}
}
基于框架的数据查询逻辑代码:
public class ProductQuery:HFSoft.BusinessLogic.QueryLogicAdapter<ProductFilter,NorthWind.Entities.ProductsView>
{ }
[Serializable]
public class ProductFilter:HFSoft.BusinessLogic.FilterAdapter
{
protected override HFSoft.Data.Expressions.IExpression OnGetExpression()
{
HFSoft.Data.Expressions.Expression exp = new HFSoft.Data.Expressions.Expression(
NorthWind.Entities.DBMapping.Products);
if (!HFSoft.StaticFunction.IsEmpty(ProductName))
{
exp &= DBMapping.Products.ProductName.Match(ProductName);
}
if (!HFSoft.StaticFunction.IsEmpty(Category))
{
exp &= DBMapping.Products.CategoryID == int.Parse(Category);
}
if (!HFSoft.StaticFunction.IsEmpty(Supplier))
{
exp &= DBMapping.Products.SupplierID == int.Parse(Supplier);
}
return exp;
}
public string ProductName;
public string Category;
public string Supplier;
}
在服务端注册JavaScript脚本:
ShowModalDialog show;
HFSoft.Web.Scripts.RegisterScript.RegiOnClick(
cmdNew, OpenPages.OpenProductEdit());
show = OpenPages.OpenProduceSearch();
show.ReturnElements.Add(
new ReturnElement(editFilter.ClientID, "filter"));
HFSoft.Web.Scripts.RegisterScript.RegiOnClick(
cmdSearch, show);
[b]
下载整个案例代码
[/b]
案例操作演示
相关文章推荐
- 图吧导航SDK给江苏省地理信息局应用案例
- Python概率编程库PyMC应用案例二则
- [应用案例]移动短信平台的推广建议
- 纯色背景在网页设计中应用的20佳优秀案例
- TreeView应用案例----无限制级类别管理应用!!!
- 表单验证的完整应用案例探讨
- Bugzilla 系统企业应用案例
- 丝带(Ribbon)在网页设计中应用的20佳优秀案例
- 【笔记】2017电信大数据普惠金融应用案例
- 心得2--Filter过滤器常见应用开发案例分页
- iOS 7第三方应用重设计的解决方案及案例参考
- 网站案例使用 Sails.js 构建和定制企业级的 Node.js 应用
- 2011级-csdn-java-张侃— Servlet监听器在开发中的应用案例
- 一个可供参考的Java高并发异步应用案例
- Websphere安装、企业部署应用 【应用案例】
- 大数据应用之HBase数据插入性能优化之多线程并行插入测试案例
- 银联在线支付---利用测试案例代码模拟支付应用(修改)
- Python循环嵌套应用案例一则:判断丑数
- 阿基米德项目ALS矩阵分解算法应用案例