protected void btnSubmit_Click(object sender, EventArgs e) { if (txtPhone.Text == "" || txtName.Text == "" || txtEmail.Text == "" || txtPassword.Text.Trim() == "") { MojoCube.Api.UI.Script.ScriptMessage(this, "请填写完整"); return; } if (!RegexPhone(txtPhone.Text.Trim())) { MojoCube.Api.UI.Script.ScriptMessage(this, "请输入正确的手机号"); return; } if (txtPassword1.Text.Trim() != "" && txtPassword1.Text.Trim().Length < 6) { MojoCube.Api.UI.Script.ScriptMessage(this, "请输入至少6位密码"); return; } if (txtPassword1.Text.Trim() != txtPassword2.Text.Trim()) { MojoCube.Api.UI.Script.ScriptMessage(this, "两次密码不一致"); return; } MojoCube.Web.Member.List list = new MojoCube.Web.Member.List(); list.GetData(int.Parse(Session["Member_UserID"].ToString())); if (list.ChkUserName(txtPhone.Text.Trim()) && list.Phone1 != txtPhone.Text.Trim()) { MojoCube.Api.UI.Script.ScriptMessage(this, "手机号已存在!"); return; } if (list.ChkUserEmail(txtEmail.Text.Trim()) && list.Email != txtEmail.Text.Trim()) { MojoCube.Api.UI.Script.ScriptMessage(this, "邮件已存在!"); return; } if (list.IsUser(txtPhone.Text.Trim(), FormsAuthentication.HashPasswordForStoringInConfigFile(txtPassword.Text.Trim(), "MD5").ToLower().Trim()) && !list.IsLock) { list.UserName = txtPhone.Text.Trim(); list.Address = txtAddress.Text.Trim(); list.FirstName = MojoCube.Web.String.GetChineseName(txtName.Text.Trim(), false); list.LastName = MojoCube.Web.String.GetChineseName(txtName.Text.Trim(), true); list.Phone1 = txtPhone.Text.Trim(); list.Email = txtEmail.Text.Trim(); if (txtPassword1.Text.Trim() != "") { list.UserPass = FormsAuthentication.HashPasswordForStoringInConfigFile(txtPassword1.Text.Trim(), "MD5").ToLower(); } MojoCube.Api.File.Upload upload = new MojoCube.Api.File.Upload(); upload.FilePath = "Member/" + list.pk_Member; upload.FileName = MojoCube.Api.Text.Function.DateTimeString(true); upload.DoFileUpload(fuPortrait); if (upload.IsUpload) { list.ImagePath = upload.OldFilePath; Session["Member_UserImagePath"] = list.ImagePath; imgPortrait.ImageUrl = "Files.aspx?image=" + MojoCube.Api.Text.Security.EncryptString(Session["Member_UserImagePath"].ToString()); } list.UpdateData(list.pk_Member); MojoCube.Api.UI.Script.ScriptMessage(this, "修改成功!"); } else { MojoCube.Api.UI.Script.ScriptMessage(this, "密码错误!"); } }
protected void btnSubmit_Click(object sender, EventArgs e) { if (txtPhone.Text == "" || txtName.Text == "" || txtEmail.Text == "" || txtPassword1.Text.Trim() == "") { MojoCube.Api.UI.Script.ScriptMessage(this, "请填写完整"); return; } if (!RegexPhone(txtPhone.Text.Trim())) { MojoCube.Api.UI.Script.ScriptMessage(this, "请输入正确的手机号"); return; } if (txtPassword1.Text.Trim().Length < 6) { MojoCube.Api.UI.Script.ScriptMessage(this, "请输入至少6位密码"); return; } if (txtPassword1.Text.Trim() != txtPassword2.Text.Trim()) { MojoCube.Api.UI.Script.ScriptMessage(this, "两次密码不一致"); return; } //判断是否存在用户名及验证码是否正确 if (Session["SiteCheckCode"] == null) { MojoCube.Api.UI.Script.ScriptMessage(this, "请填写验证码"); return; } if (Session["SiteCheckCode"] != null && Session["SiteCheckCode"].ToString().ToLower() != txtCode.Text.Trim().ToLower()) { MojoCube.Api.UI.Script.ScriptMessage(this, "验证码错误"); return; } MojoCube.Web.Member.List list = new MojoCube.Web.Member.List(); if (!list.ChkUserName(txtPhone.Text.Trim()) && !list.ChkUserEmail(txtEmail.Text.Trim())) { list.UserName = txtPhone.Text.Trim(); list.UserPass = FormsAuthentication.HashPasswordForStoringInConfigFile(txtPassword1.Text.Trim(), "MD5").ToLower(); list.NickName = string.Empty; list.FirstName = MojoCube.Web.String.GetChineseName(txtName.Text.Trim(), false); list.LastName = MojoCube.Web.String.GetChineseName(txtName.Text.Trim(), true); list.Sex = 0; list.Phone1 = txtPhone.Text.Trim(); list.Phone2 = string.Empty; list.Mobile = txtPhone.Text.Trim(); list.Fax = string.Empty; list.Country = string.Empty; list.CountryID = 0; list.Province = string.Empty; list.ProvinceID = 0; list.City = string.Empty; list.CityID = 0; list.Zip = string.Empty; list.Address = txtAddress.Text.Trim(); list.Powers = string.Empty; list.Remark = string.Empty; list.Email = txtEmail.Text.Trim(); list.IsLock = false; list.LastLogin = DateTime.Now.ToString(); list.LastLoginIP = string.Empty; list.LoginTimes = 0; list.ImagePath = string.Empty; list.CreateDate = DateTime.Now.ToString(); list.TypeID = 0; list.IsCheck = false; list.CheckDate = DateTime.Now.ToString(); list.CheckCode = Guid.NewGuid().ToString(); list.AboutMe = string.Empty; list.Clicks = 0; list.IsReceiveNews = false; list.IsPublic = false; list.IsLockBlog = false; list.Following = string.Empty; list.Followers = string.Empty; list.Question = string.Empty; list.Answer = string.Empty; list.Birthday = "1980-01-01 00:00:00"; int userID = list.InsertData(); SendMail(list.Email, list.CheckCode, list.FirstName, list.LastName, list.UserName); MojoCube.Web.Member.Message.Send("欢迎加入我们的会员!", "您好!这是一封系统消息,您不需要回复!祝您在我们的网站有个愉快的购物旅程!", 0, "admin", userID, list.UserName); btnSubmit.Enabled = false; btnReset.Enabled = false; MojoCube.Api.UI.Script.ScriptMessage(this, "恭喜您!您的账号已经创建成功,请到您的邮箱点击确认邮件完成注册!"); } else { MojoCube.Api.UI.Script.ScriptMessage(this, "用户已经存在!"); } }