public List <HoaDonHienThi> loadHoaDon() { List <HoaDonHienThi> list = new List <HoaDonHienThi>(); DataTable dt = HoaDonController.Instance.getAllHoaDonHienThi(); foreach (DataRow item in dt.Rows) { String id = item["id"].ToString(); String id_khachhang = item["hoten"].ToString(); String id_ban = item["ten_ban"].ToString(); String ngayhd = item["ngayhd"].ToString(); String sotien = item["sotien"].ToString(); String trangthai; if ((int)item["trangthai"] == 1) { trangthai = "Chưa thanh toán"; } else { trangthai = "Đã thanh toán"; } HoaDonHienThi dh = new HoaDonHienThi(id, id_ban, id_khachhang, ngayhd, sotien, trangthai); list.Add(dh); } return(list); }
public List <HoaDonHienThi> GetTable_HD() { List <HoaDonHienThi> listHD = new List <HoaDonHienThi>(); string sql = "select MaHD,TenNV,TenKH,NgayMua from HOA_DON inner join NHAN_VIEN on HOA_DON.MaNV=NHAN_VIEN.MaNV inner join KHACH_HANG on HOA_DON.MaKH=KHACH_HANG.MaKH"; XuLy.conn = new SqlConnection(XuLy.strConnection); XuLy.conn.Open(); XuLy.cmd = new SqlCommand(sql, XuLy.conn); SqlDataReader dr = XuLy.cmd.ExecuteReader(); while (dr.Read()) { HoaDonHienThi hd = new HoaDonHienThi( dr["MaHD"].ToString(), dr["TenNV"].ToString(), dr["TenKH"].ToString(), DateTime.Parse(dr["NgayMua"].ToString())); listHD.Add(hd); } dr.Close(); XuLy.conn.Close(); return(listHD); }