protected void btnSave_Click(object sender, ImageClickEventArgs e) { if (hid_RoleID.Value == "") { Sys_Role model = GetBaseInfo(); model.RoleID = Guid.NewGuid().ToString(); if (bllRole.Add(model, SaveRole(model.RoleID))) { MessageBox.ShowAndRedirect(this, "添加成功", "RoleList.aspx"); } else { MessageBox.ShowAndRedirect(this, "添加成功", "RoleList.aspx"); } } else { Sys_Role model = GetBaseInfo(); if (bllRole.Update(model, SaveRole(model.RoleID))) { MessageBox.ShowAndRedirect(this, "修改成功", "RoleList.aspx"); } else { MessageBox.ShowAndRedirect(this, "修改成功", "RoleList.aspx"); } } }
public ActionResult SubmitForm(Sys_RoleModel roleEntity, string keyValue) { if (!string.IsNullOrEmpty(keyValue)) { roleEntity.F_Id = keyValue; var LoginInfo = OperatorProvider.Provider.GetCurrent(); if (LoginInfo != null) { roleEntity.F_LastModifyUserId = LoginInfo.UserId; } roleEntity.F_LastModifyTime = DateTime.Now; rbll.Update(roleEntity); } else { roleEntity.F_Id = Common.GuId(); var LoginInfo = OperatorProvider.Provider.GetCurrent(); if (LoginInfo != null) { roleEntity.F_CreatorUserId = LoginInfo.UserId; } roleEntity.F_CreatorTime = DateTime.Now; roleEntity.F_Category = 2; rbll.Add(roleEntity); } return(Success("操作成功。")); }
public JsonResult Create(sys_role model) { ExecuteResult Er = new ExecuteResult(); if (string.IsNullOrEmpty(model.KeyId)) { int count = bll.GetList <sys_role>(item => item.FullName == model.FullName && item.IsDeleted == false).Count(); if (count > 0) { Er.Result = false; Er.Message = "已存在相同角色命名"; } else { #region 新增 model.KeyId = Guid.NewGuid().ToString(); model.CreateDate = DateTime.Now; model.IsDeleted = false; Er.Result = bll.Insert <sys_role>(model) > 0; Er.Message = Er.Result ? "新增成功" : "新增失败"; #endregion } } else { int count = bll.GetList <sys_role>(item => item.FullName == model.FullName && item.KeyId != model.KeyId && item.IsDeleted == false).Count(); if (count > 0) { Er.Result = false; Er.Message = "已存在相同角色命名"; } else { #region 修改 var old = bll.GetModelById <sys_role>(model.KeyId); old.FullName = model.FullName; old.Description = model.Description; Er.Result = bll.Update <sys_role>(old) > 0; Er.Message = Er.Result ? "编辑成功" : "编辑失败"; #endregion } } return(Json(Er)); }
public ActionResult SubmitForm(Sys_RoleModel roleEntity, string permissionIds, string keyValue) { if (!string.IsNullOrEmpty(keyValue)) { roleEntity.F_Id = keyValue; rolebll.Update(roleEntity); } else { roleEntity.F_Id = Common.GuId(); roleEntity.F_Category = 1; rolebll.Add(roleEntity); } var moduledata = modulebll.GetModelList(""); var buttondata = moduleButtonbll.GetModelList(""); var authorizedata = new List <Sys_RoleAuthorizeModel>(); var perIds = permissionIds.Split(','); roleAuthorizebll.DeleteByObjectId(roleEntity.F_Id); foreach (var itemId in perIds) { Sys_RoleAuthorizeModel roleAuthorizeEntity = new Sys_RoleAuthorizeModel(); roleAuthorizeEntity.F_Id = Common.GuId(); roleAuthorizeEntity.F_ObjectType = 1; roleAuthorizeEntity.F_ObjectId = roleEntity.F_Id; roleAuthorizeEntity.F_ItemId = itemId; if (moduledata.Find(t => t.F_Id == itemId) != null) { roleAuthorizeEntity.F_ItemType = 1; } if (buttondata.Find(t => t.F_Id == itemId) != null) { roleAuthorizeEntity.F_ItemType = 2; } authorizedata.Add(roleAuthorizeEntity); roleAuthorizebll.Add(roleAuthorizeEntity); } return(Success("操作成功。")); }