123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.Mvc;
- using Bowin.Common.Utility;
- using Bowin.Web.Controls.Mvc;
- using EMIS.CommonLogic.TeachingMaterial;
- using EMIS.ViewModel;
- using EMIS.ViewModel.TeachingMaterial;
- using EMIS.Web.Controls;
- using Bowin.Common.Data;
- using System.Data;
- using EMIS.CommonLogic.CalendarManage;
- namespace EMIS.Web.Controllers.TeachingMaterial
- {
- public class StockInStatisticsController : Controller
- {
- public IStockInDetailServices StockInDetailServices { get; set; }
- public ISchoolYearServices SchoolYearServices { get; set; }
- /// <summary>
- /// 入库统计页面
- /// </summary>
- /// <returns></returns>
- [HttpGet]
- public ActionResult List()
- {
- //默认当前学年
- var schoolYear = SchoolYearServices.GetSchoolYearIsCurrent(true);
- ViewBag.SchoolYearID = schoolYear == null ? "-1" : schoolYear.SchoolyearID.ToString();
- return View();
- }
- [HttpPost]
- public ActionResult List(QueryParamsModel pararms)
- {
- ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
- //避开全选值
- Guid? supplierID = null;
- Guid? schoolyearID = null;
- Guid? teachingMaterialID = null;
- supplierID = pararms.getExtraGuid("PublishDropdown");
- schoolyearID = pararms.getExtraGuid("SchoolYearDropdown");
- teachingMaterialID = pararms.getExtraGuid("TeachingMaterialDropdown");
- return base.Json(StockInDetailServices.GetStockInStatisticsViewGrid(configuretView, schoolyearID, supplierID, teachingMaterialID, (int)pararms.page, (int)pararms.rows));
- }
- #region 2.0 页面数据Excel导出
- /// <summary>
- /// Excel 导出
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- public ActionResult Excel()
- {
- NpoiExcelHelper neh = new NpoiExcelHelper();
- ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
- Guid? supplierID = null;
- Guid? schoolyearID = null;
- Guid? teachingMaterialID = null;
- supplierID = Request.Form["PublishDropdown"].ParseStrTo<Guid>();
- schoolyearID = Request.Form["SchoolYearDropdown"].ParseStrTo<Guid>();
- teachingMaterialID = Request.Form["TeachingMaterialDropdown"].ParseStrTo<Guid>();
- var dt = StockInDetailServices.GetStockInStatisticsVieList(configuretView, schoolyearID, supplierID, teachingMaterialID).Select(x => new
- {
- x.SchoolyearName,
- //x.StockInDocumentNo,
- //x.StockInType,
- x.TeachingMaterialCode,
- x.TeachingMaterialName,
- x.SupplierName,
- x.PublishName,
- x.PublishTime,
- x.Author,
- x.Quantity,
- x.Price,
- x.DiscountStr,
- x.DiscountPriceStr,
- x.TotalPriceStr,
- x.TotalDollarStr
- //x.HandlerUserName,
- //x.StockInUserName,
- //x.StockInTime
- }).ToTable();
- int sumQuantity = 0;
- decimal sumTotalPrice = 0;
- decimal sumTotalDollar = 0;
- foreach(DataRow dr in dt.Rows)
- {
- int quantity = (int)dr["Quantity"];
- decimal totalPrice = (decimal)dr["TotalPriceStr"];
- decimal totalDollar = (decimal)dr["TotalDollarStr"];
- sumQuantity += quantity;
- sumTotalPrice += totalPrice;
- sumTotalDollar += totalDollar;
- }
- //新增合计数量、码洋、实洋的行
- DataRow newrow = dt.NewRow();
- newrow["SchoolyearName"] = "";
- newrow["TeachingMaterialCode"] = "";
- newrow["TeachingMaterialName"] = "";
- newrow["SupplierName"] = "";
- newrow["PublishName"] = "";
- newrow["PublishTime"] = "";
- newrow["Author"] = "";
- newrow["Quantity"] = sumQuantity;
- newrow["Price"] = DBNull.Value;
- newrow["DiscountStr"] = DBNull.Value;
- newrow["DiscountPriceStr"] = DBNull.Value;
- newrow["TotalPriceStr"] = sumTotalPrice;
- newrow["TotalDollarStr"] = sumTotalDollar;
- dt.Rows.Add(newrow);
- string[] liststring = { "学年学期", "教材编号", "教材名称", "供应商",
- "出版单位", "版本时间", "作者", "数量", "单价", "折扣率", "折合价", "码洋", "实洋" };
- neh.Export(dt, liststring, "入库明细信息");
- return RedirectToAction("MsgShow", "Common", new
- {
- msg = "导出成功!",
- url = Url.Content("~/StockInDetail/List").AddMenuParameter()
- });
- }
- #endregion
- }
- }
|