protected void btAdd_Click(object sender, EventArgs e) { //管理员表与管理员角色表都需要更新 AdminInfo _AdminInfo = new AdminInfo(); AdminRole _AdminRole = new AdminRole(); AdminRoleBLL _AdminRoleBLL = new AdminRoleBLL(); RoleBLL _RoleBLL = new RoleBLL(); AdminInfoBLL _AdminInfoBLL = new AdminInfoBLL(); int Num = _AdminInfoBLL.AdminExist(this.txtAccount.Text.Trim()); if (Num > 0) { Response.Write("<script language='javascript'>"); Response.Write("alert('该账号已存在');"); Response.Write("</script>"); return; } _AdminInfo.AdminAccount = this.txtAccount.Text.Trim(); _AdminInfo.PassWord = this.txtPass.Text.Trim(); _AdminInfo.IsSYS = false; bool StepOne = _AdminInfoBLL.AddAdminInfo(_AdminInfo); _AdminRole.AdminID = _AdminInfoBLL.GetAdminID(txtAccount.Text.Trim()); _AdminRole.RoleID = int.Parse(this.DropDownRole.SelectedValue.ToString()); bool StepTwo = _AdminRoleBLL.AddAdminRole(_AdminRole); if (StepOne && StepTwo) { Response.Write("<script language='javascript'>"); Response.Write("alert('添加成功');"); Response.Write("document.location.href='AdminList.aspx';"); Response.Write("</script>"); } }
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>"); } } }