public IQueryable <BOPrintOrderItem> GetPrintOrderItemKM(int lichsuBanHang, BOPrintOrderItem item, int printID) { var queryCheck = from a in mKaraokeEntities.MENUMONs join b in mKaraokeEntities.MENUITEMMAYINs on a.MonID equals b.MonID where b.MayInID == printID select a; var queryChiTiet = from ct in mKaraokeEntities.CHITIETLICHSUBANHANGs where ct.KichThuocMonID_Ref == item.MonID && ct.LichSuBanHangID == lichsuBanHang select ct; var query = from a in mKaraokeEntities.MENUMONs join b in mKaraokeEntities.MENUKICHTHUOCMONs on a.MonID equals b.MonID join c in queryChiTiet on b.KichThuocMonID equals c.KichThuocMonID where queryCheck.Contains(a) select new { DonViID = b.DonViID, KichThuocThuc = c.KichThuocLoaiBan, KichThuocBan = b.KichThuocLoaiBan, MonID = b.KichThuocMonID, TenDai = a.TenDai, TenLoaiBan = b.TenLoaiBan, SoLuong = (int)c.SoLuong, TrangThai = (int)c.TrangThai } into x group x by new { x.MonID, x.TenDai, x.TenLoaiBan, x.TrangThai, x.DonViID, x.KichThuocThuc, x.KichThuocBan } into y select new BOPrintOrderItem { DonViID = y.Key.DonViID.Value, KichThuocThuc = y.Key.KichThuocThuc, KichThuocBan = y.Key.KichThuocBan, MonID = y.Key.MonID, TenDai = y.Key.TenDai, TenLoaiBan = y.Key.TenLoaiBan, TrangThai = (int)y.Key.TrangThai, SoLuong = y.Sum(c => c.SoLuong) } ; return(query); }
public IQueryable <BOPrintOrderItem> GetPrintOrderItemKM(int banHangID, BOPrintOrderItem item) { var query = from a in mKaraokeEntities.CHITIETBANHANGs.Where(o => o.KichThuocMonID_Ref == item.MonID && o.BanHangID == banHangID) join b in mKaraokeEntities.MENUKICHTHUOCMONs on a.KichThuocMonID equals b.KichThuocMonID join c in mKaraokeEntities.MENUMONs on b.MonID equals c.MonID select new { DonViID = b.DonViID, KichThuocThuc = a.KichThuocLoaiBan, KichThuocBan = b.KichThuocLoaiBan, MonID = b.KichThuocMonID, TenDai = c.TenDai, TenLoaiBan = b.TenLoaiBan, GiamGia = a.GiamGia, GiaBan = a.GiaBan, SoLuong = (int)a.SoLuongBan, ThanhTien = (decimal)a.ThanhTien } into x group x by new { x.MonID, x.TenDai, x.TenLoaiBan, x.GiaBan, x.GiamGia, x.DonViID, x.KichThuocThuc, x.KichThuocBan } into y select new BOPrintOrderItem { DonViID = y.Key.DonViID.Value, KichThuocThuc = y.Key.KichThuocThuc, KichThuocBan = y.Key.KichThuocBan, MonID = y.Key.MonID, TenDai = y.Key.TenDai, TenLoaiBan = y.Key.TenLoaiBan, SoLuong = y.Sum(c => c.SoLuong), GiaBan = y.Key.GiaBan, GiamGia = y.Key.GiamGia, ThanhTien = y.Sum(c => c.ThanhTien) }; return(query); }
public IQueryable<BOPrintOrderItem> GetPrintOrderItemKM(int lichsuBanHang,BOPrintOrderItem item, int printID) { var queryCheck = from a in mKaraokeEntities.MENUMONs join b in mKaraokeEntities.MENUITEMMAYINs on a.MonID equals b.MonID where b.MayInID == printID select a; var queryChiTiet = from ct in mKaraokeEntities.CHITIETLICHSUBANHANGs where ct.KichThuocMonID_Ref == item.MonID && ct.LichSuBanHangID==lichsuBanHang select ct; var query = from a in mKaraokeEntities.MENUMONs join b in mKaraokeEntities.MENUKICHTHUOCMONs on a.MonID equals b.MonID join c in queryChiTiet on b.KichThuocMonID equals c.KichThuocMonID where queryCheck.Contains(a) select new { DonViID = b.DonViID, KichThuocThuc = c.KichThuocLoaiBan, KichThuocBan = b.KichThuocLoaiBan, MonID = b.KichThuocMonID, TenDai = a.TenDai, TenLoaiBan = b.TenLoaiBan, SoLuong = (int)c.SoLuong, TrangThai = (int)c.TrangThai } into x group x by new { x.MonID, x.TenDai, x.TenLoaiBan, x.TrangThai, x.DonViID, x.KichThuocThuc, x.KichThuocBan } into y select new BOPrintOrderItem { DonViID = y.Key.DonViID.Value, KichThuocThuc = y.Key.KichThuocThuc, KichThuocBan = y.Key.KichThuocBan, MonID=y.Key.MonID, TenDai=y.Key.TenDai, TenLoaiBan=y.Key.TenLoaiBan, TrangThai = (int)y.Key.TrangThai, SoLuong = y.Sum(c => c.SoLuong) } ; return query; }
public IQueryable<BOPrintOrderItem> GetPrintOrderItemKM(int banHangID,BOPrintOrderItem item) { var query = from a in mKaraokeEntities.CHITIETBANHANGs.Where(o => o.KichThuocMonID_Ref == item.MonID && o.BanHangID==banHangID) join b in mKaraokeEntities.MENUKICHTHUOCMONs on a.KichThuocMonID equals b.KichThuocMonID join c in mKaraokeEntities.MENUMONs on b.MonID equals c.MonID select new { DonViID = b.DonViID, KichThuocThuc = a.KichThuocLoaiBan, KichThuocBan = b.KichThuocLoaiBan, MonID = b.KichThuocMonID, TenDai = c.TenDai, TenLoaiBan = b.TenLoaiBan, GiamGia = a.GiamGia, GiaBan = a.GiaBan, SoLuong = (int)a.SoLuongBan, ThanhTien = (decimal)a.ThanhTien } into x group x by new {x.MonID, x.TenDai, x.TenLoaiBan, x.GiaBan, x.GiamGia,x.DonViID,x.KichThuocThuc,x.KichThuocBan } into y select new BOPrintOrderItem { DonViID = y.Key.DonViID.Value, KichThuocThuc = y.Key.KichThuocThuc, KichThuocBan = y.Key.KichThuocBan, MonID = y.Key.MonID, TenDai=y.Key.TenDai, TenLoaiBan=y.Key.TenLoaiBan, SoLuong = y.Sum(c => c.SoLuong), GiaBan = y.Key.GiaBan, GiamGia = y.Key.GiamGia, ThanhTien = y.Sum(c => c.ThanhTien) }; return query; }