Exemplo n.º 1
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (!PageValidate.IsDateTime(txtBirthday.Text))
            {
                strErr += "生日格式错误!\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            String Name     = this.txtName.Text;
            String Password = this.txtPassword.Text;
            String TrueName = this.txtTrueName.Text;
            String Sex      = this.ddlSex.SelectedValue;
            String Phone    = this.txtPhone.Text;
            //上传图片
            string path        = Server.MapPath("~/");
            string Photo       = "";
            string filename    = "";
            string contentType = fuPhoto.PostedFile.ContentType;

            if (contentType == "image/pjpeg" || contentType == "image/bmp" || contentType == "image/gif")
            {
                string format = fuPhoto.FileName.Split('.')[1];
                Photo    = "Upload/" + Guid.NewGuid() + "." + format;
                filename = path + Photo;
                fuPhoto.PostedFile.SaveAs(filename);
            }
            else
            {
                Maticsoft.Common.MessageBox.Show(this, "请上传图片文件!");
                return;
            }
            //结束上传图片
            String   Email       = this.txtEmail.Text;
            DateTime Birthday    = DateTime.Parse(this.txtBirthday.Text);
            bool     IsActivity  = this.chkIsActivity.Checked;
            int      Fk_Roles_Id = int.Parse(this.ddlFk_Roles_Id.SelectedValue);

            Maticsoft.Model.Users model = new Maticsoft.Model.Users();
            model.Name        = Name;
            model.Password    = Password;
            model.TrueName    = TrueName;
            model.Sex         = Sex;
            model.Phone       = Phone;
            model.Photo       = Photo;
            model.Email       = Email;
            model.Birthday    = Birthday;
            model.IsActivity  = IsActivity;
            model.Fk_Roles_Id = Fk_Roles_Id;

            Maticsoft.BLL.Users bll = new Maticsoft.BLL.Users();
            try
            {
                bll.Add(model);
                Maticsoft.Common.MessageBox.ShowAndRedirect(this, "注册成功!", "List.aspx");
            }
            catch
            {
                Maticsoft.Common.MessageBox.ShowAndRedirect(this, "已存在该用户!", "Add.aspx");
            }
        }
Exemplo n.º 2
0
        protected void btnlogin_Click(object sender, EventArgs e)
        {
            string email      = @"^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$";
            Regex  rxemail    = new Regex(email);
            string phone      = "^((13[0-9])|(14[5,7])|(15[0-3,5-9])|(17[0,3,5-8])|(18[0-9])|166|198|199|(147))\\d{8}$";
            Regex  rxphone    = new Regex(phone);
            string username   = @"^\w+$";
            Regex  rxusername = new Regex(username);
            string name       = "^[a-zA-Z0-9\u4e00-\u9fa5]{1,}$";//字母数字汉字
            Regex  rxname     = new Regex(name);

            lblUserName.Text  = "";
            lblPassword.Text  = "";
            lblPassword2.Text = "";
            lblEmail.Text     = "";
            lblcode.Text      = "";
            if (txtUserName.Text == "")
            {
                lblUserName.Text = "账户不能为空!";
                return;
            }
            if (!rxname.IsMatch(txtUserName.Text))
            {
                lblPassword.Text = "不能输入特殊字符!";
                return;
            }
            if (txtPassword.Text == "")
            {
                lblPassword.Text = "密码不能为空!";
                return;
            }
            if (txtPassword2.Text == "")
            {
                lblPassword2.Text = "确认密码不能为空!";
                return;
            }
            if (txtphone.Text == "")
            {
                lblphone.Text = "手机号不能为空!";
                return;
            }
            if (txtEmail.Text == "")
            {
                lblEmail.Text = "邮箱不能为空!";
                return;
            }
            if (txtcode.Text == "")
            {
                lblcode.Text = "验证码不能为空!";
                return;
            }
            if (!rxusername.IsMatch(txtUserName.Text))
            {
                lblUserName.Text = "格式错误!";
                return;
            }
            if (!rxusername.IsMatch(txtPassword.Text))
            {
                lblPassword.Text = "格式错误!";
                return;
            }
            if (!rxusername.IsMatch(txtcode.Text))
            {
                lblUserName.Text = "格式错误!";
                return;
            }
            if (!rxusername.IsMatch(txtPassword2.Text))
            {
                lblUserName.Text = "格式错误!";
                return;
            }
            if (Users_Bll.GetList(" Username ='******' ").Tables[0].Rows.Count != 0)
            {
                lblUserName.Text = "用户名已存在!";
                return;
            }

            if (txtPassword.Text != txtPassword2.Text)
            {
                lblPassword2.Text = "两次密码输入不一致!";
                return;
            }

            if (!rxphone.IsMatch(txtphone.Text))
            {
                txtphone.Text = "";
                lblphone.Text = "手机格式错误!";
                return;
            }

            if (!rxemail.IsMatch(txtEmail.Text))
            {
                txtEmail.Text = "";
                lblEmail.Text = "邮箱输入错误!";
                return;
            }
            if (Session["CheckCode"].ToString().ToLower() != txtcode.Text.ToLower())
            {
                txtcode.Text = "";
                lblcode.Text = "验证码错误!";
                return;
            }
            if (txtUserName.Text.Count() < 6)
            {
                lblUserName.Text = "账户不能小于6位!";
                return;
            }

            Users_Mol.UserID       = DateTime.Now.ToString("yyyyMMddHHmmss");
            Users_Mol.Username     = txtUserName.Text;
            Users_Mol.UserPassword = txtPassword.Text;
            Users_Mol.Phone        = txtphone.Text;
            Users_Mol.UserEmail    = txtEmail.Text;
            Users_Mol.RegistTime   = DateTime.Now;
            Users_Mol.UserScore    = 0;
            Users_Mol.UserGrade    = "会员";
            Users_Mol.UserIdentity = "会员";
            if (CheckBox1.Checked == true)
            {
                Users_Bll.Add(Users_Mol);
                Response.Write("<script>alert('注册成功!');window.location.href='/Login.aspx'</script>");
            }
            else
            {
                CheckBox1.Checked = false;
                Response.Write("<script>alert('请同意条款!')</script>");
            }
        }
Exemplo n.º 3
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (this.txtUserID.Text.Trim().Length == 0)
            {
                strErr += "UserID不能为空!\\n";
            }
            if (this.txtUsername.Text.Trim().Length == 0)
            {
                strErr += "Username不能为空!\\n";
            }
            if (this.txtUserPassword.Text.Trim().Length == 0)
            {
                strErr += "UserPassword不能为空!\\n";
            }
            if (this.txtUserRealName.Text.Trim().Length == 0)
            {
                strErr += "UserRealName不能为空!\\n";
            }
            if (this.txtUserSex.Text.Trim().Length == 0)
            {
                strErr += "UserSex不能为空!\\n";
            }
            if (this.txtUserEmail.Text.Trim().Length == 0)
            {
                strErr += "UserEmail不能为空!\\n";
            }
            if (this.txtUserGrade.Text.Trim().Length == 0)
            {
                strErr += "UserGrade不能为空!\\n";
            }
            if (!PageValidate.IsNumber(txtUserScore.Text))
            {
                strErr += "UserScore格式错误!\\n";
            }
            if (this.txtProvince.Text.Trim().Length == 0)
            {
                strErr += "Province不能为空!\\n";
            }
            if (this.txtCity.Text.Trim().Length == 0)
            {
                strErr += "City不能为空!\\n";
            }
            if (this.txtAddress1.Text.Trim().Length == 0)
            {
                strErr += "Address1不能为空!\\n";
            }
            if (this.txtUserIdentity.Text.Trim().Length == 0)
            {
                strErr += "UserIdentity不能为空!\\n";
            }
            if (!PageValidate.IsDateTime(txtRegistTime.Text))
            {
                strErr += "RegistTime格式错误!\\n";
            }
            if (this.txtPhone.Text.Trim().Length == 0)
            {
                strErr += "Phone不能为空!\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            string   UserID       = this.txtUserID.Text;
            string   Username     = this.txtUsername.Text;
            string   UserPassword = this.txtUserPassword.Text;
            string   UserRealName = this.txtUserRealName.Text;
            string   UserSex      = this.txtUserSex.Text;
            string   UserEmail    = this.txtUserEmail.Text;
            string   UserGrade    = this.txtUserGrade.Text;
            int      UserScore    = int.Parse(this.txtUserScore.Text);
            string   Province     = this.txtProvince.Text;
            string   City         = this.txtCity.Text;
            string   Address1     = this.txtAddress1.Text;
            string   UserIdentity = this.txtUserIdentity.Text;
            DateTime RegistTime   = DateTime.Parse(this.txtRegistTime.Text);
            string   Phone        = this.txtPhone.Text;

            Maticsoft.Model.Users model = new Maticsoft.Model.Users();
            model.UserID       = UserID;
            model.Username     = Username;
            model.UserPassword = UserPassword;
            model.UserRealName = UserRealName;
            model.UserSex      = UserSex;
            model.UserEmail    = UserEmail;
            model.UserGrade    = UserGrade;
            model.UserScore    = UserScore;
            model.Province     = Province;
            model.City         = City;
            model.Address1     = Address1;
            model.UserIdentity = UserIdentity;
            model.RegistTime   = RegistTime;
            model.Phone        = Phone;

            Maticsoft.BLL.Users bll = new Maticsoft.BLL.Users();
            bll.Add(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "add.aspx");
        }