Beispiel #1
0
        public static int Insert(Thanhvien tv)
        {
            using (SqlConnection cnn = ConnectDataBase())
            {
                SqlCommand cmd = new SqlCommand("sp_Thanhvien_Insert", cnn);
                cmd.CommandType = CommandType.StoredProcedure;

                cmd.Parameters.AddWithValue("@email", tv.Email);
                cmd.Parameters.AddWithValue("@matkhau", tv.Matkhau);
                cmd.Parameters.AddWithValue("@hoten", tv.Hoten);
                cmd.Parameters.AddWithValue("@diachi", tv.Diachi);
                cmd.Parameters.AddWithValue("@sdt", tv.Sdt);
                cmd.Parameters.AddWithValue("@kichhoat", tv.Kichhoat);
                cmd.Parameters.AddWithValue("@makichhoat", tv.Makichhoat);
                cmd.Parameters.AddWithValue("@diemtichluy", tv.Diemtichluy);

                cmd.Parameters.Add("@check", SqlDbType.Int).Direction = ParameterDirection.ReturnValue;

                try
                {
                    cmd.ExecuteNonQuery();

                }
                catch (Exception)
                {

                }
                int check = (int)cmd.Parameters["@check"].Value;
                return check;
            }
        }
Beispiel #2
0
    public static void SendMail(Thanhvien tv)
    {
        MailMessage mail = new MailMessage();
        mail.To.Add(tv.Email);
        mail.From = new MailAddress("*****@*****.**");
        mail.Subject = "Kích hoạt tài khoản của bạn tại Men's Shop";
        mail.Body = "Mã kích hoạt của bạn là : http://mens.somee.com/kich-hoat.aspx?key=" + HttpContext.Current.Server.UrlEncode(tv.Makichhoat);
        mail.IsBodyHtml = true;

        SmtpClient client = new SmtpClient("smtp.gmail.com", 587);
        client.EnableSsl = true;
        NetworkCredential credent = new NetworkCredential("*****@*****.**", "/?id=g00gle.");
        client.UseDefaultCredentials = true;
        client.Credentials = credent;

        try
        {
            client.Send(mail);
        }
        catch (Exception)
        {
            throw;
        }
    }
Beispiel #3
0
        public static void Update(Thanhvien tv)
        {
            using (SqlConnection cnn = ConnectDataBase())
            {
                SqlCommand cmd = new SqlCommand("sp_Thanhvien_Update", cnn);
                cmd.CommandType = CommandType.StoredProcedure;

                cmd.Parameters.AddWithValue("@email", tv.Email);
                cmd.Parameters.AddWithValue("@matkhau", tv.Matkhau);
                cmd.Parameters.AddWithValue("@hoten", tv.Hoten);
                cmd.Parameters.AddWithValue("@diachi", tv.Diachi);
                cmd.Parameters.AddWithValue("@sdt", tv.Sdt);

                try
                {
                    cmd.ExecuteNonQuery();
                }
                catch (Exception)
                {

                }
            }
        }
Beispiel #4
0
    protected void btn_dangki_submit_Click(object sender, EventArgs e)
    {
        if(Regex.IsMatch(txt_hoten.Value.ToString(), @"[`1234567890-=;',./~!@#$%^&*()_+{}:|<>?]") || txt_hoten.Value=="")
        {
            check_hoten.Visible = true;
        }
        if (!Regex.IsMatch(txt_email.Value, @"^([\w\.\-]+)@([\w\-]+)((\.(\w){2,3})+)$"))
        {
            check_email.Visible = true;
        }
        if (txt_matkhau.Value.Length < 8)
        {
            check_matkhau.Visible = true;
        }
        if(txt_nhaplaimatkhau.Value.Equals(txt_matkhau.Value)==false)
        {
            check_nhaplaimatkhau.Visible = true;
        }
        if (!Regex.IsMatch(txt_sdt.Value, @"^[0-9]+$") || txt_sdt.Value == "")
        {
            if (txt_sdt.Value.Length == 10 || txt_sdt.Value.Length == 11)
            {
                check_sdt.Visible = false;
            }
            else
            {
                check_sdt.Visible = true;
            }
        }
        if(txt_diachi.Value=="")
        {
            check_diachi.Visible = true;
        }

        if (check_email.Visible == false && check_hoten.Visible == false && check_matkhau.Visible == false && check_nhaplaimatkhau.Visible == false && check_sdt.Visible == false && check_diachi.Visible==false)
        {
            Thanhvien tv = new Thanhvien();
            tv.Email = txt_email.Value;
            tv.Matkhau=function.Mahoa(txt_matkhau.Value).ToString();
            tv.Hoten = txt_hoten.Value;
            tv.Diachi = txt_diachi.Value;
            tv.Sdt = txt_sdt.Value;
            tv.Kichhoat = "chua kich hoat";
            tv.Makichhoat = function.Mahoa(txt_email.Value);
            tv.Diemtichluy = 0;

            try
            {
                int check = ThanhvienBUS.Thanhvien_Insert(tv);
                if(check==0)
                {
                    function.SendMail(tv);
                    Response.Write("<script>alert('Đăng kí thành công. Bạn cần truy cập và mail để kích hoạt tài khoản và sử dụng')</script>");
                }
                else
                {
                    Response.Write("<script>alert('Email này đã có người sử dụng')</script>");
                }

            }
            catch (Exception ex)
            {
                Response.Write("<script>" + ex.Message + "</script>");
            }
        }
    }
Beispiel #5
0
 public static void Thanhvien_Update(Thanhvien tv)
 {
     ThanhvienDAO.Update(tv);
 }
Beispiel #6
0
 public static int Thanhvien_Insert(Thanhvien tv)
 {
     return ThanhvienDAO.Insert(tv);
 }