コード例 #1
0
        private void btnAddAdmin_Click(object sender, EventArgs e)
        {
            string name = this.txtAdminName.Text.Trim();

            if (string.IsNullOrEmpty(name))
            {
                MessageBox.Show("管理员姓名不能为空");
                return;
            }
            string pass  = this.txtPassword.Text.Trim();
            string pass2 = this.txtPassword2.Text.Trim();
            string level = this.cmbLevel.SelectedItem.ToString();

            if (pass != pass2)
            {
                MessageBox.Show("两次密码输入不一致");
                return;
            }
            adminmodel.Admin_Name     = name;
            adminmodel.Admin_Password = pass;
            adminmodel.Admin_Level    = level;

            bool b = admin.CheckAdminInfo(adminmodel);

            if (b == true)
            {
                MessageBox.Show("该管理员已存在");
                return;
            }
            admin.AddAdminInfo(adminmodel);
            BindAdmin();
        }
コード例 #2
0
        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>");
            }
        }