public void Dg_GotFocus(object sender, EventArgs e) { DataGrid dg = sender as DataGrid; if (dg.Name == "Dg_Role") { if (SelectedRole != null) { var right = this.View.GetControl <RightList_Control>("RightList"); right.CanEdit = Constants.Login.CheckRight(RightEnum.ManageRole); right.Role = SelectedRole; } } else if (dg.Name == "Dg_User") { if (SelectedUser != null) { var role = new T_Role() { Code = SelectedUser.RoleCode, Name = SelectedUser.LoginName, RightValue = SelectedUser.RightValue }; var right = this.View.GetControl <RightList_Control>("RightList"); right.CanEdit = false; right.Role = role; } } }
public void Dg_SelectionChanged(object sender, SelectionChangedEventArgs e) { DataGrid dg = sender as DataGrid; if (dg.Name == "Dg_Role") { if (SelectedRole != null) { var right = this.View.GetControl <RightList_Control>("RightList"); right.CanEdit = Constants.Login.CheckRight(RightEnum.ManageRole); right.Role = SelectedRole; } } else if (dg.Name == "Dg_User") { if (e.AddedItems.Count == 0) { return; } T_User t_User = e.AddedItems[0] as T_User; var role = new T_Role() { Code = t_User.RoleCode, Name = t_User.LoginName, RightValue = t_User.RightValue }; var right = this.View.GetControl <RightList_Control>("RightList"); right.CanEdit = false; right.Role = role; } }
public static T_Role AddT_Role(T_Role t_Role) { string sql = "INSERT T_Role (role_name, role_pris)" + "VALUES (@role_name, @role_pris)"; sql += " ; SELECT @@IDENTITY"; try { SqlParameter[] para = new SqlParameter[] { new SqlParameter("@role_name", DBHelper.GetValueByWhetherNull(t_Role.Role_name)), new SqlParameter("@role_pris", DBHelper.GetValueByWhetherNull(t_Role.Role_pris)) }; int newId = DBHelper.GetScalar(sql, para); return(GetT_RoleById(newId)); } catch (Exception e) { Console.WriteLine(e.Message); throw e; } }
/// <summary> /// 新增 /// </summary> /// <returns></returns> public ActionResult AddInfo(string Role_Code, string Role_Name) { using (LFAdminEntities hee = new LFAdminEntities()) { var ro = hee.T_Role.Where(o => o.Role_Code == Role_Code).FirstOrDefault(); if (ro == null) { T_Role tc = new T_Role(); tc.Role_Code = Role_Code; tc.Role_Name = Role_Name; hee.T_Role.Add(tc); hee.SaveChanges(); rd.IsSuccess = "1"; rd.MessageString = "信息新增成功!"; LoggerHelper.Info(Session["JGLoginAccountID"].ToString(), "RoleController-AddInfo", rd.MessageString); return(new JsonResult { Data = rd }); } else { rd.IsSuccess = "0"; rd.MessageString = "角色编码已存在!"; LoggerHelper.Info(Session["JGLoginAccountID"].ToString(), "RoleController-AddInfo", rd.MessageString); return(new JsonResult { Data = rd }); } } }
public ActionResult List() { int page = 1; if (!String.IsNullOrEmpty(Request["p"])) { page = Convert.ToInt32(Request["p"]); } String search_criteria = ""; if (!String.IsNullOrEmpty(Request.QueryString["s"])) { search_criteria = Request.QueryString["s"]; } int total; //Dictionary<T_RoleColumns, AscDesc> orderBy = new Dictionary<T_RoleColumns, AscDesc>(); //List<T_Role> entitys = entityDao.WebSearch(page, this.pageSize, search_criteria, orderBy, out total); T_Role entity = new T_Role(); List <T_Role> entitys = entityDao.Search(entity, page, this.pageSize, search_criteria, T_Role.Columns.id, AscDesc.ASC, out total); ViewBag.total = total; ViewBag.pageSize = this.pageSize; return(View("List", entitys)); }
public static void ModifyT_Role(T_Role t_Role) { string sql = "UPDATE T_Role " + "SET " + "role_name = @role_name, " + "role_pris = @role_pris " + "WHERE Id = @Id"; try { SqlParameter[] para = new SqlParameter[] { new SqlParameter("@Id", t_Role.Id), new SqlParameter("@role_name", DBHelper.GetValueByWhetherNull(t_Role.Role_name)), new SqlParameter("@role_pris", DBHelper.GetValueByWhetherNull(t_Role.Role_pris)) }; DBHelper.ExecuteCommand(sql, para); } catch (Exception e) { Console.WriteLine(e.Message); throw e; } }
/// <summary> /// 实现对用户角色的添加信息 /// </summary> /// <param name="role"></param> /// <returns></returns> public ActionResult AddUserRoleInfo(T_Role role) { T_User roleinfo = Session["T_User"] as T_User; //实现对用户的添加信息 var rolein = _roleService.LoadEntities(u => u.RoleID > 0); List <int> roleinf = new List <int>(); foreach (var i in rolein) { roleinf.Add(i.RoleID); } int maxid = roleinf.Max(); role.RoleID = maxid + 1; role.CreateOperatorID = roleinfo.UserID; role.CreateOperatorName = roleinfo.UserName; role.CreateTime = System.DateTime.Now; role.ModiOperatorID = ""; role.ModiOperatorName = ""; role.ModiTime = System.DateTime.Now; if (_roleService.AddEntities(role) != null) { return(Content("OK")); } else { return(Content("fail")); } }
private void ResetState(T_Role role, DrisionDbContext context) { if (role.Role_Status == 1) { if (role.T_Users.Count > 0 || RoleFunctionManager.GetInstance().GetFunctions(role.Role_ID).Count > 0) { this.AjaxAlert("此角色已使用,不能停用!"); return; } role.Role_Status = 0; context.SaveChanges(); BingRoleToDataGridview(); this.AjaxAlert("停用角色成功!"); return; } else if (role.Role_Status == 0) { role.Role_Status = 1; context.SaveChanges(); BingRoleToDataGridview(); this.AjaxAlert("启用角色成功!"); return; } }
protected void gvShow_RowCommand(object sender, GridViewCommandEventArgs e) { T_Role role = null; using (DrisionDbContext context = new DrisionDbContext(GlobalObject.ConnString)) { int roleId = Convert.ToInt32(e.CommandArgument); role = context.T_Role.Where(x => x.Role_ID == roleId).FirstOrDefault(); if (e.CommandName == "state") { ResetState(role, context); } else if (e.CommandName == "up") { UpdateUser(role, context); } else if (e.CommandName == "del") { DeleteUser(role, context); } else if (e.CommandName == "set") { SetRight(role, context); } } }
public ActionResult DisableForm(string F_Id) { T_Role t_Role = roleBLL.GetForm(F_Id); t_Role.F_Enable_Mark = 0; roleBLL.SubmitForm(t_Role); return(Success("操作成功")); }
public int AddRole(T_Role role) { using (BizDataContext context = new BizDataContext(true)) { role.Role_ID = context.GetNextIdentity_Int(false); context.Insert(role); } return(role.Role_ID); }
public override void Create(FormCollection formInfo) { T_Role role = roleService.GetRoleInfo(formInfo); role.CreateDate = DateTime.Now; //ToTest //role.CreateUserID = Convert.ToInt32(Session["UserID"]); roleService.Create(role); }
public void InsertRole(T_Role role) { if (role == null) { throw new ArgumentNullException("role null"); } _roleRepository.Insert(role); }
public void UpdateRole(T_Role role) { if (role == null) { throw new ArgumentNullException("role null"); } _roleRepository.Update(role); }
private string GetRoleName(int?roleId) { T_Role role = this.DataHelper.FindById <T_Role>(roleId); if (role != null) { return(role.Role_Name); } return(string.Empty); }
public ActionResult Edit(int id) { T_Role role = dc.Set <T_Role>().AsNoTracking().Where(a => a.ID == id).FirstOrDefault(); if (role.ID == 1) { return(Content("<script>window.parent.layer.closeAll();window.parent.layer.msg('无法操作超级管理角色!')</script>")); } return(View(role)); }
/// <summary> /// 编辑角色实现 /// </summary> /// <param name="role"></param> /// <returns></returns> public bool EditRole(T_Role role, int id) { if (role == null || id <= 0) { return(false); } int modify = Modify(role, s => s.role_id == id, "role_name", "role_code", "role_note", "sm_code"); return(true); }
[ValidateInput(false)] //要加上这一句,否则会造成富文本里面的HTML代码危险警报 public JsonResult Update(T_Role entity) { if (entityDao.Update(entity) > 0) { return(Success("更新成功!", null)); } else { return(Fail("更新失败!")); } }
private void UpdateUser(T_Role role, DrisionDbContext context) { txtName.Text = role.Role_Name; rbtnState.SelectedValue = role.Role_Status.ToString(); txtRemark.Text = role.Role_Comment; lblEdit.Text = role.Role_ID.ToString(); btnAdd.Visible = false; btnEdit.Visible = true; Panel1.Visible = true; }
[ValidateInput(false)] //要加上这一句,否则会造成富文本里面的HTML代码危险警报 public JsonResult Add(T_Role entity) { if (entityDao.Add(entity) > 0) { return(Success("新增成功!", null)); } else { return(Fail("新增失败!")); } }
public JsonResult Add(T_Role model) { bool Success = false; string Message = "添加失败请联系管理员!"; if (iRole.Add(model) > 0) { Success = true; Message = "成功"; } return(Json(new { Success = Success, Message = Message }, JsonRequestBehavior.AllowGet)); }
public List <T_Role> GetPage(T_Role role1, int num1, int num2, string text1, string text2, ref int numRef1) { InvokeContext context = new InvokeContext(); context.SetMethod("GetPage"); context.SetClassName("Complex.Logical.Admin.Realization.RROLE"); context.ResultType = typeof(List <T_Role>); List <T_Role> result = null; Exception e = null; context.SetParameter(role1); context.SetParameter(num1); context.SetParameter(num2); context.SetParameter(text1); context.SetParameter(text2); context.SetParameter(numRef1); Type[] types = new Type[] { typeof(T_Role), typeof(int), typeof(int), typeof(string), typeof(string), typeof(int).MakeByRefType() }; MethodInfo method = this._realProxy.GetType().GetMethod("GetPage", types); PreAspectAttribute customAttribute = (PreAspectAttribute)Attribute.GetCustomAttribute(method, typeof(PreAspectAttribute)); if (customAttribute != null) { context = customAttribute.Action(context); } if (!context.IsRun) { return(null); } try { result = this._realProxy.GetPage((T_Role)context.Parameters[0], (int)context.Parameters[1], (int)context.Parameters[2], (string)context.Parameters[3], (string)context.Parameters[4], out numRef1); context.SetResult(result); PostAspectAttribute attribute2 = (PostAspectAttribute)Attribute.GetCustomAttribute(method, typeof(PostAspectAttribute)); if (attribute2 != null) { context = attribute2.Action(context); result = (List <T_Role>)context.Result; } } catch (Exception exception1) { e = exception1; context.SetError(e); ExceptionAspectAttribute attribute3 = (ExceptionAspectAttribute)Attribute.GetCustomAttribute(method, typeof(ExceptionAspectAttribute)); if (attribute3 == null) { throw e; } return((List <T_Role>)attribute3.Action(context).Result); } return(result); }
public ActionResult SetRole(T_Role role) { int count; if (role.Id <= 0) { count = roleService.Add(role); } else { count = roleService.Modify(role); } return(JsonSuccess(role)); }
/// <summary> /// 添加角色实现 /// </summary> /// <param name="role"></param> /// <returns></returns> public bool AddRole(T_Role role) { if (null == role) { return(false); } int add = Add(role); if (add > 0) { return(true); } return(false); }
private static IList <T_Role> GetRoleList(BizDataContext ctx, int userId) { List <T_Role> list = new List <T_Role>(); List <int> list2 = (from t in ctx.Where <T_User_Role>(t => t.User_Id == userId) select t.Role_Id).ToList <int>(); foreach (int num in list2) { T_Role item = new T_Role { Role_ID = num }; list.Add(item); } return(list); }
public ActionResult Edit() { T_Role entity = new T_Role(); Int32 id = Convert.ToInt32("-1"); if (!String.IsNullOrWhiteSpace(Request.QueryString["id"])) { id = Convert.ToInt32(Request.QueryString["id"]); } entity = entityDao.GetById(id); return(View("Edit", entity)); }
public ActionResult Show() { T_Role entity = new T_Role(); try { if (!String.IsNullOrEmpty(Request.QueryString["id"])) { entity = entityDao.GetById(Convert.ToInt32(Request.QueryString["id"])); } } catch (Exception ex) { } return(View("Show", entity)); }
public ActionResult GetRoleData(T_Role role) { string role_name = Helper.ToString(Request["role_name"]), sm_code = RequestHelper.GetStrByName("sm_code"); int page = Helper.ToInt(Request["page"]); int rows = Helper.ToInt(Request["rows"]); role_name = (!string.IsNullOrEmpty(role_name)) ? HttpUtility.UrlDecode(role_name) : role_name; List<T_Role> list = operateContext.bllSession.T_Role.GetRoleData(role_name, page, rows, sm_code); TableModel tModel = new TableModel() { total = operateContext.bllSession.T_Role.SelectCount(s => s.role_name.Contains(role_name)), rows = list }; return Json(tModel, JsonRequestBehavior.AllowGet); }
public ActionResult EditRoleByObj(T_Role role,int id) { if (!ModelState.IsValid) return operateContext.RedirectAjax(1, "数据验证失败~", "", ""); try { //清理角色缓存 SessionHelper.RemoveSession(CacheConstant.loginUserCacheRoles); if(operateContext.bllSession.T_Role.EditRole(role,id)) return operateContext.RedirectAjax(0, "数据更新成功~", "", ""); return operateContext.RedirectAjax(1, "数据更新失败~", "", ""); } catch (Exception ex){ return operateContext.RedirectAjax(0, ex.Message, "", ""); } }
public ActionResult AddRoleByObj(T_Role role) { if (!ModelState.IsValid || null == role) return operateContext.RedirectAjax(1, "数据验证失败~", "", ""); try{ role.creator_date = DateTime.Now; role.creator_id = operateContext.Usr.user_id; if (operateContext.bllSession.T_Role.AddRole(role)) return operateContext.RedirectAjax(0, "数据更新成功~", "", ""); return operateContext.RedirectAjax(1, "数据更新失败~", "", ""); } catch (Exception ex){ return operateContext.RedirectAjax(0, ex.Message, "", ""); } }