protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { var BLL = new RoleManagerBLL(); // 检查mid是否存在参数 RoleInfo selectedRole = null; if (!string.IsNullOrEmpty(Request["id"])) { var selectedRoleID = int.Parse(Request["id"]); selectedRole = BLL.GetRole(selectedRoleID); // 未找到模块对象 if (selectedRole == null) { Response.Redirect("~/common/erroraccess.aspx"); return; } } // 显示要修改的模块内容 DisplayRole(PageUtility.User, selectedRole); } }
private RoleInfo GetRole(UserInfo loginedUser, RoleManagerBLL BLL) { // 检查用户的输入情况 if (string.IsNullOrEmpty(txtName.Text.Trim())) { lblError.Text = "请输入角色名称!"; return(null); } if (string.IsNullOrEmpty(txtOrder.Text.Trim()) || !ValidationUtility.IsNumric(txtOrder.Text.Trim())) { lblError.Text = "请输入正确格式的排序数值!"; return(null); } var ret = new RoleInfo { ID = 0, PopedomIDs = string.Empty, CreatedByID = loginedUser.ID, CreatedByName = loginedUser.Alias, CreatedDate = DateTime.Now }; // 如果是修改,则获取要修改的对象 if (!string.IsNullOrEmpty(hdnRoleNo.Value.Trim())) { var existRole = BLL.GetRole(int.Parse(hdnRoleNo.Value.Trim())); if (existRole == null) { lblError.Text = "修改的对象未找到!请确认该对象是否被其它用户删除!"; return(null); } ret = existRole; } ret.RoleName = txtName.Text.Trim(); ret.HeadImage = string.Empty; ret.Description = txtDesc.Text.Trim(); ret.DisplayOrder = int.Parse(txtOrder.Text.Trim()); ret.LastUpdByID = loginedUser.ID; ret.LastUpdByName = loginedUser.Alias; ret.LastUpdDate = DateTime.Now; return(ret); }