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 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(); }