protected void Page_Load(object sender, EventArgs e)
        {
            bind_SanPham();

            string link_fb = Request.QueryString["s"];

            rptQuangCao.DataSource = QuangCaoService.QuangCao_GetByTop("", " Active='True'", "");
            rptQuangCao.DataBind();

            if (link_fb != null)
            {
                Session["link_fb"] = link_fb;
                List <Entity.KhachHang> lstKh = new List <Entity.KhachHang>();

                lstKh = KhachHangService.KhachHang_GetByTop("", " Link_Fb='" + Session["link_fb"].ToString() + "' ", "");
                if (lstKh.Count == 0)
                {
                    KhachHang objkh = new KhachHang();
                    objkh.TenKH    = "";
                    objkh.GioiTinh = "true";
                    objkh.NgaySinh = "";
                    objkh.MatKhau  = "";

                    objkh.Email    = "";
                    objkh.TaiKhoan = Session["TenDangNhap"].ToString();
                    objkh.SDT      = "";
                    objkh.Tinh     = "";
                    objkh.Quan     = "";
                    objkh.DiaChi   = "";
                    objkh.Link_Fb  = Session["Link_Fb"].ToString();
                    KhachHangService.KhachHang_Insert(objkh);
                }
            }
        }
Exemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            remenu.DataSource = NhomHangService.NhomHang_GetByTop("", " Active='True'", "");
            remenu.DataBind();

            if (!IsPostBack)
            {
                TenDangNhap = Request.QueryString["TenDangNhap"];
                //load tỉnh
                ddlthanhpho.DataSource     = from tp in db.devvn_tinhthanhphos select new { tp.name, tp.matp };
                ddlthanhpho.DataTextField  = "name";
                ddlthanhpho.DataValueField = "matp";
                ddlthanhpho.DataBind();

                List <Entity.KhachHang> lst = new List <Entity.KhachHang>();
                lst = KhachHangService.KhachHang_GetByTop("", " TaiKhoan='" + TenDangNhap + "' ", "");

                devvn_quanhuyen qh = new devvn_quanhuyen();

                // var id = from tps in db.devvn_tinhthanhphos where tps.name == lst[0].Tinh.ToString() select new { tps.matp };


                lbltendangnhap.Text = lst[0].TaiKhoan;
                txthovaten.Text     = lst[0].TenKH;
                string gt = lst[0].GioiTinh;
                if (String.Compare(gt, "True") == 0)
                {
                    rdobtnNam.Checked = true;
                }
                else
                {
                    rdobtnNu.Checked = true;
                }

                txtngaysinh.Text  = lst[0].NgaySinh;
                txtemail.Text     = lst[0].Email;
                txtdienthoai.Text = lst[0].SDT;

                if (lst[0].Quan != "")
                {
                    ddlthanhpho.Items.FindByText(lst[0].Tinh).Selected = true;
                }
                txtdiachi.Text = lst[0].DiaChi;

                MatKhau = lst[0].MatKhau;

                string id = ddlthanhpho.SelectedValue;
                var    q  = from x in db.devvn_quanhuyens where (x.matp == id)select new { x.maqh, x.name };
                ddlquan.DataSource     = q;
                ddlquan.DataTextField  = "name";
                ddlquan.DataValueField = "maqh";
                ddlquan.DataBind();

                if (lst[0].Tinh != "")
                {
                    ddlquan.Items.FindByText(lst[0].Quan).Selected = true;
                }
            }
        }
        protected void btnhuy_Click(object sender, EventArgs e)
        {
            if (Session["link_fb"] != null)
            {
                lst = KhachHangService.KhachHang_GetByTop("", " link_fb='" + Session["link_fb"] + "'", "");
                lbltendangnhap.Text = lst[0].TaiKhoan;
                txthovaten.Text     = lst[0].TenKH;
                string gt = lst[0].GioiTinh;
                if (String.Compare(gt, "True") == 0)
                {
                    rdobtnNam.Checked = true;
                }
                else
                {
                    rdobtnNu.Checked = true;
                }

                txtngaysinh.Text  = lst[0].NgaySinh;
                txtemail.Text     = lst[0].Email;
                txtdienthoai.Text = lst[0].SDT;
                if (lst[0].Quan != "" && lst[0].Tinh != "")
                {
                    ddlquan.Items.FindByText(lst[0].Quan).Selected     = true;
                    ddlthanhpho.Items.FindByText(lst[0].Tinh).Selected = true;
                }

                txtdiachi.Text = lst[0].DiaChi;



                lbltendangnhap.Text = lst[0].TaiKhoan;
                txtemail.Text       = lst[0].Email;
            }
            else
            {
                List <Entity.KhachHang> lst = new List <Entity.KhachHang>();
                lst = KhachHangService.KhachHang_GetByTop("", " TaiKhoan='" + TenDangNhap + "'", "");
                lbltendangnhap.Text = lst[0].TaiKhoan;
                txthovaten.Text     = lst[0].TenKH;
                string gt = lst[0].GioiTinh;
                if (String.Compare(gt, "True") == 0)
                {
                    rdobtnNam.Checked = true;
                }
                else
                {
                    rdobtnNu.Checked = true;
                }

                txtngaysinh.Text  = "2017-01-01";
                txtemail.Text     = lst[0].Email;
                txtdienthoai.Text = lst[0].SDT;
                ddlquan.Items.FindByText(lst[0].Quan).Selected     = true;
                ddlthanhpho.Items.FindByText(lst[0].Tinh).Selected = true;
                txtdiachi.Text = lst[0].DiaChi;
                MatKhau        = lst[0].MatKhau;
            }
        }
        protected void btndangki_Click(object sender, EventArgs e)
        {
            Entity.KhachHang objkh = new Entity.KhachHang();
            if (txtpassword.Text != "")
            {
                objkh.MatKhau = txtpassword.Text.Trim();
            }
            else
            {
                objkh.MatKhau = MatKhau;
                //Response.Write("<script>alert('Bạn phải bắt buộc phải nhập mật khẩu!')</script>");
                //return;
            }
            objkh.TenKH = txthovaten.Text.Trim();
            if (rdobtnNam.Checked == true)
            {
                objkh.GioiTinh = "true";
            }
            else
            {
                objkh.GioiTinh = "false";
            }
            objkh.NgaySinh = txtngaysinh.Text;

            objkh.SDT    = txtdienthoai.Text.Trim();
            objkh.Tinh   = ddlthanhpho.SelectedItem.ToString();
            objkh.Quan   = ddlquan.SelectedItem.ToString();
            objkh.DiaChi = txtdiachi.Text.Trim();
            List <Entity.KhachHang> lst = new List <Entity.KhachHang>();

            if (Session["link_fb"] != null)
            {
                objkh.Email = txtemail.Text;
                lst         = KhachHangService.KhachHang_GetByTop("", " link_fb='" + Session["link_fb"] + "' ", "");
                objkh.Id    = lst[0].Id;
                KhachHangService.KhachHang_Update(objkh);
                Response.Write("<script>alert('Cật nhật thành công')</script>");
            }
            else
            {
                objkh.Email = txtemail.Text.Trim();
                lst         = KhachHangService.KhachHang_GetByTop("", " TaiKhoan='" + Session["TenDangNhap"] + "'", "");
                objkh.Id    = lst[0].Id;
                KhachHangService.KhachHang_Update(objkh);
                Response.Write("<script>alert('Cật nhật thành công')</script>");
            }
        }
        protected void btndangnhap_Click(object sender, EventArgs e)
        {
            if (txtusername.Text == "" || txtpassword.Text == "")
            {
                lblcheck.Text = "Bạn phải nhập đầy đủ user và password!!!";
                return;
            }
            else if (txtusername.Text != "" || txtpassword.Text != "")
            {
                List <Entity.KhachHang> lst = KhachHangService.KhachHang_GetByTop("", " TaiKhoan='" + txtusername.Text + "' AND MatKhau='" + txtpassword.Text + "' ", "");
                if (lst.Count > 0)
                {
                    Session["display_name"] = lst[0].TaiKhoan;
                    Session["TenDangNhap"]  = lst[0].TaiKhoan;
                    Response.Redirect("TrangChu.aspx");
                }
                else
                {
                    lblcheck.Text = "Tài khoản và mật khẩu không đúng!!";
                }

                List <Entity.NhanVien> lst1 = NhanVienService.NhanVien_GetByTop("", " UserName='******' AND Password='******' and id_quyen = 1", "");
                if (lst1.Count == 0)
                {
                    lblcheck.Text = "Tài khoản hoặc mật khẩu không đúng!!";
                }
                else
                {
                    Session["TenDangNhap"] = lst1;
                    Response.Redirect("HangAdmin.aspx");
                }
            }
            else
            {
                List <Entity.NhanVien> lst = NhanVienService.NhanVien_GetByTop("", " UserName='******' AND Password='******' and id_quyen = 1 ", "");
                if (lst.Count == 0)
                {
                    lblcheck.Text = "Tài khoản hoặc mật khẩu không đúng!!";
                }
                else
                {
                    Session["TenDangNhap"] = lst;
                    Response.Redirect("HangAdmin.aspx");
                }
            }
        }
 protected void btndangnhap_Click(object sender, EventArgs e)
 {
     if (txtusername.Text == "" || txtpassword.Text == "")
     {
         lblcheck.Text = "Bạn phải nhập đầy đủ user và password!!!";
         return;
     }
     else
     {
         List <Entity.KhachHang> lst = KhachHangService.KhachHang_GetByTop("", " TaiKhoan='" + txtusername.Text + "' AND MatKhau='" + txtpassword.Text + "' ", "");
         if (lst.Count > 0)
         {
             Session["TenDangNhap"] = lst[0].TaiKhoan;
             Response.Redirect("TrangChu.aspx");
         }
         else
         {
             lblcheck.Text = "Tài khoản và mật khẩu không đúng!!";
         }
     }
 }
        protected void btndathang_Click(object sender, EventArgs e)
        {
            List <Entity.KhachHang> lstKh = new List <Entity.KhachHang>();

            Entity.DatHang        dh    = new Entity.DatHang();
            List <Entity.DatHang> lstdh = new List <Entity.DatHang>();

            Entity.ChiTietDatHang lstctdh = new Entity.ChiTietDatHang();
            string Id_SP;

            if (txtdiachi.Text == "" || txtdienthoai.Text == "" || txtemail.Text == "" || txthovaten.Text == "" || ddlquan.SelectedIndex == 0 || ddlthanhpho.SelectedIndex == 0)
            {
                Response.Write("<script>alert('Bạn phải nhập đầy đủ thông tin!!1')</script>");
                return;
            }
            else if (Session["Link_Fb"] == null)
            {
                if (Session["TenDangNhap"] == null)
                {
                    Entity.KhachHang obj = new Entity.KhachHang();

                    obj.TenKH    = txthovaten.Text;
                    obj.TaiKhoan = "";
                    obj.MatKhau  = "";
                    obj.NgaySinh = "";
                    obj.GioiTinh = "True";

                    obj.Email   = txtemail.Text;
                    obj.SDT     = txtdienthoai.Text;
                    obj.DiaChi  = txtdiachi.Text;
                    obj.Tinh    = ddlthanhpho.SelectedItem.ToString();
                    obj.Quan    = ddlquan.SelectedItem.ToString();
                    obj.Link_Fb = "false";
                    KhachHangService.KhachHang_Insert(obj);
                    lstKh           = KhachHangService.KhachHang_GetByTop("", " id=(SELECT MAX(id) from tbl_KhachHang) ", "");
                    dh.Id_KhachHang = lstKh[0].Id;
                    dh.NgaylapHD    = DateTime.Now.ToString();
                    dh.IdPay        = ddlhinhthucthanhtoan.SelectedValue.ToString();
                    DatHangService.DatHang_Insert(dh);
                    lstdh             = DatHangService.DatHang_GetByTop("", " id=(SELECT MAX(id) from tbl_DatHang)", "");
                    lstctdh.Id_hoadon = lstdh[0].Id;
                    for (int i = 0; i < tbGioHang.Rows.Count; i++)
                    {
                        string tenSP = tbGioHang.Rows[i]["TenSP"].ToString();
                        Id_SP              = SanPhamService.SanPham_GetByTop("", " TenHang=N'" + tenSP + "'", "")[0].Id;
                        lstctdh.Id_hang    = Id_SP;
                        lstctdh.Size       = tbGioHang.Rows[i]["Size"].ToString();
                        lstctdh.SoLuongMua = tbGioHang.Rows[i]["SoLuong"].ToString();
                        lstctdh.ThanhTien  = tbGioHang.Rows[i]["TongGia"].ToString();
                        lstctdh.Gia        = tbGioHang.Rows[i]["Gia"].ToString();
                        ChiTietDatHangService.ChiTietDatHang_Insert(lstctdh);
                    }
                }
                else
                {
                    string TenDangNhap = Session["TenDangNhap"].ToString();

                    lstKh = KhachHangService.KhachHang_GetByTop("", " TaiKhoan='" + TenDangNhap + "'", "");
                    Entity.KhachHang kh = new Entity.KhachHang();
                    kh.Id     = lstKh[0].Id;
                    kh.TenKH  = txthovaten.Text;
                    kh.Email  = txtemail.Text;
                    kh.DiaChi = txtdiachi.Text;
                    kh.SDT    = txtdienthoai.Text;
                    kh.Tinh   = ddlthanhpho.SelectedItem.ToString();
                    kh.Quan   = ddlquan.SelectedItem.ToString();
                    KhachHangService.KhachHang_UpdateDatHang(kh);

                    dh.NgaylapHD    = DateTime.Now.ToString();
                    dh.IdPay        = ddlhinhthucthanhtoan.SelectedValue.ToString();
                    dh.Id_KhachHang = kh.Id;
                    DatHangService.DatHang_Insert(dh);

                    lstdh = DatHangService.DatHang_GetByTop("", " id=(SELECT MAX(id) from tbl_DatHang where id_KhachHang=" + kh.Id + ")", "");


                    lstctdh.Id_hoadon = lstdh[0].Id;
                    for (int i = 0; i < tbGioHang.Rows.Count; i++)
                    {
                        string tenSP = tbGioHang.Rows[i]["TenSP"].ToString();
                        Id_SP              = SanPhamService.SanPham_GetByTop("", " TenHang=N'" + tenSP + "'", "")[0].Id;
                        lstctdh.Id_hang    = Id_SP;
                        lstctdh.Size       = tbGioHang.Rows[i]["Size"].ToString();
                        lstctdh.SoLuongMua = tbGioHang.Rows[i]["SoLuong"].ToString();
                        lstctdh.ThanhTien  = tbGioHang.Rows[i]["TongGia"].ToString();
                        lstctdh.Gia        = tbGioHang.Rows[i]["Gia"].ToString();
                        ChiTietDatHangService.ChiTietDatHang_Insert(lstctdh);
                    }
                }
            }
            else
            {
                string Link_Fb = Session["Link_Fb"].ToString();

                lstKh = KhachHangService.KhachHang_GetByTop("", " Link_Fb='" + Link_Fb + "' ", "");
                Entity.KhachHang kh = new Entity.KhachHang();
                kh.Id     = lstKh[0].Id;
                kh.TenKH  = txthovaten.Text;
                kh.Email  = txtemail.Text;
                kh.DiaChi = txtdiachi.Text;
                kh.SDT    = txtdienthoai.Text;
                kh.Tinh   = ddlthanhpho.SelectedItem.ToString();
                kh.Quan   = ddlquan.SelectedItem.ToString();
                KhachHangService.KhachHang_UpdateDatHang(kh);

                dh.NgaylapHD    = DateTime.Now.ToString();
                dh.IdPay        = ddlhinhthucthanhtoan.SelectedValue.ToString();
                dh.Id_KhachHang = kh.Id;
                DatHangService.DatHang_Insert(dh);

                lstdh = DatHangService.DatHang_GetByTop("", " id=(SELECT MAX(id) from tbl_DatHang where id_KhachHang=" + kh.Id + ")", "");


                lstctdh.Id_hoadon = lstdh[0].Id;
                for (int i = 0; i < tbGioHang.Rows.Count; i++)
                {
                    string tenSP = tbGioHang.Rows[i]["TenSP"].ToString();
                    Id_SP              = SanPhamService.SanPham_GetByTop("", " TenHang=N'" + tenSP + "'", "")[0].Id;
                    lstctdh.Id_hang    = Id_SP;
                    lstctdh.Size       = tbGioHang.Rows[i]["Size"].ToString();
                    lstctdh.SoLuongMua = tbGioHang.Rows[i]["SoLuong"].ToString();
                    lstctdh.ThanhTien  = tbGioHang.Rows[i]["TongGia"].ToString();
                    lstctdh.Gia        = tbGioHang.Rows[i]["Gia"].ToString();
                    ChiTietDatHangService.ChiTietDatHang_Insert(lstctdh);
                }
            }
            Response.Write("<script>alert('Đặt hàng thành công!!')</script>");
            Session["GioHang"] = null;
            lblsl                 = (Label)Master.FindControl("lblslgiohang");
            lblsl.Text            = "0";
            lbltongtien.Text      = "0 VNĐ";
            tbGioHang             = null;
            grvsanpham.DataSource = tbGioHang;
            grvsanpham.DataBind();
        }
Exemplo n.º 8
0
        protected void btndathang_Click(object sender, EventArgs e)
        {
            List <Entity.KhachHang> lstKh = new List <Entity.KhachHang>();

            Entity.DatHang        dh    = new Entity.DatHang();
            List <Entity.DatHang> lstdh = new List <Entity.DatHang>();

            Entity.ChiTietDatHang lstctdh = new Entity.ChiTietDatHang();
            string Id_SP;

            if (txtdiachi.Text == "" || txtdienthoai.Text == "" || txtemail.Text == "" || txthovaten.Text == "") //|| ddlquan.SelectedIndex == 0 || ddlthanhpho.SelectedIndex == 0
            {
                Response.Write("<script>alert('" + ddlquan.SelectedValue + "')</script>");
                Response.Write("<script>alert('Bạn phải nhập đầy đủ thông tin!!1')</script>");
                return;
            }
            else
            {
                if (Session["TenDangNhap"] == null)
                {
                    Entity.KhachHang obj = new Entity.KhachHang();
                    //Response.Write("<script>alert('Vào đây')</script>");
                    obj.TenKH    = txthovaten.Text;
                    obj.TaiKhoan = "";
                    obj.MatKhau  = "";
                    obj.NgaySinh = "";
                    obj.GioiTinh = "True";

                    obj.Email   = txtemail.Text;
                    obj.SDT     = txtdienthoai.Text;
                    obj.DiaChi  = txtdiachi.Text;
                    obj.Tinh    = ddlthanhpho.SelectedItem.ToString();
                    obj.Quan    = ddlquan.SelectedItem.ToString();
                    obj.Link_Fb = "false";
                    KhachHangService.KhachHang_Insert(obj);
                    lstKh = KhachHangService.KhachHang_GetByTop("", " id=(SELECT MAX(id) from tbl_KhachHang) ", "");

                    tbl_DatHang dhs = new tbl_DatHang();
                    dhs.id_KhachHang = int.Parse(lstKh[0].Id);
                    dhs.NgaylapHD    = DateTime.Now;
                    dhs.IdPay        = int.Parse(ddlhinhthucthanhtoan.SelectedValue);
                    ///////////////////////////////////////////////////////////////////
                    dbs.tbl_DatHangs.InsertOnSubmit(dhs);
                    dbs.SubmitChanges();
                    lstdh             = DatHangService.DatHang_GetByTop("", " id=(SELECT MAX(id) from tbl_DatHang)", "");
                    lstctdh.Id_hoadon = lstdh[0].Id;
                    for (int i = 0; i < tbGioHang.Rows.Count; i++)
                    {
                        string tenSP = tbGioHang.Rows[i]["TenSP"].ToString();
                        Id_SP              = SanPhamService.SanPham_GetByTop("", " TenHang=N'" + tenSP + "'", "")[0].Id;
                        lstctdh.Id_hang    = Id_SP;
                        lstctdh.Size       = tbGioHang.Rows[i]["Size"].ToString();
                        lstctdh.SoLuongMua = tbGioHang.Rows[i]["SoLuong"].ToString();
                        lstctdh.ThanhTien  = tbGioHang.Rows[i]["TongGia"].ToString();
                        lstctdh.Gia        = tbGioHang.Rows[i]["Gia"].ToString();
                        ChiTietDatHangService.ChiTietDatHang_Insert(lstctdh);
                    }
                }
                else
                {
                    string TenDangNhap = Session["TenDangNhap"].ToString();

                    lstKh = KhachHangService.KhachHang_GetByTop("", " TaiKhoan='" + TenDangNhap + "'", "");
                    Entity.KhachHang kh = new Entity.KhachHang();
                    kh.Id     = lstKh[0].Id;
                    kh.TenKH  = txthovaten.Text;
                    kh.Email  = txtemail.Text;
                    kh.DiaChi = txtdiachi.Text;
                    kh.SDT    = txtdienthoai.Text;
                    kh.Tinh   = ddlthanhpho.SelectedItem.ToString();
                    kh.Quan   = ddlquan.SelectedItem.ToString();
                    KhachHangService.KhachHang_UpdateDatHang(kh);

                    tbl_DatHang dhs = new tbl_DatHang();
                    dhs.id_KhachHang = int.Parse(kh.Id);
                    dhs.NgaylapHD    = DateTime.Now;
                    dhs.IdPay        = int.Parse(ddlhinhthucthanhtoan.SelectedValue);
                    ///////////////////////////////////////////////////////////////////
                    dbs.tbl_DatHangs.InsertOnSubmit(dhs);
                    dbs.SubmitChanges();

                    lstdh = DatHangService.DatHang_GetByTop("", " id=(SELECT MAX(id) from tbl_DatHang where id_KhachHang=" + kh.Id + ")", "");

                    lstctdh.Id_hoadon = lstdh[0].Id;
                    for (int i = 0; i < tbGioHang.Rows.Count; i++)
                    {
                        string tenSP = tbGioHang.Rows[i]["TenSP"].ToString();
                        Id_SP              = SanPhamService.SanPham_GetByTop("", " TenHang=N'" + tenSP + "'", "")[0].Id;
                        lstctdh.Id_hang    = Id_SP;
                        lstctdh.Size       = tbGioHang.Rows[i]["Size"].ToString();
                        lstctdh.SoLuongMua = tbGioHang.Rows[i]["SoLuong"].ToString();
                        lstctdh.ThanhTien  = tbGioHang.Rows[i]["TongGia"].ToString();
                        lstctdh.Gia        = tbGioHang.Rows[i]["Gia"].ToString();
                        ChiTietDatHangService.ChiTietDatHang_Insert(lstctdh);
                    }
                }
            }

            Response.Write("<script>alert('Đặt hàng thành công!! Cảm ơn bạn nhiều nhé!! ')</script>");

            // MailMessage message = new MailMessage("*****@*****.**",txtemail.Text, "Shop Fashion(Clothing Store) ",grvsanpham.Rows[0].Cells[0].Text);
            // message.IsBodyHtml = true;

            //  SmtpClient client = new SmtpClient("smtp.gmail.com", 587);
            //client.EnableSsl = true;
            //client.UseDefaultCredentials = false;
            //client.DeliveryMethod = SmtpDeliveryMethod.Network;
            //client.Credentials = new System.Net.NetworkCredential("*****@*****.**", "Baonguyen741999@!");
            //client.Send(message);

            for (int i = 0; i < tbGioHang.Rows.Count; i++)
            {
                var          from         = "*****@*****.**";
                var          to           = txtemail.Text;
                const string Password     = "******";
                string       mail_subject = "Clothing Store";
                string       mail_message = "From : Clothing Store" + "\n";
                mail_message += "From : [email protected] " + "\n";
                mail_message += "Thông tin mua hàng của quý khách" + "\n";
                string tenSP = tbGioHang.Rows[i]["TenSP"].ToString();
                Id_SP = SanPhamService.SanPham_GetByTop("", " TenHang=N'" + tenSP + "'", "")[0].Id;

                mail_message += "ID sản phẩm : " + Id_SP + "\n";
                mail_message += "Tên sản phẩm :" + tbGioHang.Rows[i]["TenSP"].ToString() + "\n";
                mail_message += "Size: " + tbGioHang.Rows[i]["Size"].ToString() + "\n";
                mail_message += "Số lượng: " + tbGioHang.Rows[i]["SoLuong"].ToString() + "\n";
                mail_message += "Tổng giá: " + tbGioHang.Rows[i]["TongGia"].ToString() + "\n";
                mail_message += "Giá: " + tbGioHang.Rows[i]["Gia"].ToString() + "\n";
                var smtp = new SmtpClient();
                {
                    smtp.Host           = "smtp.gmail.com";
                    smtp.Port           = 587;
                    smtp.EnableSsl      = true;
                    smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
                    smtp.Credentials    = new NetworkCredential(from, Password);
                    smtp.Timeout        = 10000;
                }
                smtp.Send(from, to, mail_subject, mail_message);
            }



            Session["GioHang"]     = null;
            Session["slspgiohang"] = null;
            lblsl                 = (Label)Master.FindControl("lblslgiohang");
            lblsl.Text            = "0";
            lbltongtien.Text      = "0 VNĐ";
            tbGioHang             = null;
            grvsanpham.DataSource = tbGioHang;
            grvsanpham.DataBind();
            Response.AddHeader("REFRESH", "1;URL=TrangChu.aspx");
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                TenDangNhap = Request.QueryString["TenDangNhap"];
                if (Session["link_fb"] != null)
                {
                    txtpassword.Enabled        = false;
                    txtpassword.Width          = 319;
                    txtpassword.Height         = 30;
                    txtrepressPassword.Enabled = false;
                    txtrepressPassword.Width   = 319;
                    txtrepressPassword.Height  = 27;


                    lst = KhachHangService.KhachHang_GetByTop("", " link_fb='" + Session["link_fb"] + "'", "");
                    lbltendangnhap.Text = lst[0].TaiKhoan;
                    txthovaten.Text     = lst[0].TenKH;
                    string gt = lst[0].GioiTinh;
                    if (String.Compare(gt, "True") == 0)
                    {
                        rdobtnNam.Checked = true;
                    }
                    else
                    {
                        rdobtnNu.Checked = true;
                    }

                    txtngaysinh.Text  = lst[0].NgaySinh;
                    txtemail.Text     = lst[0].Email;
                    txtdienthoai.Text = lst[0].SDT;
                    if (lst[0].Quan != "" && lst[0].Tinh != "")
                    {
                        ddlquan.Items.FindByText(lst[0].Quan).Selected     = true;
                        ddlthanhpho.Items.FindByText(lst[0].Tinh).Selected = true;
                    }

                    txtdiachi.Text = lst[0].DiaChi;



                    lbltendangnhap.Text = lst[0].TaiKhoan;
                    txtemail.Text       = lst[0].Email;
                }
                else
                {
                    List <Entity.KhachHang> lst = new List <Entity.KhachHang>();
                    lst = KhachHangService.KhachHang_GetByTop("", " TaiKhoan='" + TenDangNhap + "' ", "");
                    lbltendangnhap.Text = lst[0].TaiKhoan;
                    txthovaten.Text     = lst[0].TenKH;
                    string gt = lst[0].GioiTinh;
                    if (String.Compare(gt, "True") == 0)
                    {
                        rdobtnNam.Checked = true;
                    }
                    else
                    {
                        rdobtnNu.Checked = true;
                    }

                    txtngaysinh.Text  = lst[0].NgaySinh;
                    txtemail.Text     = lst[0].Email;
                    txtdienthoai.Text = lst[0].SDT;
                    if (lst[0].Quan != "" && lst[0].Tinh != "")
                    {
                        ddlquan.Items.FindByText(lst[0].Quan).Selected     = true;
                        ddlthanhpho.Items.FindByText(lst[0].Tinh).Selected = true;
                    }
                    txtdiachi.Text = lst[0].DiaChi;

                    MatKhau = lst[0].MatKhau;
                }
            }
        }