Exemple #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);
     }
 }
Exemple #2
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);
            }
        }
Exemple #3
0
 protected void lbtRegister_Click(object sender, EventArgs e)
 {
     try
     {
         if (Page.IsValid)
         {
             if (string.IsNullOrEmpty(txtUserName.Value.Trim()))
             {
                 WebMsgBox.Show("Vui lòng nhập email của bạn");
                 txtUserName.Focus();
                 return;
             }
             if (!StringClass.IsValidEmail(txtUserName.Value.Trim()))
             {
                 WebMsgBox.Show("Vui lòng nhập email đúng định dạng");
                 txtUserName.Focus();
                 return;
             }
             if (string.IsNullOrEmpty(txtPass.Value.Trim()))
             {
                 WebMsgBox.Show("Vui lòng nhập mật khẩu");
                 txtPass.Focus();
                 return;
             }
             Regex reg = new Regex("(?!^[0-9]*$)(?!^[a-zA-Z]*$)^([a-zA-Z0-9]{6,15})$");
             if (!reg.IsMatch(txtPass.Value.Trim()))
             {
                 WebMsgBox.Show("Mật khẩu chỉ bao gồm kí tự chữ và số");
                 txtPass.Focus();
                 return;
             }
             if (!txtPass.Value.Trim().Equals(txtConfirmPass.Value.Trim()))
             {
                 WebMsgBox.Show("Mật khẩu xác nhận không khớp");
                 txtConfirmPass.Focus();
                 return;
             }
             Customers cus = new Customers();
             cus.Email    = StringClass.SqlInjection(txtUserName.Value.Trim());
             cus.UserName = cus.Email.Substring(0, cus.Email.LastIndexOf("@"));
             cus.FullName = cus.Email.Substring(0, cus.Email.LastIndexOf("@"));
             cus.Password = StringClass.SqlInjection(StringClass.Encode(txtPass.Value.Trim()));
             cus.Active   = "1";
             DataTable dt = CustomersService.Customers_GetByName(StringClass.SqlInjection(txtUserName.Value.Trim()));
             if (dt.Rows.Count > 0)
             {
                 WebMsgBox.Show("Email này đã được đăng kí.");
                 txtUserName.Focus();
                 return;
             }
             int id = CustomersService.Customers_Insert(cus);
             cus.Id = id.ToString();
             FormsAuthentication.SetAuthCookie(StringClass.SqlInjection(txtUserName.Value.Trim()), false);
             Session["Info"] = cus;
             Response.Redirect("/", false);
         }
     }
     catch (Exception ex)
     {
         MailSender.SendMail("", "", "Error System", ex.Message + "\n" + ex.StackTrace);
     }
 }