public List <TK_KH_HDBDTOcs> LAYDSHDBanTheoNgay(DateTime TimeTu, DateTime TimeDen) { List <TK_KH_HDBDTOcs> ls = new List <TK_KH_HDBDTOcs>(); string struyvan = "Select * From HienThiDSHoaDonBan Where TinhTrang = 1 AND NgayLapHD Between '" + TimeTu + "' AND '" + TimeDen + "'"; //SqlParameter[] p = new SqlParameter[2]; //p[1] = new SqlParameter("@TimeTu",TimeTu); //p[1] = new SqlParameter("@TimeTu", TimeDen); SqlConnection con = DataProvider.TaoKetNoi(); SqlDataReader sr = DataProvider.TruyVanDuLieu(struyvan, con); while (sr.Read()) { TK_KH_HDBDTOcs dto = new TK_KH_HDBDTOcs(); dto.MaHDBan = sr["MaHDBan"].ToString(); dto.HoTenKH = sr["HoTenKH"].ToString(); dto.HoTenNV = sr["HoTenNV"].ToString(); dto.NgayLapHD = DateTime.Parse(sr["NgayLapHD"].ToString()); dto.TongTien = double.Parse(sr["TongTien"].ToString()); dto.MaKH = sr["MaKH"].ToString(); dto.NVLapHD = sr["NVLapHD"].ToString(); dto.TinhTrang = int.Parse(sr["TinhTrang"].ToString()); ls.Add(dto); } con.Close(); sr.Close(); return(ls); }
public List <TK_KH_HDBDTOcs> LAYDSHDBanTheoMaHD(string mahd) { List <TK_KH_HDBDTOcs> ls = new List <TK_KH_HDBDTOcs>(); string struyvan = "Select tk.HoTenNV,kh.HoTenKH,hdb.* From TAI_KHOAN tk,KHACH_HANG kh , HOA_DON_BAN hdb WHERE kh.MaKH=hdb.MaKH AND tk.MaNV = hdb.NVLapHD AND MaHDBan='" + mahd + "' "; SqlConnection con = DataProvider.TaoKetNoi(); SqlDataReader sr = DataProvider.TruyVanDuLieu(struyvan, con); while (sr.Read()) { TK_KH_HDBDTOcs dto = new TK_KH_HDBDTOcs(); dto.MaHDBan = sr["MaHDBan"].ToString(); dto.NgayLapHD = DateTime.Parse(sr["NgayLapHD"].ToString()); dto.TongTien = double.Parse(sr["TongTien"].ToString()); dto.HoTenNV = sr["HoTenNV"].ToString(); dto.HoTenKH = sr["HoTenKH"].ToString(); dto.TienKhachTra = decimal.Parse(sr["TienKhachTra"].ToString()); dto.TienDu = decimal.Parse(sr["TienDu"].ToString()); ls.Add(dto); } con.Close(); sr.Close(); return(ls); }