/// <summary> /// 更新导航栏 /// </summary> /// <param name="str"></param> public static string MenuUpdate(string str) { try { PublicBLL.PubBll <HtMenu> bll = new PublicBLL.PubBll <HtMenu>(); HtMenu entity = bll.ReturnEntity(str); Ht_Menu model = dal.SelectEntities(x => x.ID == entity.ID).FirstOrDefault(); PublicBLL.PubBll <Ht_Menu> bll1 = new PublicBLL.PubBll <Ht_Menu>(); model = bll1.Edit(entity, model); model.LU = Common.Common.UserID;; model.LT = DateTime.Now; if (dal.Update(model, LogBLL.controllog("modify", "更新导航栏_MenuUpdate", str))) { return("保存成功"); } else { return("保存失败"); } } catch (Exception ex) { LogBLL.errorControlLog("modify", "更新导航栏_MenuUpdate", str, ex.ToString()); return("保存失败"); } }
/// <summary> /// 新增导航栏 /// </summary> /// <param name="str"></param> public static string MenuAdd(string str) { try { PublicBLL.PubBll <Ht_Menu> bll = new PublicBLL.PubBll <Ht_Menu>(); Ht_Menu entity = bll.ReturnEntity(str); if (dal.SelectEntities(x => x.Name == entity.Name).Count > 0) { return("该人员已经被赋予角色"); } else { entity.CT = DateTime.Now; entity.CU = Common.Common.UserID; entity.LU = Common.Common.UserID; entity.LT = DateTime.Now; entity.ST = 1; if (dal.Add(entity, LogBLL.controllog("add", "新增导航栏_MenuAdd", str))) { return("保存成功"); } else { return("保存失败"); } } } catch (Exception ex) { LogBLL.errorControlLog("add", "新增导航栏_MenuAdd", str, ex.ToString()); return("保存失败"); } }
/// <summary> /// 禁用开启 /// </summary> /// <returns></returns> public static string MenuDelete(int id) { try { Ht_Menu bean = dal.SelectEntities(x => x.ID == id).FirstOrDefault(); if (bean.ST == 0) { bean.LU = Common.Common.UserID; bean.LT = DateTime.Now; bean.ST = 1; } else { bean.LU = Common.Common.UserID; bean.LT = DateTime.Now; bean.ST = 0; } dal.UpdateEntity(bean, LogBLL.controllog("delete", "导航栏禁用开启_MenuDelete", id.ToString())); return("成功"); } catch (Exception ex) { LogBLL.errorControlLog("delete", "导航栏禁用开启_MenuDelete", id.ToString(), ex.ToString()); return("失败"); } }
/// <summary> /// 保存 /// </summary> /// <returns></returns> public static bool LimitSave(string str, string str1) { try { if (!string.IsNullOrEmpty(str)) { Ht_Limit ht_Limits = JsonConvert.DeserializeObject <Ht_Limit>(str); List <Ht_LimitDetails> ht_LimitDetailslist = JsonConvert.DeserializeObject <List <Ht_LimitDetails> >(str1); foreach (var i in ht_LimitDetailslist) { i.CT = DateTime.Now; i.CU = Common.Common.UserID; i.LU = Common.Common.UserID; i.LT = DateTime.Now; i.ST = 1; } ht_Limits.Ht_LimitDetails = ht_LimitDetailslist; ht_admin_userrole userrole = dal.RoleALL().Where(x => x.ID == ht_Limits.RoleID).FirstOrDefault(); ht_Limits.RoleName = userrole.role_name; ht_Limits.CT = DateTime.Now; ht_Limits.CU = Common.Common.UserID; ht_Limits.LU = Common.Common.UserID; ht_Limits.LT = DateTime.Now; ht_Limits.ST = 1; List <Ht_Menu> ht_Menulist = dal.MenuALL(); if (dal.LimitSave(ht_Limits, ht_LimitDetailslist, ht_Menulist, LogBLL.controllog("add", "权限保存_LimitSave", str))) { return(true); } else { return(false); } } else { return(false); } } catch (Exception ex) { LogBLL.errorControlLog("add", "权限保存_LimitSave", str, ex.ToString()); return(false); } }
/// <summary> /// 更新 /// </summary> /// <param name="str"></param> /// <returns></returns> public static bool LimitUpdate(string[] str) { try { if (!string.IsNullOrEmpty(str[0])) { Ht_Limit ht_Limit = JsonConvert.DeserializeObject <Ht_Limit>(str[0]); Ht_Limit ht_Limit1 = dal.SelectEntities(x => x.ST >= 0).ToList().Where(x => x.ID == ht_Limit.ID).FirstOrDefault(); ht_Limit1.Common = ht_Limit.Common; ht_Limit1.LT = DateTime.Now; ht_Limit1.LU = Common.Common.UserID; List <Ht_LimitDetails> newlist = JsonConvert.DeserializeObject <List <Ht_LimitDetails> >(str[1]); List <Ht_LimitDetails> oldlist = dal.DetailsUpdate(x => x.LimitID == ht_Limit.ID); List <Ht_LimitDetails> addlist = new List <Ht_LimitDetails>(); List <Ht_LimitDetails> deletelist = new List <Ht_LimitDetails>(); List <Ht_LimitDetails> updatelist = new List <Ht_LimitDetails>(); foreach (var i in oldlist) { if (newlist.Where(x => x.MenuID == i.MenuID).Count() > 0) { if (newlist.Where(x => x.MenuID == i.MenuID && x.funAdd == i.funAdd && x.funDelete == i.funDelete && x.funSelect == i.funSelect && x.funUpdate == i.funUpdate).Count() > 0) { newlist.Remove(newlist.Where(x => x.MenuID == i.MenuID).FirstOrDefault()); } else { var q = newlist.Where(x => x.MenuID == i.MenuID).FirstOrDefault(); i.funAdd = q.funAdd; i.funDelete = q.funDelete; i.funSelect = q.funSelect; i.funUpdate = q.funUpdate; i.LT = DateTime.Now; i.LU = Common.Common.UserID; updatelist.Add(i); newlist.Remove(newlist.Where(x => x.MenuID == i.MenuID).FirstOrDefault()); } } else { deletelist.Add(i); } } addlist = newlist; foreach (var i in addlist) { i.CT = DateTime.Now; i.CU = Common.Common.UserID; i.LT = DateTime.Now; i.LU = Common.Common.UserID; i.ST = 1; i.LimitID = ht_Limit.ID; } dal.UpdateList(ht_Limit1, addlist, deletelist, updatelist, LogBLL.controllog("modify", "权限更新_LimitUpdate", JsonConvert.SerializeObject(str))); return(true); } else { return(false); } } catch (Exception ex) { LogBLL.errorControlLog("modify", "权限更新_LimitUpdate", JsonConvert.SerializeObject(str), ex.ToString()); throw ex; } }