//管理员角色绑定 private void AdminRoleBind(int AdminID) { AdminInfoBLL _AdminInfoBLL = new AdminInfoBLL(); bool IsSys = _AdminInfoBLL.IsSys(AdminID); if (IsSys) { this.DropDownRole.Items.Clear(); ListItem item = new ListItem("系统管理员"); this.DropDownRole.Items.Add(item); this.DropDownRole.Enabled = false; } else { //与角色表中的数据绑定 RoleBLL _RoleBLL = new RoleBLL(); DataTable DT = _RoleBLL.GetAllRoleInfo(); DropDownRole.Items.Clear(); DropDownRole.DataSource = DT; DropDownRole.DataTextField = "RoleName"; DropDownRole.DataValueField = "RoleID"; DropDownRole.DataBind(); //获得当前编辑对象的管理角色个数 AdminRoleBLL _AdminRoleBLL = new AdminRoleBLL(); int AdminRoleCount = _AdminRoleBLL.GetCountByAdminID(AdminID); if (AdminRoleCount > 0) { int RoleID = _RoleBLL.GetRoleIDByAdminID(AdminID); DropDownRole.SelectedValue = RoleID.ToString(); } } }
protected void btAdd_Click(object sender, EventArgs e) { AdminInfoBLL _AdminInfoBLL = new AdminInfoBLL(); AdminInfo _AdminInfo = new AdminInfo(); _AdminInfo.AdminAccount = this.txtAccount.Text; _AdminInfo.PassWord = this.txtPass.Text; string _AdminID = Request.QueryString["AdminID"].ToString(); int AdminID = int.Parse(_AdminID); _AdminInfo.IsSYS = _AdminInfoBLL.IsSys(AdminID); if (_AdminInfo.IsSYS) { if (_AdminInfoBLL.UpdateAdminInfo(AdminID, _AdminInfo)) { Response.Write("<script language='javascript'>"); Response.Write("alert('更新成功');"); Response.Write("document.location.href='AdminList.aspx';"); Response.Write("</script>"); } } else { int RoleID = int.Parse(DropDownRole.SelectedValue.ToString()); AdminRoleBLL _AdminRoleBLL = new AdminRoleBLL(); bool StepOne = false; bool StepTwo = false; if (_AdminInfoBLL.UpdateAdminInfo(AdminID, _AdminInfo)) { StepOne = true; } int AdminRoleCount = _AdminRoleBLL.GetCountByAdminID(AdminID); if (AdminRoleCount > 0) { if (_AdminRoleBLL.UpdateAdminRole(AdminID, RoleID)) { StepTwo = true; } } else { AdminRole _AdminRole = new AdminRole(); _AdminRole.AdminID = AdminID; _AdminRole.RoleID = RoleID; if (_AdminRoleBLL.AddAdminRole(_AdminRole)) { StepTwo = true; } } if (StepOne && StepTwo) { Response.Write("<script language='javascript'>"); Response.Write("alert('更新成功');"); Response.Write("document.location.href='AdminList.aspx';"); Response.Write("</script>"); } } }
//根据管理员信息 管理员角色信息 protected void deleteThis() { try { Array delWitch = rqid.Split('|'); bool isTrue = false; for (int i = 0; i < delWitch.Length - 1; i++) { int delid = Convert.ToInt32(delWitch.GetValue(i)); AdminInfoBLL _AdminInfoBLL = new AdminInfoBLL(); AdminRoleBLL _AdminRoleBLL = new AdminRoleBLL(); int AdminRoleCount = _AdminRoleBLL.GetCountByAdminID(delid); if (AdminRoleCount > 0) { if (_AdminRoleBLL.DeleteAdminRole(delid)) { isTrue = true; } else { isTrue = false; } } if (_AdminInfoBLL.DeleteAdminInfo(delid)) { isTrue = true; } else { isTrue = false; } if (isTrue == false) { break; } } if (!(isTrue == false)) { Response.Write("<script language='javascript'>"); Response.Write("alert('删除成功!');"); Response.Write("document.location.href='AdminList.aspx';"); Response.Write("</script>"); } else { Response.Write("<script language='javascript'>"); Response.Write("alert('删除失败!');"); Response.Write("document.location.href='AdminList.aspx';"); Response.Write("</script>"); } } catch { Response.Write("<script language='javascript'>"); Response.Write("alert('删除失败!');"); Response.Write("document.location.href='AdminList.aspx';"); Response.Write("</script>"); } }