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, "用户已经存在!"); } }
protected void btnSave_Click(object sender, EventArgs e) { if (txtName.Text.Trim() == "") { AlertDiv.InnerHtml = MojoCube.Web.String.ShowAlert("danger", "请填写用户名"); return; } MojoCube.Web.Member.List list = new MojoCube.Web.Member.List(); //修改 if (ViewState["pk_Member"] != null) { MojoCube.Api.File.Upload upload = new MojoCube.Api.File.Upload(); upload.FilePath = "Member/" + ViewState["pk_Member"].ToString(); upload.FileName = MojoCube.Api.Text.Function.DateTimeString(true); upload.DoFileUpload(fuPortrait); list.GetData(int.Parse(ViewState["pk_Member"].ToString())); if (cbResetPsw.Checked) { list.UserPass = FormsAuthentication.HashPasswordForStoringInConfigFile("123456", "MD5").ToLower(); } list.UserName = txtName.Text.Trim(); list.FirstName = txtFirstName.Text.Trim(); list.LastName = txtLastName.Text.Trim(); list.Phone1 = txtPhone.Text.Trim(); list.Mobile = txtPhone.Text.Trim(); list.Email = txtEmail.Text.Trim(); list.Address = txtAddress.Text.Trim(); list.Birthday = txtBirthday.Text.Trim() + " 00:00:00"; list.Sex = int.Parse(ddlSex.SelectedValue); if (upload.IsUpload) { list.ImagePath = upload.OldFilePath; } list.UpdateData(list.pk_Member); } //新增 else { list.UserName = txtPhone.Text.Trim(); list.UserPass = FormsAuthentication.HashPasswordForStoringInConfigFile("123456", "MD5").ToLower(); list.NickName = string.Empty; list.FirstName = txtFirstName.Text.Trim(); list.LastName = txtLastName.Text.Trim(); list.Sex = int.Parse(ddlSex.SelectedValue); 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 = true; 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 = txtBirthday.Text.Trim() + " 00:00:00"; list.InsertData(); } Response.Redirect("List.aspx?active=" + Request.QueryString["active"]); }