public ActionResult XuliBaoCaoSanLuongDoanhThu(FormCollection form, int type) { int month = String.IsNullOrEmpty(form["m1"]) ? DateTime.Now.Month : Convert.ToInt32(form["m1"]); int year = String.IsNullOrEmpty(form["y1"]) ? DateTime.Now.Year : Convert.ToInt32(form["y1"]); ControllerBase <BaoCaoSanLuongDoanhThu> cB = new ControllerBase <BaoCaoSanLuongDoanhThu>(); //type = 0 => quận if (type == 0) { int quanHuyenID = String.IsNullOrEmpty(form["quan"]) ? 0 : Convert.ToInt32(form["quan"]); if (quanHuyenID == 0) { BaoCaoSanLuongDoanhThu bc = cB.Query("BaoCaoSanLuongKinhDoanhTaiVu", new SqlParameter("@thang", month), new SqlParameter("@nam", year)).First(); ViewData["baoCaoSanLuongDoanhThu"] = bc; } else { BaoCaoSanLuongDoanhThu bc = cB.Query("BaoCaoSanLuongKinhDoanhTaiVuTheoQuan", new SqlParameter("@thang", month), new SqlParameter("@nam", year), new SqlParameter("@quan", quanHuyenID), new SqlParameter("@d2", 0.05)).First(); ViewData["baoCaoSanLuongDoanhThu"] = bc; } ViewBag.tenQuanHuyen = baoCaoSanLuongDoanhThu.getTieuDeSanLuongDoanhThu(quanHuyenID); } //type = 1 => tuyến if (type == 1) { String dsTuyen = !String.IsNullOrEmpty(form["tuyen"]) ? form["tuyen"] : ""; BaoCaoSanLuongDoanhThu bc = cB.Query("BaoCaoSanLuongKinhDoanhTaiVuTheoTuyen", new SqlParameter("@thang", month), new SqlParameter("@nam", year), new SqlParameter("@d2", 0.05), new SqlParameter("@list", dsTuyen)).FirstOrDefault(); ViewData["baoCaoSanLuongDoanhThu"] = bc; ViewBag.tenQuanHuyen = baoCaoSanLuongDoanhThu.getTieuDeSanLuongDoanhThu(0); if (String.IsNullOrEmpty(dsTuyen)) { ViewBag.selectedTuyens = "Tất cả các tuyến"; } else { ViewBag.selectedTuyens = "Tuyến " + tuyenHelper.translateTuyenIDToMaTuyen(dsTuyen); } } ViewBag.selectedMonth = month.ToString(); ViewBag.selectedYear = year.ToString(); return(View()); }
public ActionResult XuLiBaoCaoSanLuongDoanhThuTheoQuy(FormCollection form, int type) { int quy = !String.IsNullOrEmpty(form["q1"]) ? Convert.ToInt32(form["q1"]) : 0; int nam = !String.IsNullOrEmpty(form["y1"]) ? Convert.ToInt32(form["y1"]) : 0; String thangTrongQuy = TimeHelper.getThangTrongQuy(quy); ControllerBase <BaoCaoSanLuongDoanhThu> cB = new ControllerBase <BaoCaoSanLuongDoanhThu>(); if (type == 0) { int quanHuyenID = String.IsNullOrEmpty(form["quan"]) ? 0 : Convert.ToInt32(form["quan"]); BaoCaoSanLuongDoanhThu bc = cB.Query("BaoCaoSanLuongKinhDoanhTaiVuTheoQuanTheoQuy", new SqlParameter("@nam", nam), new SqlParameter("@quan", quanHuyenID), new SqlParameter("@d2", 0.05), new SqlParameter("@list", thangTrongQuy)).First(); ViewData["baoCaoSanLuongDoanhThu"] = bc; ViewBag.tenQuanHuyen = baoCaoSanLuongDoanhThu.getTieuDeSanLuongDoanhThu(quanHuyenID); } else { String tuyens = !String.IsNullOrEmpty(form["tuyen"]) ? form["tuyen"] : ""; BaoCaoSanLuongDoanhThu bc = cB.Query("BaoCaoSanLuongKinhDoanhTaiVuTheoTuyenTheoQuy", new SqlParameter("@nam", nam), new SqlParameter("@d2", 0.05), new SqlParameter("@list", thangTrongQuy), new SqlParameter("@listTuyen", tuyens)).First(); ViewData["baoCaoSanLuongDoanhThu"] = bc; ViewBag.tenQuanHuyen = baoCaoSanLuongDoanhThu.getTieuDeSanLuongDoanhThu(0); if (String.IsNullOrEmpty(tuyens)) { ViewBag.selectedTuyens = "Tất cả các tuyến"; } else { ViewBag.selectedTuyens = "Tuyến " + tuyenHelper.translateTuyenIDToMaTuyen(tuyens); } } ViewBag.selectedMonth = "Quý " + quy; ViewBag.selectedYear = nam.ToString(); return(View("XuliBaoCaoSanLuongDoanhThu")); }
//Báo cáo sản lượng doanh thu theo từng mức áp giá theo từng tháng public ActionResult BaoCaoSanLuongDoanhThu() { List <BaoCaoSanLuongDoanhThu> lstBCSL = new List <BaoCaoSanLuongDoanhThu>(); BaoCaoSanLuongDoanhThu tong = new BaoCaoSanLuongDoanhThu() { SanLuong = 0, DoanhThuTruocThue = 0, VAT = 0, PhiNuocThai = 0, TongCong = 0 }; foreach (var apgia in db.Apgias.OrderBy(p => p.ApgiaID).ToList()) { BaoCaoSanLuongDoanhThu bcsl = new Models.BaoCaoSanLuongDoanhThu(); bcsl.STT = apgia.ApgiaID; bcsl.CacMuc = apgia.Ten; switch (bcsl.CacMuc) { case "SH1": { bcsl.SanLuong = db.Chitiethoadonnuocs.Sum(c => c.SH1); bcsl.DoanhThuTruocThue = bcsl.SanLuong * 2500; break; } case "SH2": { bcsl.SanLuong = db.Chitiethoadonnuocs.Sum(c => c.SH2); bcsl.DoanhThuTruocThue = bcsl.SanLuong * 3000; break; } case "SH3": { bcsl.SanLuong = db.Chitiethoadonnuocs.Sum(c => c.SH3); bcsl.DoanhThuTruocThue = bcsl.SanLuong * 4000; break; } case "SH4": { bcsl.SanLuong = db.Chitiethoadonnuocs.Sum(c => c.SH4); bcsl.DoanhThuTruocThue = bcsl.SanLuong * 4500; break; } case "SX - XD": { bcsl.SanLuong = db.Chitiethoadonnuocs.Sum(c => c.SXXD); bcsl.DoanhThuTruocThue = bcsl.SanLuong * 5000; break; } case "CC": { bcsl.SanLuong = db.Chitiethoadonnuocs.Sum(c => c.CC); bcsl.DoanhThuTruocThue = bcsl.SanLuong * 3500; break; } case "HC": { bcsl.SanLuong = db.Chitiethoadonnuocs.Sum(c => c.HC); bcsl.DoanhThuTruocThue = bcsl.SanLuong * 4000; break; } case "KD-DV": { bcsl.SanLuong = db.Chitiethoadonnuocs.Sum(c => c.KDDV); bcsl.DoanhThuTruocThue = bcsl.SanLuong * 8500; break; } } bcsl.VAT = bcsl.DoanhThuTruocThue * 10 / 100; bcsl.PhiNuocThai = 0; bcsl.TongCong = bcsl.DoanhThuTruocThue + bcsl.PhiNuocThai + bcsl.VAT; //add vao list bao cao tong hop lstBCSL.Add(bcsl); // cong don gia tri vao tong tong.SanLuong += bcsl.SanLuong; tong.DoanhThuTruocThue += bcsl.DoanhThuTruocThue; tong.VAT += bcsl.VAT; tong.PhiNuocThai += bcsl.PhiNuocThai; tong.TongCong += bcsl.TongCong; } ViewBag.bcsl = lstBCSL; ViewBag.tong = tong; return(View()); }