public List <ChiTietHoaDon> getAll() { String query = "select MaHoaDon,MaSach,SoLuongMua from ChiTietHoaDon"; DataTable dt = this.dp.ExecuteQuery(query); List <ChiTietHoaDon> lstChiTietHoaDon = new List <ChiTietHoaDon>(); foreach (DataRow dr in dt.Rows) { ChiTietHoaDon chiTietHoaDon = new ChiTietHoaDon(); chiTietHoaDon.MaHoaDon = (int)dr["MaHoaDon"]; chiTietHoaDon.MaSach = (int)dr["MaSach"]; chiTietHoaDon.SoLuongMua = (int)dr["SoLuongMua"]; lstChiTietHoaDon.Add(chiTietHoaDon); } return(lstChiTietHoaDon); }
public static List <ChiTietHoaDon> LoadCTHoaDon(int id) { QLCHXeEntity db = new QLCHXeEntity(); var result = ( from c in db.ChiTietHoaDons join x in db.Xes on c.MaSanPham equals x.MaXe join km in db.KhuyenMais on c.MaKhuyenMai equals km.MaKhuyenMai where c.MaHoaDon == id select new { MaHoaDon = c.MaHoaDon, MaSanPham = c.MaSanPham, TenXe = x.TenXe, DonGia = c.DonGia, SoLuong = c.SoLuong, MaKhuyenMai = c.MaKhuyenMai, GiamGia = c.GiamGia, ThanhTien = c.ThanhTien, NoiDung = km.NoiDung }).ToList(); List <ChiTietHoaDon> listReturn = new List <ChiTietHoaDon>(); foreach (var item in result) { ChiTietHoaDon cthoadon_list = new ChiTietHoaDon(); cthoadon_list.MaHoaDon = item.MaHoaDon; cthoadon_list.MaSanPham = item.MaSanPham; cthoadon_list.TenXe = item.TenXe; cthoadon_list.DonGia = item.DonGia; cthoadon_list.SoLuong = item.SoLuong; cthoadon_list.MaKhuyenMai = item.MaKhuyenMai; cthoadon_list.GiamGia = item.GiamGia; cthoadon_list.ThanhTien = item.ThanhTien; listReturn.Add(cthoadon_list); } return(listReturn); }
public List <ChiTietHoaDon> getByMaHoaDon(int MaHoaDon) { String query = "select MaHoaDon,MaSach,SoLuongMua from ChiTietHoaDon where MaHoaDon = @MaHoaDon"; List <SqlParameter> sqlParameters = new List <SqlParameter>(); SqlParameter param = new SqlParameter("MaHoaDon", MaHoaDon); sqlParameters.Add(param); DataTable dt = this.dp.ExecuteQuery(query, sqlParameters); List <ChiTietHoaDon> lstChiTietHoaDon = new List <ChiTietHoaDon>(); foreach (DataRow dr in dt.Rows) { ChiTietHoaDon chiTietHoaDon = new ChiTietHoaDon(); chiTietHoaDon.MaHoaDon = (int)dr["MaHoaDon"]; chiTietHoaDon.MaSach = (int)dr["MaSach"]; chiTietHoaDon.SoLuongMua = (int)dr["SoLuongMua"]; lstChiTietHoaDon.Add(chiTietHoaDon); } return(lstChiTietHoaDon); }
public static ChiTietHoaDon GetBillDetail(ChiTietHoaDon detail) { provider = new DataProvider(); provider.Connect(); string cmdStr = "Execute proc_GetBillDetail " + detail.MaHoaDon + ", N'" + detail.TenMon + "'"; SqlDataReader reader = provider.ExecuteReader(cmdStr); ChiTietHoaDon cthd = null; if (reader.Read()) { cthd = new ChiTietHoaDon { MaHoaDon = reader.GetInt32(0), TenMon = reader.GetString(1), SoLuong = reader.GetInt32(2), ThanhTien = reader.GetInt32(3) }; } provider.Disconnect(); return(cthd); }
public static int DeleteThietBi(ChiTietHoaDon cthd) { return(ExecuteQuery.DeleteRows(cthd.Mahd, "CTHoaDon")); }
public static int AddCTHD(ChiTietHoaDon cthd) { return(ExecuteQuery.AddRows(cthd.ToString(), "CTHoaDon")); }
public void AddCTHoaDon(ChiTietHoaDon cthd) { db.ChiTietHoaDons.Add(cthd); db.SaveChanges(); }