Пример #1
0
        protected void Add_Click(object sender, EventArgs e)
        {
            if (this.TxtName.Text.Trim().Length == 0)
            {
                Response.Write("<script lanuage=javascript>alert('用户名不能为空!')</script>");
                return;
            }
            UsersBLL usersbll = new UsersBLL();
            bool     jiance   = usersbll.Detect(this.TxtName.Text);

            if (jiance)
            {
                Response.Write("<script>alert('对不起,用户名已存在');history.back();</script>");
                return;
            }
            Users a = new Users();

            a.UserName  = this.TxtName.Text;
            a.Password  = CJ_DBOperater.CJ.PwdSecurity(this.TxtPassword.Text.Trim());
            a.QuePwd    = question.Text.Trim();
            a.AnsPwd    = answer.Text.Trim();
            a.Role      = this.DropDownList1.SelectedItem.Text;
            a.Telephone = this.TxtPhone.Text;
            if (this.RadioButton_Male.Checked == true)
            {
                a.UserSex = "男";
            }
            else if (this.RadioButton_Female.Checked == true)
            {
                a.UserSex = "女";
            }
            a.Address = this.TxtAddress.Text;
            a.Email   = this.TxtEmail.Text;
            if (mark.Text.Trim().Length == 0)
            {
                a.UserMark = 0;
            }
            else
            {
                a.UserMark = Convert.ToInt32(mark.Text);
            }
            a.LoginTime  = Convert.ToDateTime(DateTime.Now.ToString());
            a.CreateTime = Convert.ToDateTime(DateTime.Now.ToString());
            if (usersbll.Add(a))
            {
                Response.Write("<script>alert('添加成功');window.location.href='UsersMgr.aspx';</script>");
            }
            else
            {
                Response.Write("<script>alert('添加失败');history.back();</script>");
            }
        }
Пример #2
0
        //用户名检测
        protected void Detect_Click(object sender, EventArgs e)
        {
            if (this.UserLoginName.Text.Trim().Length == 0)
            {
                Response.Write("<script lanuage=javascript>alert('用户名不能为空!')</script>");
                return;
            }
            UsersBLL usersbll = new UsersBLL();
            bool     a        = usersbll.Detect(this.UserLoginName.Text);

            if (a)
            {
                lblmessage.Text = "对不起,用户名已存在";
            }

            else
            {
                lblmessage.Text = "恭喜您!用户名可用";
            }
        }
Пример #3
0
        //注册
        protected void Btn_Login_Click(object sender, EventArgs e)
        {
            if (UserLoginName.Text.Trim().Length == 0)
            {
                Response.Write("<script lanuage=javascript>alert('用户名不能为空!')</script>");
                return;
            }
            if (identify.Text.ToString().ToLower() != Session["check"].ToString().ToLower())
            {
                Response.Write("<script lanuage=javascript>alert('您输入的验证码有误,请重新输入!')</script>");
                identify.Text = "";
                return;
            }
            if (Password.Text.Trim().Length == 0 || AffrimPassword.Text.Trim().Length == 0)
            {
                Response.Write("<script lanuage=javascript>alert('密码和确认密码均不能为空!')</script>");
                return;
            }
            if (txtQuePwd.Text.Trim().Length == 0 || txtAnsPwd.Text.Trim().Length == 0)
            {
                Response.Write("<script lanuage=javascript>alert('密码问题和密码答案均不能为空!')</script>");
                return;
            }
            if (EmailAddress.Text.Trim().Length == 0)
            {
                Response.Write("<script lanuage=javascript>alert('邮箱不能为空!')</script>");
                return;
            }
            UsersBLL usersbll = new UsersBLL();
            bool     panduan  = usersbll.Detect(this.UserLoginName.Text.Trim());

            if (panduan)
            {
                Response.Write("<script lanuage=javascript>alert('你的用户名已被占用!');</script>");
                return;
            }
            Users a = new Users();

            a.UserName  = this.UserLoginName.Text.Trim();
            a.Password  = CJ_DBOperater.CJ.PwdSecurity(this.Password.Text.Trim());
            a.Role      = "会员";//注册为一般用户
            a.Telephone = this.TelephoneNum.Text.Trim();
            if (this.RadioButton_Male.Checked == true)
            {
                a.UserSex = "男";
            }
            else if (this.RadioButton_Female.Checked == true)
            {
                a.UserSex = "女";
            }
            a.Address  = this.Address.Text.Trim();
            a.Email    = this.EmailAddress.Text.Trim();
            a.UserMark = 0;
            a.QuePwd   = this.txtQuePwd.Text.Trim();
            a.AnsPwd   = this.txtAnsPwd.Text.Trim();


            a.LoginTime  = DateTime.Now;
            a.CreateTime = DateTime.Now;
            if (usersbll.Add(a))
            {
                Response.Write("<script lanuage=javascript>alert('注册用户成功,现在转向登录界面!')</script>");
                Response.Write(" <script lanuage=javascript> location.href= './login.aspx' </script> ");
            }
            else
            {
                Response.Write("<script lanuage=javascript>alert('注册用户时出现错误,请重新注册!')</script>");
                Response.Write(" <script lanuage=javascript> location.href= './register.aspx' </script> ");
            }
        }