protected void btnLuu_Click(object sender, EventArgs e)
        {
            DTOKhachHang dtoKH = new DTOKhachHang();

            dtoKH.TenKH    = txtTenKH.Text;
            dtoKH.DiaChiKH = txtDiaChi.Text;
            dtoKH.SdtKH    = txtSdt.Text;

            DTOLoaiKH dtoLoaiKH = new DTOLoaiKH();

            dtoLoaiKH.MaLKH  = int.Parse(ddLoaiKH.SelectedValue);
            dtoLoaiKH.TenLKH = ddLoaiKH.SelectedItem.ToString();
            dtoKH.dtoLoaiKH  = dtoLoaiKH;

            XuLy_TiepNhanDonHang control = new XuLy_TiepNhanDonHang();

            //        DAO_Entity daoKH = new DAO_Entity();
            if (KiemTraNhap() == "")
            {
                control.ThemKH(dtoKH);
                Response.Redirect("~/QLBoPhan_TiepXucKH/DSKhachHang.aspx");
            }
            else
            {
                ThemKH.Visible = true;
                lbLoi.Text     = KiemTraNhap();
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                DTOKhachHang dto   = new DTOKhachHang();
                DAO_Entity   daokh = new DAO_Entity();

                XuLy_TiepNhanDonHang control = new XuLy_TiepNhanDonHang();
                control.LayDSKhachHang();

                List <DTOKhachHang> Dskh = daokh.TaoDSKH();
                GridDSKH.DataSource = Dskh;
                GridDSKH.DataBind();
            }
            catch (Exception)
            {
                Response.Write("<script>alert('Loi tai du lieu!')</script>");
            }
            ThemKH.Visible = false;


            if (IsPostBack == false)
            {
                List <DTOLoaiKH> dsLKH = new List <DTOLoaiKH>();
                DAO_Entity       daoKH = new DAO_Entity();
                dsLKH = daoKH.LayDSLKH();
                //hien thi ten loai KH ra dropdownlist
                ddLoaiKH.DataTextField = "TenLKH"; //TenLKH la thuoc tinh trong DTOLoaiKH
                //truyen dl theo ma loai
                ddLoaiKH.DataValueField = "MaLKH"; //MaLKH la thuoc tinh trong DTOLoaiKH
                ddLoaiKH.DataSource     = dsLKH;
                ddLoaiKH.DataBind();
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                hienThanhPhamChon();

                if (Session["dsThanhPhamChon"] == null)
                {
                    lbDSChon.Visible       = false;
                    lbTextTongTien.Visible = false;
                    lbTongTien.Visible     = false;
                    lbDSSanpham.Visible    = false;
                    grDSSanPham.Visible    = false;
                    gridDSChon.Visible     = false;
                }
                else
                {
                    lbDSChon.Visible       = true;
                    lbTextTongTien.Visible = true;
                    lbTongTien.Visible     = true;
                    lbDSSanpham.Visible    = true;
                    grDSSanPham.Visible    = true;
                    gridDSChon.Visible     = true;
                }
            }
            catch (Exception)
            {
                Response.Write("<script>alert('Loi tai du lieu!')</script>");
            }

            if (IsPostBack == false)//postback=false: chưa có sự kiện click trên web
            {
                // request: yeu cau. QueryString: lay gia tri cua chuoi tren duong dan
                string       makh        = Request.QueryString["MaKH"].ToString();
                DAO_Entity   daoEntities = new DAO_Entity();
                DTOKhachHang dtoKH       = daoEntities.LayTTKHTheoMa(makh);

                XuLy_TiepNhanDonHang control = new XuLy_TiepNhanDonHang();
                control.LayttKH(makh);

                lbMaKH.Text       = dtoKH.MaKH.ToString();
                txtTen.Text       = dtoKH.TenKH;
                txtNgayTaoDH.Text = DateTime.Now.ToShortDateString();


                List <DTODonDatHang> dsdh = daoEntities.LayDSDHTheoMa(makh);
                GridViewDH.DataSource = dsdh;
                GridViewDH.DataBind();
                grDSSanPham.DataSource = daoEntities.TaoDSSP();
                grDSSanPham.DataBind();
            }
        }
        protected void btnTim_Click(object sender, EventArgs e)
        {
            DAO_Entity daoKH = new DAO_Entity();

            XuLy_TiepNhanDonHang control = new XuLy_TiepNhanDonHang();

            control.TimtenKH(txtTim.Text.Trim());

            List <DTOKhachHang> kqTim = daoKH.TimTheoTenKH(txtTim.Text.Trim());

            GridDSKH.DataSource = kqTim;
            GridDSKH.DataBind();
        }