Exemple #1
0
    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, "密码错误!");
        }
    }
Exemple #2
0
    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"]);
    }