/// <summary> /// 新增部门 /// </summary> /// <returns></returns> public ActionResult Add() { string DepartName = WebUtil.GetFormValue <string>("DepartName"); string ParentNum = WebUtil.GetFormValue <string>("ParentNum"); string CompanyID = WebUtil.GetFormValue <string>("CompanyID"); string SnNum = WebUtil.GetFormValue <string>("SnNum"); SysDepartEntity entity = new SysDepartEntity(); entity.SnNum = SnNum; entity.DepartName = DepartName; entity.ChildCount = 0; entity.ParentNum = ParentNum; entity.Depth = 0; entity.IsDelete = (int)EIsDelete.NotDelete; entity.CreateTime = DateTime.Now; entity.CompanyID = CompanyID; DepartProvider provider = new DepartProvider(CompanyID); int line = provider.Add(entity); DataResult result = new DataResult(); if (line > 0) { result.Code = (int)EResponseCode.Success; result.Message = "部门新增成功"; } else { result.Code = (int)EResponseCode.Exception; result.Message = "部门新增失败"; } return(Content(JsonHelper.SerializeObject(result))); }
public ActionResult AddDepart([ModelBinder(typeof(JsonBinder <SysDepartEntity>))] SysDepartEntity entity) { DepartProvider provider = new DepartProvider(); int line = 0; if (entity.DepartNum.IsEmpty()) { entity.DepartNum = SequenceProvider.GetSequence(typeof(SysDepartEntity)); entity.IsDelete = (int)EIsDelete.NotDelete; entity.CreateTime = DateTime.Now; line = provider.Add(entity); } else { line = provider.UpdateDepart(entity); } if (line > 0) { this.ReturnJson.AddProperty("d", "success"); } else { this.ReturnJson.AddProperty("d", ""); } return(Content(this.ReturnJson.ToString())); }