生成工具-CodeSmith-享受编程的乐趣(三)(转载)
2005-08-03 02:12 横刀天笑 阅读(376) 评论(0) 编辑 收藏 举报
第三层、业务对象层,生成的源代码如下: 业务层对象主要提供了基于单条记录的对象和后台供二次开发的manager类 using System; using System.Data; using Keyss.Framework; namespace Keyss.Framework { ArticleClass#region ArticleClass public class ArticleClass:ArticleClassInf { public properties#region public properties public bool Exists { get { return ArticleClassManager_Base.CheckByID(_iD); } } #endregion Tree Properties#region Tree Properties public void AddChild(ArticleClassInf child) { child.ParentID = _iD; ArticleClassManager_Base.Insert(child); } public void CopyChildren(Guid fromID) { ArticleClassManager_Base.CopyChildren(_iD,fromID); } public void DeleteChildren() { System.Data.DataTable table = GetChildren(); foreach(System.Data.DataRow row in table.Rows) { ArticleClassManager_Base.Delete((Guid)row["ID"]); } } public void MoveTo(Guid newParentID) { ArticleClassManager_Base.MoveTo(_iD,newParentID); } public string GetFullName() { string result; string paraStr = "Select [dbo].A_ArticleClass_GetFullName("; paraStr += string.Format("'{0}'",_iD); paraStr += ")"; SqlHelper helper = KeyssConfig.DatabaseHelper; result =(string)helper.ExecuteScalar(paraStr); return result; } public string GetFullID() { string result; string paraStr = "Select [dbo].A_ArticleClass_GetFullID("; paraStr += string.Format("'{0}'",_iD); paraStr += ")"; SqlHelper helper = KeyssConfig.DatabaseHelper; result =(string)helper.ExecuteScalar(paraStr); return result; } public System.Data.DataTable GetChildren() { return ArticleClassManager_Base.GetChildren(_iD); } public System.Data.DataTable GetNonChildren() { return ArticleClassManager_Base.GetNonChildren(_iD); } public System.Data.DataTable GetParents() { return ArticleClassManager_Base.GetParents(_iD); } public int GetLevel() { int result; string paraStr = "Select [dbo].A_ArticleClass_GetLevel("; paraStr += string.Format("'{0}'",_iD); paraStr += ")"; SqlHelper helper = KeyssConfig.DatabaseHelper; result =(int)helper.ExecuteScalar(paraStr); return result; } public ArticleClass GetParent() { if(_parentID==Guid.Empty) return null; else return new ArticleClass(_parentID); } #endregion public methods#region public methods public void Populate(ArticleClassInf articleClassInf) { _iD = articleClassInf.ID; _parentID = articleClassInf.ParentID; _name = articleClassInf.Name; _description = articleClassInf.Description; _orderBy = articleClassInf.OrderBy; _imgUrl = articleClassInf.ImgUrl; _iconUrl = articleClassInf.IconUrl; } #endregion construction#region construction public ArticleClass(Guid iD) { 阅读全文(27) | 回复(0) | 引用通告(0) | 编辑 |