123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273 |
- 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 TeacherRetailController : 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("LibraryDropdown");//书库ID
- schoolyearID = pararms.getExtraGuid("SchoolYearDropdown");//学年
- endStockInTime = pararms.getExtraDateTime("EndStockInTime");
- startStockInTime = pararms.getExtraDateTime("StartStockInTime");
- return base.Json(StockOutServices.GetStockOutViewGrid(configuretView, schoolyearID, new List<int> { (int)CF_StockOutType.TeachingMaterialRetail }, 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
- {
- stockOutView = new StockOutView()
- {
- OutNumber = 1,
- StockOutID = Guid.Empty,
- StockOutNo = StockOutServices.GetStockOutNo(CF_StockOutType.TeachingMaterialRetail),
- 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("yyyy-MM-dd");
- 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? supplierID = null;
- Guid? schoolyearID = null;
- supplierID = Request.Form["SupplierDropdown"].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.TeachingMaterialRetail }, supplierID, startStockInTime, endStockInTime).Select(x => new
- {
- x.StockOutNo,
- x.RecordStatusName,
- x.SchoolyearName,
- 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("~/TeacherRetail/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>
- /// <returns></returns>
- public ActionResult TeachingMaterial()
- {
- return View();
- }
- /// <summary>
- ///
- /// </summary>
- /// <returns></returns>
- [HttpGet]
- public ActionResult GetStockOutByTMList()
- {
- return View();
- }
- /// <summary>
- ///
- /// </summary>
- /// <param name="pararms"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult GetStockOutByTMList(QueryParamsModel pararms)
- {
- ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
- //避开全选值
- Guid? publishID = null;
- Guid? coursematerialID = null;
- bool? isLate = false;
- var teachingMaterialPoolID = pararms.getExtraGuid("TeachingMaterialDropdown");
- publishID = pararms.getExtraGuid("PublishDropdown");
- coursematerialID = pararms.getExtraGuid("CourseDropdown");
- var isSelectMax = pararms.getExtraInt("hidIsSelectMax") == 1;
- return base.Json(StockOutServices.GetStockInByTeachingMaterialPoolViewGrid(configuretView, isLate, teachingMaterialPoolID, coursematerialID, isSelectMax, (int)pararms.page, (int)pararms.rows));
- }
- /// <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);
- }
- }
- }
- }
|