public List <ClassMHBanChay> GetAllThongTinTangDan() { using (CSDLQuanLyQuanAoDataContext db = new CSDLQuanLyQuanAoDataContext()) { return(db.ExecuteQuery <ClassMHBanChay>(" select hh.MaHangHoa,hh.TenHangHoa,cthd.GiaNhap,SUM(cthd.SoLuong) AS SLM,Sum(cthd.SoLuong*cthd.GiaNhap) as TongTien" + " FROM dbo.ChiTietHoaDon cthd " + " INNER join dbo.HangHoa hh ON hh.MaHangHoa = cthd.MaHangHoa " + " WHERE MaHoaDon IN(SELECT MaHoaDon FROM dbo.HoaDon) " + " GROUP BY hh.MaHangHoa, hh.TenHangHoa, cthd.GiaNhap " + " having SUM(cthd.SoLuong) > 0 " + " ORDER BY SLM asc ").ToList()); } }
public List <ClassMHBanChay> GetThongTinTheoNgayGiamDan(String tuNgay, String denNgay) { using (CSDLQuanLyQuanAoDataContext db = new CSDLQuanLyQuanAoDataContext()) { return(db.ExecuteQuery <ClassMHBanChay>(" select hh.MaHangHoa,hh.TenHangHoa,cthd.GiaNhap,SUM(cthd.SoLuong) AS SLM,Sum(cthd.SoLuong*cthd.GiaNhap) as TongTien" + " FROM dbo.ChiTietHoaDon cthd " + " INNER join dbo.HangHoa hh ON hh.MaHangHoa = cthd.MaHangHoa " + " WHERE MaHoaDon IN(SELECT MaHoaDon FROM dbo.HoaDon " + " WHERE NgayLapHoaDon BETWEEN '" + tuNgay + "' AND'" + denNgay + "'" + ") " + " GROUP BY hh.MaHangHoa, hh.TenHangHoa, cthd.GiaNhap " + " having SUM(cthd.SoLuong) > 0 " + " ORDER BY SLM DESC ").ToList()); } }