123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384 |
- 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 EMIS.CommonLogic.SystemServices;
- using EMIS.CommonLogic.CalendarManage;
- namespace EMIS.Web.Controllers.TeachingMaterial
- {
- [Authorization]
- public class StockOutController : Controller
- {
- public IStockOutServices StockOutServices { get; set; }
- public ISerialNumberServices SerialNumberServices { get; set; }//编号生成
- public IStockInDetailServices StockInDetailServices { get; set; }
- public IStockInServices StockInServices { 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;
- DateTime? startStockInTime = DateTime.Now;
- DateTime? endStockInTime = DateTime.Now;
- supplierID = pararms.getExtraGuid("SupplierDropdown");//书库ID
- schoolyearID = pararms.getExtraGuid("SchoolYearDropdown");//学年
- //startStockInTime = Convert.ToDateTime(Request.Form["EndStockInTime"]);
- endStockInTime = pararms.getExtraDateTime("EndStockInTime");
- startStockInTime = pararms.getExtraDateTime("StartStockInTime");
- return base.Json(StockOutServices.GetStockOutViewGrid(configuretView, schoolyearID,
- new List<int> { (int)CF_StockOutType.StudentBook, (int)CF_StockOutType.TeacherBook },
- supplierID, startStockInTime, endStockInTime, (int)pararms.page, (int)pararms.rows));
- }
- public ActionResult RefundList()
- {
- var schoolYear = SchoolYearServices.GetSchoolYearIsCurrent(true);
- ViewBag.SchoolYearID = schoolYear == null ? "-1" : schoolYear.SchoolyearID.ToString();//默认当前学年
- return View();
- }
- [HttpPost]
- public ActionResult RefundList(QueryParamsModel pararms)
- {
- ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
- //避开全选值
- Guid? supplierID = null;
- Guid? schoolyearID = null;
- DateTime? startStockInTime = DateTime.Now;
- DateTime? endStockInTime = DateTime.Now;
- supplierID = pararms.getExtraGuid("SupplierDropdown");//书库ID
- schoolyearID = pararms.getExtraGuid("SchoolYearDropdown");//学年
- //startStockInTime = Convert.ToDateTime(Request.Form["EndStockInTime"]);
- endStockInTime = pararms.getExtraDateTime("EndStockInTime");
- startStockInTime = pararms.getExtraDateTime("StartStockInTime");
- return base.Json(StockOutServices.GetStockOutViewGrid(configuretView, schoolyearID,
- new List<int> { (int)CF_StockOutType.Refund },
- supplierID, startStockInTime, endStockInTime, (int)pararms.page, (int)pararms.rows));
- }
- /// <summary>
- ///
- /// </summary>
- /// <param name="stockOutID"></param>
- /// <returns></returns>
- [HttpGet]
- public ActionResult Edit(Guid? stockOutID)
- {
- var schoolYear = SchoolYearServices.GetSchoolYearIsCurrent(true);
- StockOutView stockOutView = new StockOutView();
- if (stockOutID != null && stockOutID != Guid.Empty)
- {
- stockOutView = StockOutServices.GetSingleStockOut(stockOutID.Value);
- }
- else
- {
- var stockOutType = Convert.ToInt32(Request.Params["stockOutType"]);//获取出库类型
- stockOutView = new StockOutView()
- {
- StockOutID = Guid.Empty,
- OutNumber = 1,
- StockOutTypeID = stockOutType,
- StockOutNo = StockOutServices.GetStockOutNo((CF_StockOutType)stockOutType),
- SchoolyearID = schoolYear.SchoolyearID,
- StockOutTime = DateTime.Now
- };
- }
- return View(stockOutView);
- }
- /// <summary>
- ///
- /// </summary>
- /// <param name="stockOutView"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult Edit(StockOutView stockOutView)
- {
- try
- {
- string type = Request.Params["hid_ActionsType"];//0 保存 1 提交
- string time = DateTime.Now.ToString("yyyyMMdd");
- var user = HttpContext.User as EMIS.Utility.FormValidate.CustomPrincipal;
- var TMList = DataGrid.GetTableData<TeachingMaterialPoolView>("dgStockInTMSelectList");//获取底部列表项数据
- string keyValue = SerialNumberServices.SetSN(time);//格式: 2016-3-25-001
- if (TMList.Count <= 0)
- {
- return Json(new ReturnMessage()
- {
- IsSuccess = false,
- Message = "保存失败,原因:教材信息不能为空。"
- });
- }
- else
- {
- StockOutServices.Save(stockOutView, TMList, user.UserID, type);
- }
- return Json(new ReturnMessage()
- {
- IsSuccess = true,
- Message = "保存成功。"
- });
- }
- catch (Exception ex)
- {
- return Json(new ReturnMessage()
- {
- IsSuccess = false,
- Message = "保存失败,原因:" + ex.Message
- });
- }
- }
- /// <summary>
- /// Excel 导出
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- public ActionResult Excel()
- {
- NpoiExcelHelper neh = new NpoiExcelHelper();
- ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
- Guid? libraryID = null;
- Guid? schoolyearID = null;
- libraryID = Request.Form["LibraryDropdown"].ParseStrTo<Guid>();
- schoolyearID = Request.Form["SchoolYearDropdown"].ParseStrTo<Guid>();
- DateTime? startStockInTime = DateTime.Now;
- DateTime? endStockInTime = DateTime.Now;
- endStockInTime = DateTime.Parse(Request.Form["EndStockInTime"]);
- startStockInTime = DateTime.Parse(Request.Form["StartStockInTime"]);
- var dt = StockOutServices.GetStockOutViewList(configuretView, schoolyearID, new List<int> { (int)CF_StockOutType.StudentBook, (int)CF_StockOutType.TeacherBook }, libraryID, startStockInTime, endStockInTime).Select(x => new
- {
- x.StockOutNo,
- x.SchoolyearName,
- // x.LibraryName,
- x.StockOutTypeName,
- x.StockOutSumMoney,
- x.RecipientUserName,
- x.StockOutUserName,
- x.StockOutTime,
- x.Desc
- }).ToTable();
- string[] liststring = { "出库单据号", "学年学期", "出库类型", "单据总金额", "签收人", "经手人", "领书日期", "领书说明" };
- neh.Export(dt, liststring, "出库管理信息");
- return RedirectToAction("MsgShow", "Common", new
- {
- msg = "导出成功!",
- url = Url.Content("~/StockOut/List").AddMenuParameter()
- });
- }
- /// <summary>
- /// 删除
- /// </summary>
- /// <param name="roleID"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult Delete(string stockOutIDs)
- {
- try
- {
- var stockOutIDList = stockOutIDs.Split(',').Select(x => (Guid)new Guid(x)).ToList();
- StockOutServices.Delete(stockOutIDList);
- return base.Json("删除成功。");
- }
- catch (Exception ex)
- {
- string mge = ex.Message;
- return base.Json("删除失败,原因:" + mge);
- }
- }
- /// <summary>
- /// 个人领书明细
- /// </summary>
- /// <param name="stockOutID"></param>
- /// <returns></returns>
- [HttpGet]
- public ActionResult StockOutDetailList(string stockOutID)
- {
- if (!string.IsNullOrEmpty(stockOutID))
- ViewData["stockOutID"] = stockOutID;
- return View();
- }
- /// <summary>
- /// 个人领书明细查询
- /// </summary>
- /// <param name="pararms"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult StockOutDetailList(QueryParamsModel pararms)
- {
- ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
- Guid? stockOutId = Request["stockOutId"].ParseStrTo<Guid>();
- return base.Json(StockOutServices.GetStockOutDetailViewGrid(stockOutId, (int)pararms.page, (int)pararms.rows));
- }
- /// <summary>
- /// Excel 导出
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- public ActionResult StockOutDetailExcel(Guid? stockOutId)
- {
- NpoiExcelHelper neh = new NpoiExcelHelper();
- ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
- var dt = StockOutServices.GetStockOutDetailViewList(stockOutId).Select(x => new
- {
- x.SchoolyearName,
- x.StockOutNo,
- x.GetBookNo,
- x.TeachingMaterialCode,
- x.TeachingMaterialName,
- x.PublishName,
- SupplierName = x.PublishName,
- x.PublishTime,
- x.Author,
- x.Quantity,
- x.Price,
- x.DiscountStr,
- x.DiscountPriceStr,
- x.TotalPriceStr,
- x.TotalDollarStr,
- x.RecipientUserName,
- x.StockOutUserName,
- StockOutTime = x.StockOutTime.Value.ToString("yyyy-MM-dd"),
- x.Desc
- }).ToTable();
- string[] liststring = { "学年学期", "出库单据号","领书人", "教材编号", "教材名称", "供应商",
- "出版单位", "版本时间", "作者", "数量", "单价", "折扣率", "折合价", "码洋", "总价", "签收人","经手人", "出库日期", "出库说明" };
- neh.Export(dt, liststring, "出库明细信息");
- return RedirectToAction("MsgShow", "Common", new
- {
- msg = "导出成功!",
- url = Url.Content("~/StockOut/StockOutDetailList").AddMenuParameter()
- });
- }
- /// <summary>
- /// 教材信息明细
- /// </summary>
- /// <param name="stockOutID"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult GetTMViewList(Guid? stockOutID)
- {
- if (stockOutID.HasValue)
- {
- var resultList = StockOutServices.GetStockOutByTMViewList(stockOutID.Value);
- return Json(new JsonDataGridResult<TeachingMaterialPoolView> { rows = resultList, total = resultList.Count });
- }
- else
- {
- return Json(new JsonDataGridResult<TeachingMaterialPoolView>());
- }
- }
- /// <summary>
- /// 提交
- /// </summary>
- /// <param name="roleID"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult Submit(string stockOutIDs)
- {
- try
- {
- var user = HttpContext.User as EMIS.Utility.FormValidate.CustomPrincipal;
- var stockOutIDList = stockOutIDs.Split(',').Select(x => (Guid)new Guid(x)).ToList();
- StockOutServices.Submit(stockOutIDList, user.UserID);
- return base.Json("提交出库成功。");
- }
- catch (Exception ex)
- {
- string mge = ex.Message;
- return base.Json("提交出库失败,原因:" + mge);
- }
- }
- /// <summary>
- /// 添加教材
- /// </summary>
- /// <returns></returns>
- public ActionResult TeachingMaterial()
- {
- return View();
- }
- /// <summary>
- ///
- /// </summary>
- /// <returns></returns>
- [HttpGet]
- public ActionResult GetStockOutByTMList()
- {
- return View();
- }
- [HttpPost]
- public ActionResult GetStockOutByTMList(QueryParamsModel pararms)
- {
- ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
- bool? isLate = false;
- var teachingMaterialPoolID = pararms.getExtraGuid("TeachingMaterialDropdown");
- var coursematerialID = pararms.getExtraGuid("CourseDropdown");
- Guid? publishID = pararms.getExtraGuid("PublishDropdown");
- var schoolyearID = pararms.getExtraGuid("SchoolyearID");
- var isSelectMax = pararms.getExtraInt("hidIsSelectMax") == 1;
- // if (configuretView.Attribute == DropdownList.SELECT_ALL.ToString()) configuretView.Attribute = "";
- return base.Json(StockOutServices.GetStockInByTeachingMaterialPoolViewGrid(configuretView, isLate, teachingMaterialPoolID, coursematerialID, isSelectMax, (int)pararms.page, (int)pararms.rows));
- }
- [HttpGet]
- public ActionResult RefundListTeachingMaterial()
- {
- return View();
- }
- [HttpPost]
- public ActionResult GetTeachingMaterialForRefund(QueryParamsModel pararms)
- {
- ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
- bool? isLate = false;
- var teachingMaterialPoolID = pararms.getExtraGuid("TeachingMaterialDropdown");
- var coursematerialID = pararms.getExtraGuid("CourseDropdown");
- Guid? publishID = pararms.getExtraGuid("PublishDropdown");
- var schoolyearID = pararms.getExtraGuid("SchoolyearID");
- var isSelectMax = pararms.getExtraInt("hidIsSelectMax") == 1;
- // if (configuretView.Attribute == DropdownList.SELECT_ALL.ToString()) configuretView.Attribute = "";
- return base.Json(StockOutServices.GetTeachingMaterialViewForRefundGrid(configuretView, isLate, teachingMaterialPoolID, coursematerialID, isSelectMax, (int)pararms.page, (int)pararms.rows));
- }
- }
- }
|