コード例 #1
0
 private void btAdminConfirm_Click(object sender, EventArgs e)
 {
     if (tbAdminID.Text.Trim() == "" || tbAdminName.Text.Trim() == "" || tbAdminPassword.Text.Trim() == "" || tbAdminConfirmPasswd.Text == "")
     {
         MessageBox.Show("输入信息不完整!", "添加失败", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
         flag = 1;
     }
     if (flag == 0)
     {
         Maticsoft.BLL.Admin adm        = new BLL.Admin();
         Model.Admin         adminmodel = new Model.Admin();
         string str1 = string.Format("userID = '{0}'", tbAdminID.Text.Trim());
         if (adm.GetRecordCount(str1) > 0)
         {
             MessageBox.Show("当前用户名已存在!", "添加失败", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
         }
         else
         {
             if (tbAdminPassword.Text.Trim().ToString().Length >= 6 && tbAdminPassword.Text.Trim().ToString().Length <= 10)
             {
                 if (tbAdminPassword.Text.Trim() == tbAdminConfirmPasswd.Text.Trim())
                 {
                     adminmodel.userID   = tbAdminID.Text.Trim();
                     adminmodel.userName = tbAdminName.Text.Trim();
                     adminmodel.passwd   = tbAdminPassword.Text.Trim();
                     if (adm.Add(adminmodel) == true)
                     {
                         MessageBox.Show("添加成功!");
                         ((Main_Admin)this.Owner).dgvAdmin_Load();
                         this.Close();
                     }
                     else
                     {
                         MessageBox.Show("添加失败!");
                     }
                 }
                 else
                 {
                     MessageBox.Show("两次密码不对应!", "添加失败", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                 }
             }
             else
             {
                 MessageBox.Show("输入密码不合规范!", "添加失败", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
             }
         }
     }
 }
コード例 #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            User loggedInUser = (User)Session["currentUser"];

            if (loggedInUser != null)
            {
                if (BLL.Admin.RetrieveAdmin(loggedInUser) == null)
                {
                    if (loggedInUser.Username.Equals("Admin"))
                    {
                        BLL.Admin admin = new BLL.Admin();
                        admin.UserId = loggedInUser.Id;
                        admin.Add();
                        System.Diagnostics.Debug.WriteLine("Making admin");
                    }
                    else
                    {
                        System.Diagnostics.Debug.WriteLine("Not an admin");
                        Response.Redirect("/Redirect.aspx");
                    }
                }
            }
        }
コード例 #3
0
ファイル: AdminDo.aspx.cs プロジェクト: wayshan/tljs
        protected void BtnSubmit_Click(object sender, EventArgs e)
        {
            string username = txtUserName.Text.Trim();
            var    model    = bllAdmin.GetModel(p => p.UserName.Equals(username));

            if (model != null)
            {
                PageFunc.AjaxAlert(this.Page, "用户名已存在!");
                return;
            }


            modelAdmin.UserName  = username;
            modelAdmin.UserPwd   = PageFunc.Encrypt(txtPwd.Text, 1);
            modelAdmin.AddTime   = DateTime.Now;
            modelAdmin.Enabled   = chbIsEnabled.Checked;
            modelAdmin.UserType  = ddlUserType.SelectedValue;
            modelAdmin.Remark    = txtRemark.Text.Trim();
            modelAdmin.TbAccount = ddlAccount.SelectedValue;

            bllAdmin.Add(modelAdmin);
            Response.Write(PageFunc.ShowMsgJumpE("添加成功!", "AdminList.aspx"));
        }