protected void btnAdd_Click(object sender, EventArgs e) { var bll = new RoleManagerBLL(); var role = GetRole(PageUtility.User, bll); if (role == null) { return; } try { if (hdnRoleNo.Value == string.Empty) { bll.AddRole(role); } else { bll.ModifyRole(role); } } catch (Exception ex) { lblError.Text = ex.Message; return; } Response.Redirect("RoleManager.aspx"); }
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 void bindRoleList(RoleManagerBLL bll, int pageIndex, int pageSize) { int total; GridView1.DataSource = bll.GetRoleList(pageIndex, pageSize, out total); GridView1.DataBind(); Navigation1.DataBind(pageIndex, pageSize, total); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { var bll = new RoleManagerBLL(); bindRoleList(bll, PageUtility.NAVIGATION_DEFAULT_PAGEINDEX, PageUtility.NAVIGATION_DEFAULT_PAGESIZE); } }
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); }
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) { var bll = new RoleManagerBLL(); var roleID = int.Parse(e.CommandArgument.ToString()); switch (e.CommandName) { case "Remove": bll.RemoveRole(roleID); bindRoleList(bll, PageUtility.NAVIGATION_DEFAULT_PAGEINDEX, PageUtility.NAVIGATION_DEFAULT_PAGESIZE); break; case "Popedom": Response.Redirect("RolePopedomManager.aspx?id=" + roleID); break; } }