/// <summary> /// 构造方法 - BaseTree表 /// </summary> /// <param name="row"></param> public BaseTree(Db_BaseTree row) { this.id = row.Id; this.text = row.Name; this.Code = row.Code; this.ParentId = row.ParentId; this.CreatedOn = row.CreatedOn; this.CreatedOnString = this.CreatedOn.ToString("yyyy-MM-dd HH:mm"); this.Seq = row.Seq; this.state = "open"; }
/// <summary> /// 新增树的节点 /// </summary> /// <param name="condtion"></param> /// <returns></returns> public static BaseTree CreateBaseTree(BaseTreeAttr condtion) { ValiDatas.valiData(condtion); var r = CheckCode(condtion.Code); if (r > 0) { throw new ValiDataException(string.Format("code [{0}] 已存在,新增失败", condtion.Code)); } using (var db = new DefaultContainer()) { Db_BaseTree dbTree = new Db_BaseTree() { Id = Guid.NewGuid().ToString(), Code = condtion.Code, CreatedOn = DateTime.Now, Name = condtion.text, ParentId = string.IsNullOrEmpty(condtion.ParentId)? null :condtion.ParentId, Seq = condtion.Seq }; db.Db_BaseTreeSet.Add(dbTree); db.SaveChanges(); return(new BaseTree(dbTree)); } }