Exemplo n.º 1
0
 protected void lbtSavePass_Click(object sender, EventArgs e)
 {
     try
     {
         if (Page.IsValid)
         {
             if (!string.IsNullOrEmpty(cus.Password))
             {
                 if (!StringClass.Encode(txtOldPassword.Value.Trim()).Equals(cus.Password))
                 {
                     WebMsgBox.Show("Mật khẩu cũ không đúng");
                     txtOldPassword.Focus();
                     Response.Redirect("/thanh-vien/thong-tin-ca-nhan#doi-mat-khau", false);
                     return;
                 }
             }
             Regex reg = new Regex("(?!^[0-9]*$)(?!^[a-zA-Z]*$)^([a-zA-Z0-9]{6,15})$");
             if (!reg.IsMatch(txtNewPassword.Value.Trim()))
             {
                 WebMsgBox.Show("Mật khẩu chỉ bao gồm kí tự chữ và số");
                 txtNewPassword.Focus();
                 Response.Redirect("/thanh-vien/thong-tin-ca-nhan#doi-mat-khau", false);
                 return;
             }
             if (!txtNewPassword.Value.Trim().Equals(txtConfirmNewPassword.Value.Trim()))
             {
                 WebMsgBox.Show("Mật khẩu xác nhận không khớp");
                 txtConfirmNewPassword.Focus();
                 Response.Redirect("/thanh-vien/thong-tin-ca-nhan#doi-mat-khau", false);
                 return;
             }
             cus.Password = StringClass.Encode(txtNewPassword.Value.Trim());
             CustomersService.Customers_Update(cus);
             Session["Info"] = cus;
             WebMsgBox.Show("Cập nhật mật khẩu thành công.");
             Response.Redirect("/thanh-vien/thong-tin-ca-nhan#doi-mat-khau", false);
         }
     }
     catch (Exception ex)
     {
         MailSender.SendMail("", "", "Error System", ex.Message + "\n" + ex.StackTrace);
         WebMsgBox.Show("Cập nhật mật khẩu thất bại. Vui lòng thử lại.");
         Response.Redirect("/thanh-vien/thong-tin-ca-nhan#doi-mat-khau", false);
     }
 }
Exemplo n.º 2
0
 protected void lbtSave_Click(object sender, EventArgs e)
 {
     try
     {
         if (Page.IsValid)
         {
             cus.FullName = txtFullName.Value.Trim();
             cus.Phone    = txtPhone.Value.Trim();
             CustomersService.Customers_Update(cus);
             Session["Info"] = cus;
             WebMsgBox.Show("Cập nhật thông tin thành công.");
         }
     }
     catch (Exception ex)
     {
         WebMsgBox.Show("Cập nhật thông tin thất bại. Vui lòng thử lại sau.");
         MailSender.SendMail("", "", "Error System", ex.Message + "\n" + ex.StackTrace);
     }
 }
Exemplo n.º 3
0
        protected void lbtGetPass_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtEmail.Value.Trim() == string.Empty)
                {
                    WebMsgBox.Show("Vui lòng nhập Email của bạn!");
                    txtEmail.Focus();
                    return;
                }
                DataTable dt = CustomersService.Customers_GetByName(txtEmail.Value.Trim());
                if (dt == null || dt.Rows.Count == 0)
                {
                    WebMsgBox.Show("Email này không tồn tại trong hệ thống!");
                    txtEmail.Focus();
                    return;
                }

                Customers cus = new Customers();
                cus.Id          = dt.Rows[0]["Id"].ToString();
                cus.AppId       = dt.Rows[0]["AppId"].ToString();
                cus.UserName    = dt.Rows[0]["UserName"].ToString();
                cus.FullName    = dt.Rows[0]["FullName"].ToString();
                cus.Phone       = dt.Rows[0]["Phone"].ToString();
                cus.Email       = dt.Rows[0]["Email"].ToString();
                cus.Gender      = dt.Rows[0]["Gender"].ToString();
                cus.CreatedDate = DateTime.Parse(dt.Rows[0]["CreatedDate"].ToString()).ToString("MM/dd/yyyy HH:mm:ss");
                cus.Ord         = dt.Rows[0]["Ord"].ToString();
                cus.Active      = dt.Rows[0]["Active"].ToString();
                string newPass = StringClass.RandomString(8);
                cus.Password = StringClass.Encode(newPass);
                CustomersService.Customers_Update(cus);
                MailSender.SendMail(txtEmail.Value.Trim(), "", @"Reset mật khẩu", "Bạn nhận được email này do bạn hoặc một ai đó đã sử dụng địa chỉ email " + txtEmail.Value.Trim() +
                                    " để lấy lại mật khẩu tại filetranh.net.<br/> Mật khẩu mới của bạn là " + newPass +
                                    "<br/>Nếu bạn không tạo tài khoản trên filetranh.net, vui lòng bỏ qua nội dung của email này.");
                WebMsgBox.Show("Chúng tôi đã gửi mật khẩu mới vào email của bạn. Vui lòng check email của bạn.");
            }
            catch (Exception ex)
            {
                MailSender.SendMail("", "", "Error System", ex.Message + "\n" + ex.StackTrace);
            }
        }