/// <summary> /// 查询所有的仓库数据信息 /// </summary> /// <returns></returns> public List <StorageEntity> GetList() { string Key = string.Format(CacheKey.JOOSHOW_STORAGE_CACHE, this.CompanyID); List <StorageEntity> listResult = CacheHelper.Get <List <StorageEntity> >(Key); if (!listResult.IsNullOrEmpty()) { return(listResult); } StorageEntity entity = new StorageEntity(); entity.IncludeAll(); entity.OrderBy(a => a.ID, EOrderBy.DESC); entity.Where(a => a.IsDelete == (int)EIsDelete.NotDelete) .And(a => a.CompanyID == this.CompanyID); SysDepartEntity depart = new SysDepartEntity(); depart.Include(item => new { DepartName = item.DepartName }); entity.Left <SysDepartEntity>(depart, new Params <string, string>() { Item1 = "DepartNum", Item2 = "SnNum" }); listResult = this.Storage.GetList(entity); if (!listResult.IsNullOrEmpty()) { CacheHelper.Add(Key, listResult); } return(listResult); }
/// <summary> /// 获得所有的部门信息 /// </summary> /// <returns></returns> public List <SysDepartEntity> GetList() { string key = string.Format(CacheKey.JOOSHOW_SYSDEPART_CACHE, this.CompanyID); List <SysDepartEntity> listResult = CacheHelper.Get(key) as List <SysDepartEntity>; if (!listResult.IsNullOrEmpty()) { return(listResult); } SysDepartEntity temp = new SysDepartEntity(); temp.IncludeAll(); temp.Where(a => a.IsDelete == (int)EIsDelete.NotDelete) .And(item => item.CompanyID == this.CompanyID); listResult = this.SysDepart.GetList(temp); if (!listResult.IsNullOrEmpty()) { foreach (SysDepartEntity item in listResult) { int depth = listResult.Where(a => a.Left <= item.Left && a.Right >= item.Right).Count(); item.Depth = depth; } foreach (SysDepartEntity entity in listResult.Where(itemParent => !string.IsNullOrEmpty(itemParent.ParentNum))) { SysDepartEntity tempEntity = listResult.SingleOrDefault(item => item.SnNum == entity.ParentNum); if (!tempEntity.IsNull()) { entity.ParentName = tempEntity.DepartName; } } CacheHelper.Insert(key, listResult, null, DateTime.Now.AddDays(1)); } return(listResult); }
/// <summary> /// 使用工号扫描 /// </summary> /// <param name="UserCode"></param> /// <returns></returns> public AdminEntity Scan(string UserCode) { AdminEntity entity = new AdminEntity(); entity.IncludeAll(); entity.Exclude(a => a.PassWord); entity.Where(a => a.IsDelete == (int)EIsDelete.NotDelete) .And <AdminEntity>(a => a.CompanyID == CompanyID) .And(item => item.UserCode == UserCode) ; entity = this.Admin.GetSingle(entity); if (entity != null) { SysRoleProvider RoleProvider = new SysRoleProvider(this.CompanyID); DepartProvider DepartProvider = new DepartProvider(this.CompanyID); if (entity.RoleNum.IsNotEmpty()) { SysRoleEntity RoleEntity = RoleProvider.GetRoleEntity(entity.RoleNum); entity.RoleName = RoleEntity != null ? RoleEntity.RoleName : string.Empty; } if (entity.DepartNum.IsNotEmpty()) { SysDepartEntity DepartEntity = DepartProvider.GetSingle(entity.DepartNum); entity.DepartName = DepartEntity != null ? DepartEntity.DepartName : string.Empty; } } return(entity); }
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())); }
/// <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))); }
/// <summary> /// 新增部门 /// </summary> /// <returns></returns> public int Add(SysDepartEntity entity) { string Key = string.Format(CacheKey.JOOSHOW_SYSDEPART_CACHE, this.CompanyID); if (entity.ParentNum.IsEmpty()) { SysDepartEntity parent = GetRoot(); entity.ParentNum = GetRoot().SnNum; } List <SysDepartEntity> listSource = GetList(); listSource = listSource.IsNull() ? new List <SysDepartEntity>() : listSource; using (TransactionScope ts = new TransactionScope()) { //查询新增节点的上一个节点 SysDepartEntity parent = listSource.FirstOrDefault(item => item.SnNum == entity.ParentNum); int rightValue = parent.Right; List <SysDepartEntity> listNodes = listSource.Where(item => item.Right >= rightValue).ToList(); if (!listNodes.IsNullOrEmpty()) { foreach (SysDepartEntity item in listNodes) { item.Right += 2; item.IncludeRight(true); item.Where(b => b.SnNum == item.SnNum).And(b => item.CompanyID == this.CompanyID); this.SysDepart.Update(item); } } listNodes = listSource.Where(item => item.Left >= rightValue).ToList(); if (!listNodes.IsNullOrEmpty()) { foreach (SysDepartEntity item in listNodes) { item.Left += 2; item.IncludeLeft(true); item.Where(b => b.SnNum == item.SnNum).And(b => item.CompanyID == this.CompanyID); this.SysDepart.Update(item); } } entity.SnNum = ConvertHelper.NewGuid(); entity.DepartNum = entity.DepartNum.IsEmpty() ? new TNumProvider(this.CompanyID).GetSwiftNum(typeof(SysDepartEntity), 5) : string.Empty; entity.CompanyID = this.CompanyID; entity.IsDelete = (int)EIsDelete.NotDelete; entity.CreateTime = DateTime.Now; entity.Left = rightValue; entity.Right = rightValue + 1; entity.IncludeAll(); int line = this.SysDepart.Add(entity); if (line > 0) { CacheHelper.Remove(Key); } ts.Complete(); return(line); } }
/// <summary> /// 查询用户管理员分页 /// </summary> /// <param name="entity"></param> /// <param name="pageInfo"></param> /// <returns></returns> public List <AdminEntity> GetList(AdminEntity entity, ref PageInfo pageInfo) { entity.IncludeAll(); entity.Exclude(a => a.PassWord); entity.OrderBy(a => a.ID, EOrderBy.DESC); entity.Where(a => a.IsDelete == (int)EIsDelete.NotDelete); entity.And(a => a.CompanyID == entity.CompanyID); entity.And(item => item.UserCode != "DA_0000"); if (!entity.UserName.IsEmpty()) { entity.And("UserName", ECondition.Like, "%" + entity.UserName + "%"); } if (!entity.UserCode.IsEmpty()) { entity.And("UserCode", ECondition.Like, "%" + entity.UserCode + "%"); } if (!entity.RoleNum.IsEmpty()) { entity.And(a => a.RoleNum == entity.RoleNum); } if (!entity.DepartNum.IsEmpty()) { DepartProvider provider = new DepartProvider(this.CompanyID); List <SysDepartEntity> listDepart = provider.GetChildList(entity.DepartNum); string[] items = null; if (!listDepart.IsNullOrEmpty()) { items = listDepart.Select(item => item.SnNum).ToArray(); entity.And("DepartNum", ECondition.In, items); } } int rowCount = 0; List <AdminEntity> listResult = this.Admin.GetList(entity, pageInfo.PageSize, pageInfo.PageIndex, out rowCount); pageInfo.RowCount = rowCount; if (!listResult.IsNullOrEmpty()) { SysRoleProvider RoleProvider = new SysRoleProvider(this.CompanyID); DepartProvider DepartProvider = new DepartProvider(this.CompanyID); foreach (AdminEntity item in listResult) { if (item.RoleNum.IsNotEmpty()) { SysRoleEntity RoleEntity = RoleProvider.GetRoleEntity(item.RoleNum); item.RoleName = RoleEntity != null ? RoleEntity.RoleName : string.Empty; } if (item.DepartNum.IsNotEmpty()) { SysDepartEntity DepartEntity = DepartProvider.GetSingle(item.DepartNum); item.DepartName = DepartEntity != null ? DepartEntity.DepartName : string.Empty; } } } return(listResult); }
/// <summary> /// 获得所有的部门信息 /// </summary> /// <returns></returns> public List <SysDepartEntity> GetList() { List <SysDepartEntity> listResult = CacheHelper.Get(CacheKey.JOOSHOW_SYSDEPART_CACHE) as List <SysDepartEntity>; if (!listResult.IsNullOrEmpty()) { return(listResult); } SysDepartEntity temp = new SysDepartEntity(); temp.IncludeID(true) .IncludeChildCount(true) .IncludeCreateTime(true) .IncludeDepartName(true) .IncludeDepartNum(true) .IncludeDepth(true) .IncludeParentNum(true) ; temp.Where(a => a.IsDelete == (int)EIsDelete.NotDelete); listResult = this.SysDepart.GetList(temp); if (!listResult.IsNullOrEmpty()) { foreach (SysDepartEntity entity in listResult.Where(itemParent => !string.IsNullOrEmpty(itemParent.ParentNum))) { SysDepartEntity tempEntity = listResult.SingleOrDefault(item => item.DepartNum == entity.ParentNum); if (!tempEntity.IsNull()) { entity.ParentName = tempEntity.DepartName; } } CacheHelper.Insert(CacheKey.JOOSHOW_SYSDEPART_CACHE, listResult, null, DateTime.Now.AddHours(5)); } return(listResult); }
/// <summary> /// 查询用户管理员分页 /// </summary> /// <param name="entity"></param> /// <param name="pageInfo"></param> /// <returns></returns> public List <AdminEntity> GetList(AdminEntity entity, ref PageInfo pageInfo) { entity.IncludeAll(); entity.OrderBy(a => a.ID, EOrderBy.DESC); entity.Where(a => a.IsDelete == (int)EIsDelete.NotDelete); SysRoleEntity roleEntity = new SysRoleEntity(); roleEntity.Include("RoleName", "RoleName"); entity.Left <SysRoleEntity>(roleEntity, new Params <string, string>() { Item1 = "RoleNum", Item2 = "RoleNum" }); SysDepartEntity departEntity = new SysDepartEntity(); departEntity.Include("DepartName", "DepartName"); entity.Left <SysDepartEntity>(departEntity, new Params <string, string>() { Item1 = "DepartNum", Item2 = "DepartNum" }); int rowCount = 0; List <AdminEntity> listResult = this.Admin.GetList(entity, pageInfo.PageSize, pageInfo.PageIndex, out rowCount); pageInfo.RowCount = rowCount; return(listResult); }
/// <summary> /// 部门查看分页 /// </summary> /// <param name="entity"></param> /// <param name="pageInfo"></param> /// <returns></returns> public List <SysDepartEntity> GetList(SysDepartEntity entity, ref PageInfo pageInfo) { List <SysDepartEntity> listSource = GetList(); if (listSource.IsNullOrEmpty()) { return(listSource); } listSource = listSource.Where(item => item.ParentNum.IsNotEmpty()).ToList(); if (!entity.DepartName.IsEmpty()) { listSource = listSource.Where(a => a.DepartName.Contains(entity.DepartName)).ToList(); } if (!entity.DepartNum.IsEmpty()) { listSource = listSource.Where(a => a.DepartNum == entity.DepartNum).ToList(); } int rowCount = listSource.Count; pageInfo.RowCount = rowCount; List <SysDepartEntity> listResult = listSource.Skip((pageInfo.PageIndex - 1) * pageInfo.PageSize).Take(pageInfo.PageSize).ToList(); if (!listResult.IsNullOrEmpty()) { listResult.ForEach(item => { if (item.ParentName == "Root") { item.ParentName = ""; } }); } return(listResult); }
/// <summary> /// 查询根节点 /// </summary> /// <returns></returns> private SysDepartEntity GetRoot() { string Key = string.Format(CacheKey.JOOSHOW_SYSDEPART_CACHE, this.CompanyID); List <SysDepartEntity> listSource = GetList(); if (listSource.IsNullOrEmpty()) { SysDepartEntity entity = new SysDepartEntity(); entity.SnNum = ConvertHelper.NewGuid(); entity.DepartNum = new TNumProvider(this.CompanyID).GetSwiftNum(typeof(SysDepartEntity), 5); entity.IsDelete = (int)EIsDelete.NotDelete; entity.CreateTime = DateTime.Now; entity.DepartName = "Root"; entity.ParentNum = ""; entity.CompanyID = this.CompanyID; entity.Left = 1; entity.Right = 2; entity.IncludeAll(); int line = this.SysDepart.Add(entity); if (line > 0) { CacheHelper.Remove(Key); } } listSource = GetList(); SysDepartEntity result = listSource.First(item => item.ParentNum.IsEmpty()); return(result); }
/// <summary> /// 添加部门 /// </summary> /// <param name="entity"></param> /// <returns></returns> public int Add(SysDepartEntity entity) { entity.DepartNum = entity.DepartNum.IsEmpty() ? DateTime.Now.ToString("yyyyMMddHHmmss") + (new Random(DateTime.Now.Millisecond)).Next(1000, 9999) : entity.DepartNum; entity.ChildCount = 0; SysDepartEntity parent = GetSingle(entity.ParentNum); if (parent.IsNotNull()) { entity.Depth = parent.Depth + 1; parent.ChildCount++; parent.IncludeDepth(true) .IncludeChildCount(true) .Where <SysDepartEntity>("DepartNum", ECondition.Eth); this.SysDepart.Update(parent); } entity.IncludeDepartNum(true) .IncludeDepartName(true) .IncludeChildCount(true) .IncludeParentNum(true) .IncludeDepth(true) .IncludeIsDelete(true) .IncludeCreateTime(true) ; int line = this.SysDepart.Add(entity); if (line > 0) { CacheHelper.Remove(CacheKey.JOOSHOW_SYSDEPART_CACHE); } return(line); }
public ActionResult AddDepart() { string DepartNum = WebUtil.GetQueryStringValue <string>("DepartNum", string.Empty); string CompanyID = this.CompanyID; string ParentNum = string.Empty; SysDepartEntity entity = null; if (!DepartNum.IsEmpty()) { ITopClient client = new TopClientDefault(); Dictionary <string, string> dic = new Dictionary <string, string>(); dic.Add("CompanyID", CompanyID); dic.Add("DepartNum", DepartNum); string result = client.Execute(DepartApiName.DepartApiName_Single, dic); if (!result.IsEmpty()) { DataResult <SysDepartEntity> dataResult = JsonConvert.DeserializeObject <DataResult <SysDepartEntity> >(result); entity = dataResult.Result; } } entity = entity.IsNull() ? new SysDepartEntity() : entity; ViewBag.Entity = entity; ParentNum = entity.ParentNum; ViewBag.DepartList = DropDownHelper.GetDepart(ParentNum, CompanyID); return(View()); }
/// <summary> /// 查询分页 /// </summary> /// <returns></returns> public ActionResult GetPage() { string CompanyID = WebUtil.GetFormValue <string>("CompanyID"); int PageIndex = WebUtil.GetFormValue <int>("PageIndex", 1); int PageSize = WebUtil.GetFormValue <int>("PageSize", 10); string DepartName = WebUtil.GetFormValue <string>("DepartName", string.Empty); string ParentNum = WebUtil.GetFormValue <string>("ParentNum", string.Empty); SysDepartEntity entity = new SysDepartEntity(); entity.DepartName = DepartName; entity.ParentNum = ParentNum; PageInfo pageInfo = new PageInfo(); pageInfo.PageIndex = PageIndex; pageInfo.PageSize = PageSize; DepartProvider provider = new DepartProvider(CompanyID); List <SysDepartEntity> list = provider.GetList(entity, ref pageInfo); DataListResult <SysDepartEntity> result = new DataListResult <SysDepartEntity>() { Code = (int)EResponseCode.Success, Message = "响应成功", Result = list, PageInfo = pageInfo }; return(Content(JsonHelper.SerializeObject(result))); }
/// <summary> /// 删除部门信息 /// </summary> /// <param name="list"></param> /// <param name="CompanyID"></param> /// <returns></returns> public int Delete(IEnumerable <string> list) { string key = string.Format(CacheKey.JOOSHOW_SYSDEPART_CACHE, this.CompanyID); using (TransactionScope ts = new TransactionScope()) { int line = 0; List <SysDepartEntity> listSource = GetList(); listSource = listSource.IsNull() ? new List <SysDepartEntity>() : listSource; foreach (string item in list) { SysDepartEntity parent = listSource.FirstOrDefault(a => a.SnNum == item); int rightValue = parent.Right; int leftValue = parent.Left; SysDepartEntity delDepart = new SysDepartEntity(); delDepart.IsDelete = (int)EIsDelete.Deleted; delDepart.IncludeIsDelete(true); delDepart.Where(a => a.Left >= leftValue) .And(a => a.Right <= rightValue) .And(a => a.CompanyID == this.CompanyID) ; line += this.SysDepart.Update(delDepart); List <SysDepartEntity> listNodes = listSource.Where(a => a.Left > leftValue).ToList(); if (!listNodes.IsNullOrEmpty()) { foreach (SysDepartEntity depart in listNodes) { depart.Left = depart.Left - (rightValue - leftValue + 1); depart.IncludeLeft(true); depart.Where(a => a.SnNum == depart.SnNum).And(a => a.CompanyID == this.CompanyID); line += this.SysDepart.Update(depart); } } listNodes = listSource.Where(a => a.Right > rightValue).ToList(); if (!listNodes.IsNullOrEmpty()) { foreach (SysDepartEntity depart in listNodes) { depart.Right = depart.Right - (rightValue - leftValue + 1); depart.IncludeRight(true); depart.Where(a => a.SnNum == depart.SnNum).And(a => a.CompanyID == this.CompanyID); line += this.SysDepart.Update(depart); } } } ts.Complete(); if (line > 0) { CacheHelper.Remove(key); } return(line); } }
/// <summary> /// 根据部门编号获得部门信息 /// </summary> /// <param name="departNum"></param> /// <returns></returns> public SysDepartEntity GetSingle(string departNum) { List <SysDepartEntity> listResult = GetList(); if (!listResult.IsNullOrEmpty() && !departNum.IsEmpty()) { SysDepartEntity entity = listResult.SingleOrDefault(item => item.DepartNum == departNum); return(entity); } return(null); }
/// <summary> /// 批量删除部门 /// </summary> /// <param name="items"></param> /// <returns></returns> public int DeleteDepart(int[] items) { SysDepartEntity entity = new SysDepartEntity(); int line = this.SysDepart.Delete(items); if (line > 0) { CacheHelper.Remove(CacheKey.JOOSHOW_SYSDEPART_CACHE); } return(line); }
/// <summary> /// 查询族谱路径 /// </summary> /// <param name="SnNum"></param> /// <returns></returns> public List <SysDepartEntity> GetParentList(string SnNum) { SysDepartEntity node = GetSingle(SnNum); List <SysDepartEntity> listSource = GetList(); if (node != null && listSource != null) { listSource = listSource.Where(item => item.ParentNum.IsNotEmpty()).ToList(); return(listSource.Where(item => item.Left <= node.Left && item.Right >= node.Right).ToList()); } return(null); }
public ActionResult ToExcel() { PageInfo pageInfo = new Git.Framework.DataTypes.PageInfo() { PageIndex = 1, PageSize = Int32.MaxValue }; string departName = WebUtil.GetFormValue <string>("departName", string.Empty); DepartProvider provider = new DepartProvider(); SysDepartEntity entity = new SysDepartEntity(); List <SysDepartEntity> list = provider.GetList(); List <SysDepartEntity> listResult = new List <SysDepartEntity>(); if (!list.IsNullOrEmpty()) { listResult = list.Where(a => a.DepartName.Contains(departName) || a.DepartNum.Contains(departName)).OrderByDescending(a => a.ID).ToList(); } if (!listResult.IsNullOrEmpty()) { DataTable dt = new DataTable(); dt.Columns.Add(new DataColumn("序号")); dt.Columns.Add(new DataColumn("部门编号")); dt.Columns.Add(new DataColumn("部门名")); dt.Columns.Add(new DataColumn("创建时间")); int count = 1; foreach (SysDepartEntity t in listResult) { DataRow row = dt.NewRow(); row[0] = count; row[1] = t.DepartNum; row[2] = t.DepartName; row[3] = t.CreateTime; count++; dt.Rows.Add(row); } string filePath = Server.MapPath("~/UploadFiles/"); if (!System.IO.Directory.Exists(filePath)) { System.IO.Directory.CreateDirectory(filePath); } string filename = string.Format("部门管理{0}.xls", DateTime.Now.ToString("yyyyMMddHHmmss")); NPOIExcel excel = new NPOIExcel("部门管理", "部门", System.IO.Path.Combine(filePath, filename)); excel.ToExcel(dt); this.ReturnJson.AddProperty("Path", ("/UploadFiles/" + filename).Escape()); } else { this.ReturnJson.AddProperty("d", "无数据导出!"); } return(Content(this.ReturnJson.ToString())); }
/// <summary> /// 根据编号查询部门信息 /// </summary> /// <param name="DepartNum"></param> /// <returns></returns> public SysDepartEntity GetSingle(string DepartNum) { List <SysDepartEntity> listSource = GetList(); if (listSource.IsNullOrEmpty()) { return(null); } listSource = listSource.Where(item => item.ParentNum.IsNotEmpty()).ToList(); SysDepartEntity depart = listSource.FirstOrDefault(item => item.SnNum == DepartNum); return(depart); }
/// <summary> /// 查询部门信息 /// </summary> /// <returns></returns> public ActionResult Single() { string CompanyID = WebUtil.GetFormValue <string>("CompanyID"); string DepartNum = WebUtil.GetFormValue <string>("DepartNum"); DepartProvider provider = new DepartProvider(CompanyID); SysDepartEntity entity = provider.GetSingle(DepartNum); DataResult <SysDepartEntity> result = new DataResult <SysDepartEntity>() { Code = (int)EResponseCode.Success, Message = "响应成功", Result = entity }; return(Content(JsonHelper.SerializeObject(result))); }
/// <summary> /// 根据主键编号修改部门信息(修改部门名和部门级别) /// </summary> /// <param name="entity"></param> /// <returns></returns> public int UpdateDepartByID(SysDepartEntity entity) { entity.IncludeDepartName(true) .IncludeParentNum(true); entity.Where <SysDepartEntity>("ID", ECondition.Eth); int line = this.SysDepart.Update(entity); if (line > 0) { CacheHelper.Remove(CacheKey.JOOSHOW_SYSDEPART_CACHE); } return(line); }
public static SysDepart_CE ToCE(SysDepartEntity item) { SysDepart_CE target = new SysDepart_CE(); target.ID = item.ID; target.DepartNum = item.DepartNum; target.DepartName = item.DepartName; target.ChildCount = item.ChildCount; target.ParentNum = item.ParentNum; target.Depth = item.Depth; target.IsDelete = item.IsDelete; target.CreateTime = item.CreateTime; return(target); }
/// <summary> /// 根据部门编号获得部门信息 /// </summary> /// <param name="id"></param> /// <returns></returns> public SysDepartEntity GetDepartEntity(string DepartNum) { SysDepartEntity entity = new SysDepartEntity() { DepartNum = DepartNum }; entity.IncludeID(true) .IncludeDepartNum(true) .IncludeDepartName(true) .IncludeParentNum(true) .Where <SysDepartEntity>("DepartNum", ECondition.Eth); return(this.SysDepart.GetSingle(entity)); }
/// <summary> /// 修改部门信息(修改部门名称) /// 根据主键和父类编号修改部门信息 /// </summary> /// <param name="entity"></param> /// <returns></returns> public int UpdateDepart(SysDepartEntity entity) { entity.ThrowIfNull("修改部门信息对象为空"); entity.IncludeDepartName(true) ; //entity.Where<SysDepartEntity>("ID", ECondition.Eth) // .And<SysDepartEntity>("ParentNum", ECondition.Eth); entity.Where(a => a.DepartNum == entity.DepartNum); int line = this.SysDepart.Update(entity); if (line > 0) { CacheHelper.Remove(CacheKey.JOOSHOW_SYSDEPART_CACHE); } return(line); }
/// <summary> /// 根据主键编号获得父类部门信息 /// </summary> /// <param name="id"></param> /// <returns></returns> public SysDepartEntity GetParent(int id) { List <SysDepartEntity> listSource = GetList(); if (listSource.IsNullOrEmpty()) { return(null); } SysDepartEntity entity = listSource.SingleOrDefault(item => item.ID == id); if (entity.IsNull()) { return(null); } return(listSource.SingleOrDefault(item => item.DepartNum == entity.ParentNum)); }
/// <summary> /// 修改部门信息 /// </summary> /// <param name="entity"></param> /// <returns></returns> public int Update(SysDepartEntity entity) { string key = string.Format(CacheKey.JOOSHOW_SYSDEPART_CACHE, this.CompanyID); entity.Include(a => new { a.DepartName }); int line = 0; entity.Where(a => a.SnNum == entity.SnNum) .And(item => item.CompanyID == this.CompanyID); line = this.SysDepart.Update(entity); if (line > 0) { CacheHelper.Remove(key); } return(line); }
/// <summary> /// 删除部门 /// </summary> /// <param name="id"></param> /// <returns></returns> public int DeleteDepart(int id) { int line = 0; SysDepartEntity entity = GetDepartEntity(id); if (entity.IsNotNull()) { entity.IncludeIsDelete(true); entity.IsDelete = (int)EIsDelete.Deleted; entity.Where(a => a.ID == id); line = this.SysDepart.Update(entity); if (line > 0) { CacheHelper.Remove(CacheKey.JOOSHOW_SYSDEPART_CACHE); } } return(line); }
public ActionResult AddDepart() { string departNum = WebUtil.GetQueryStringValue <string>("departNum"); if (departNum.IsEmpty()) { ViewBag.SysDepart = new SysDepartEntity(); return(View()); } else { DepartProvider provider = new DepartProvider(); SysDepartEntity entity = provider.GetDepartEntity(departNum); entity = entity == null ? new SysDepartEntity() : entity; ViewBag.SysDepart = entity; return(View()); } }
/// <summary> /// 根据主键编号和父类编号获得部门信息 /// </summary> /// <param name="id"></param> /// <param name="parentID"></param> /// <returns></returns> public SysDepartEntity GetDepartEntity(int id, string ParentNum) { SysDepartEntity entity = new SysDepartEntity() { ID = id, ParentNum = ParentNum }; entity.IncludeID(true) .IncludeDepartNum(true) .IncludeDepartName(true) .IncludeParentNum(true) .IncludeChildCount(true) .IncludeCreateTime(true) .Where <SysDepartEntity>("ID", ECondition.Eth) .And <SysDepartEntity>("ParentNum", ECondition.Eth); List <SysDepartEntity> list = this.SysDepart.GetList(entity); return(list.IsNullOrEmpty() ? null : list[0]); }