您的位置:首页 > 其它

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]

案例操作演示

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: