public ActionResult DocumentViewerPartialExport() { TempData.Keep("tukhoa"); TempData.Keep("tungay"); TempData.Keep("dengay"); ThongKeSanPham report = new ThongKeSanPham(TempData["tukhoa"].ToString(), TempData["tungay"].ToString(), TempData["denngay"].ToString()); return(DocumentViewerExtension.ExportTo(report, Request)); }
public ActionResult DocumentViewerPartial() { TempData.Keep("tukhoa"); TempData.Keep("tungay"); TempData.Keep("denngay"); ThongKeSanPham report = new ThongKeSanPham(TempData["tukhoa"].ToString(), TempData["tungay"].ToString(), TempData["denngay"].ToString()); return(PartialView("_DocumentViewerPartial", report)); }
public ActionResult ThongKeSanPham() { List <ThongKeSanPham> lstSP = new List <ThongKeSanPham>(); var result = db.ChiTietHDs.GroupBy(o => o.MASP) .Select(g => new { masp = g.Key, total = g.Sum(i => i.SOLUONG) }); foreach (var group in result) { SANPHAM sp = db.SANPHAMs.SingleOrDefault(n => n.MASP == group.masp); ThongKeSanPham tk = new ThongKeSanPham(); tk.maSP = group.masp; tk.tenSP = sp.TENSP; tk.soLuong = (int)group.total; tk.anhSP = sp.ANHSP; tk.size = sp.SIZE; tk.giaBan = (double)sp.GIABD; lstSP.Add(tk); } return(View(lstSP.OrderByDescending(m => m.soLuong).ToList())); }
void ThongKe() { chart1.Series[0].Points.Clear(); if (cbbThongKe.Text.ToString() == "Doanh Thu") { // Hien thi danh sach hoa don DataTable data = DataProvider.Instance.ExecuteQuery("exec USP_ThongKeBill @Date1 , @Date2", new object[] { DateTimeTu.Value.ToString("yyyy-MM-dd"), DateTimeDen.Value.ToString("yyyy-MM-dd") }); dtgThongKe.DataSource = data; // lay doanh thu theo ngay va ve bieu do List <DoanhThuNgay> listDoanhThu = new List <DoanhThuNgay>(); DataTable dataDoanhThu = DataProvider.Instance.ExecuteQuery("exec USP_BieuDoThongKeDoanhThu @Date1 , @Date2", new object[] { DateTimeTu.Value.ToString("yyyy-MM-dd"), DateTimeDen.Value.ToString("yyyy-MM-dd") }); foreach (DataRow row in dataDoanhThu.Rows) { DoanhThuNgay doanhThu = new DoanhThuNgay(row); listDoanhThu.Add(doanhThu); } chart1.Series[0].Name = "Doanh Thu (VNĐ)"; foreach (DoanhThuNgay item in listDoanhThu) { chart1.Series[0].Points.AddXY(item.Date.Value.ToString("yyyy-MM-dd"), (float)item.TotalPrice); } dataExportExcel = data; } else { List <ThongKeSanPham> listSanPham = new List <ThongKeSanPham>(); DataTable dataSanPham = DataProvider.Instance.ExecuteQuery("exec USP_ThongKeSanPham @Date1 , @Date2", new object[] { DateTimeTu.Value.ToString("yyyy-MM-dd"), DateTimeDen.Value.ToString("yyyy-MM-dd") }); dtgThongKe.DataSource = dataSanPham; foreach (DataRow row in dataSanPham.Rows) { ThongKeSanPham tkSanPham = new ThongKeSanPham(row); listSanPham.Add(tkSanPham); } chart1.Series[0].Name = "Số Lượng Đã Bán"; foreach (ThongKeSanPham item in listSanPham) { chart1.Series[0].Points.AddXY(item.TenSP.ToString(), item.DaBan); } dataExportExcel = dataSanPham; } try { string doanhThuNow = DataProvider.Instance.ExecuteScalar("select sum(totalPrice) from Bill where DateCheckIn = '" + DateTime.Now.ToString("yyyy-MM-dd") + "' group by DateCheckIn").ToString(); lblDoanhThu.Text = doanhThuNow.ToString() + " ₫"; string hoaDonNow = DataProvider.Instance.ExecuteScalar("select count(DateCheckIn) from Bill where DateCheckIn = '" + DateTime.Now.ToString("yyyy-MM-dd") + "'").ToString(); lblSLHoaDon.Text = hoaDonNow.ToString(); string daBanNow = DataProvider.Instance.ExecuteScalar("select sum(bi.count) from BillInfo as bi, Bill as b where DateCheckIn = '" + DateTime.Now.ToString("yyyy-MM-dd") + "' and bi.idBill = b.id group by b.DateCheckIn").ToString(); lblSLDaBan.Text = daBanNow.ToString(); } catch (Exception ex) { } }