StockOutController.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.Mvc;
  6. using Bowin.Common.Utility;
  7. using Bowin.Web.Controls.Mvc;
  8. using EMIS.CommonLogic.TeachingMaterial;
  9. using EMIS.ViewModel;
  10. using EMIS.ViewModel.TeachingMaterial;
  11. using EMIS.Web.Controls;
  12. using Bowin.Common.Data;
  13. using EMIS.CommonLogic.SystemServices;
  14. using EMIS.CommonLogic.CalendarManage;
  15. namespace EMIS.Web.Controllers.TeachingMaterial
  16. {
  17. [Authorization]
  18. public class StockOutController : Controller
  19. {
  20. public IStockOutServices StockOutServices { get; set; }
  21. public ISerialNumberServices SerialNumberServices { get; set; }//编号生成
  22. public IStockInDetailServices StockInDetailServices { get; set; }
  23. public IStockInServices StockInServices { get; set; }
  24. public ISchoolYearServices SchoolYearServices { get; set; }
  25. /// <summary>
  26. /// 个人领书页面
  27. /// </summary>
  28. /// <returns></returns>
  29. [HttpGet]
  30. public ActionResult List()
  31. {
  32. var schoolYear = SchoolYearServices.GetSchoolYearIsCurrent(true);
  33. ViewBag.SchoolYearID = schoolYear == null ? "-1" : schoolYear.SchoolyearID.ToString();//默认当前学年
  34. return View();
  35. }
  36. [HttpPost]
  37. public ActionResult List(QueryParamsModel pararms)
  38. {
  39. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  40. //避开全选值
  41. Guid? supplierID = null;
  42. Guid? schoolyearID = null;
  43. DateTime? startStockInTime = DateTime.Now;
  44. DateTime? endStockInTime = DateTime.Now;
  45. supplierID = pararms.getExtraGuid("SupplierDropdown");//书库ID
  46. schoolyearID = pararms.getExtraGuid("SchoolYearDropdown");//学年
  47. //startStockInTime = Convert.ToDateTime(Request.Form["EndStockInTime"]);
  48. endStockInTime = pararms.getExtraDateTime("EndStockInTime");
  49. startStockInTime = pararms.getExtraDateTime("StartStockInTime");
  50. return base.Json(StockOutServices.GetStockOutViewGrid(configuretView, schoolyearID,
  51. new List<int> { (int)CF_StockOutType.StudentBook, (int)CF_StockOutType.TeacherBook },
  52. supplierID, startStockInTime, endStockInTime, (int)pararms.page, (int)pararms.rows));
  53. }
  54. public ActionResult RefundList()
  55. {
  56. var schoolYear = SchoolYearServices.GetSchoolYearIsCurrent(true);
  57. ViewBag.SchoolYearID = schoolYear == null ? "-1" : schoolYear.SchoolyearID.ToString();//默认当前学年
  58. return View();
  59. }
  60. [HttpPost]
  61. public ActionResult RefundList(QueryParamsModel pararms)
  62. {
  63. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  64. //避开全选值
  65. Guid? supplierID = null;
  66. Guid? schoolyearID = null;
  67. DateTime? startStockInTime = DateTime.Now;
  68. DateTime? endStockInTime = DateTime.Now;
  69. supplierID = pararms.getExtraGuid("SupplierDropdown");//书库ID
  70. schoolyearID = pararms.getExtraGuid("SchoolYearDropdown");//学年
  71. //startStockInTime = Convert.ToDateTime(Request.Form["EndStockInTime"]);
  72. endStockInTime = pararms.getExtraDateTime("EndStockInTime");
  73. startStockInTime = pararms.getExtraDateTime("StartStockInTime");
  74. return base.Json(StockOutServices.GetStockOutViewGrid(configuretView, schoolyearID,
  75. new List<int> { (int)CF_StockOutType.Refund },
  76. supplierID, startStockInTime, endStockInTime, (int)pararms.page, (int)pararms.rows));
  77. }
  78. /// <summary>
  79. ///
  80. /// </summary>
  81. /// <param name="stockOutID"></param>
  82. /// <returns></returns>
  83. [HttpGet]
  84. public ActionResult Edit(Guid? stockOutID)
  85. {
  86. var schoolYear = SchoolYearServices.GetSchoolYearIsCurrent(true);
  87. StockOutView stockOutView = new StockOutView();
  88. if (stockOutID != null && stockOutID != Guid.Empty)
  89. {
  90. stockOutView = StockOutServices.GetSingleStockOut(stockOutID.Value);
  91. }
  92. else
  93. {
  94. var stockOutType = Convert.ToInt32(Request.Params["stockOutType"]);//获取出库类型
  95. stockOutView = new StockOutView()
  96. {
  97. StockOutID = Guid.Empty,
  98. OutNumber = 1,
  99. StockOutTypeID = stockOutType,
  100. StockOutNo = StockOutServices.GetStockOutNo((CF_StockOutType)stockOutType),
  101. SchoolyearID = schoolYear.SchoolyearID,
  102. StockOutTime = DateTime.Now
  103. };
  104. }
  105. return View(stockOutView);
  106. }
  107. /// <summary>
  108. ///
  109. /// </summary>
  110. /// <param name="stockOutView"></param>
  111. /// <returns></returns>
  112. [HttpPost]
  113. public ActionResult Edit(StockOutView stockOutView)
  114. {
  115. try
  116. {
  117. string type = Request.Params["hid_ActionsType"];//0 保存 1 提交
  118. string time = DateTime.Now.ToString("yyyyMMdd");
  119. var user = HttpContext.User as EMIS.Utility.FormValidate.CustomPrincipal;
  120. var TMList = DataGrid.GetTableData<TeachingMaterialPoolView>("dgStockInTMSelectList");//获取底部列表项数据
  121. string keyValue = SerialNumberServices.SetSN(time);//格式: 2016-3-25-001
  122. if (TMList.Count <= 0)
  123. {
  124. return Json(new ReturnMessage()
  125. {
  126. IsSuccess = false,
  127. Message = "保存失败,原因:教材信息不能为空。"
  128. });
  129. }
  130. else
  131. {
  132. StockOutServices.Save(stockOutView, TMList, user.UserID, type);
  133. }
  134. return Json(new ReturnMessage()
  135. {
  136. IsSuccess = true,
  137. Message = "保存成功。"
  138. });
  139. }
  140. catch (Exception ex)
  141. {
  142. return Json(new ReturnMessage()
  143. {
  144. IsSuccess = false,
  145. Message = "保存失败,原因:" + ex.Message
  146. });
  147. }
  148. }
  149. /// <summary>
  150. /// Excel 导出
  151. /// </summary>
  152. /// <returns></returns>
  153. [HttpPost]
  154. public ActionResult Excel()
  155. {
  156. NpoiExcelHelper neh = new NpoiExcelHelper();
  157. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
  158. Guid? libraryID = null;
  159. Guid? schoolyearID = null;
  160. libraryID = Request.Form["LibraryDropdown"].ParseStrTo<Guid>();
  161. schoolyearID = Request.Form["SchoolYearDropdown"].ParseStrTo<Guid>();
  162. DateTime? startStockInTime = DateTime.Now;
  163. DateTime? endStockInTime = DateTime.Now;
  164. endStockInTime = DateTime.Parse(Request.Form["EndStockInTime"]);
  165. startStockInTime = DateTime.Parse(Request.Form["StartStockInTime"]);
  166. var dt = StockOutServices.GetStockOutViewList(configuretView, schoolyearID, new List<int> { (int)CF_StockOutType.StudentBook, (int)CF_StockOutType.TeacherBook }, libraryID, startStockInTime, endStockInTime).Select(x => new
  167. {
  168. x.StockOutNo,
  169. x.SchoolyearName,
  170. // x.LibraryName,
  171. x.StockOutTypeName,
  172. x.StockOutSumMoney,
  173. x.RecipientUserName,
  174. x.StockOutUserName,
  175. x.StockOutTime,
  176. x.Desc
  177. }).ToTable();
  178. string[] liststring = { "出库单据号", "学年学期", "出库类型", "单据总金额", "签收人", "经手人", "领书日期", "领书说明" };
  179. neh.Export(dt, liststring, "出库管理信息");
  180. return RedirectToAction("MsgShow", "Common", new
  181. {
  182. msg = "导出成功!",
  183. url = Url.Content("~/StockOut/List").AddMenuParameter()
  184. });
  185. }
  186. /// <summary>
  187. /// 删除
  188. /// </summary>
  189. /// <param name="roleID"></param>
  190. /// <returns></returns>
  191. [HttpPost]
  192. public ActionResult Delete(string stockOutIDs)
  193. {
  194. try
  195. {
  196. var stockOutIDList = stockOutIDs.Split(',').Select(x => (Guid)new Guid(x)).ToList();
  197. StockOutServices.Delete(stockOutIDList);
  198. return base.Json("删除成功。");
  199. }
  200. catch (Exception ex)
  201. {
  202. string mge = ex.Message;
  203. return base.Json("删除失败,原因:" + mge);
  204. }
  205. }
  206. /// <summary>
  207. /// 个人领书明细
  208. /// </summary>
  209. /// <param name="stockOutID"></param>
  210. /// <returns></returns>
  211. [HttpGet]
  212. public ActionResult StockOutDetailList(string stockOutID)
  213. {
  214. if (!string.IsNullOrEmpty(stockOutID))
  215. ViewData["stockOutID"] = stockOutID;
  216. return View();
  217. }
  218. /// <summary>
  219. /// 个人领书明细查询
  220. /// </summary>
  221. /// <param name="pararms"></param>
  222. /// <returns></returns>
  223. [HttpPost]
  224. public ActionResult StockOutDetailList(QueryParamsModel pararms)
  225. {
  226. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
  227. Guid? stockOutId = Request["stockOutId"].ParseStrTo<Guid>();
  228. return base.Json(StockOutServices.GetStockOutDetailViewGrid(stockOutId, (int)pararms.page, (int)pararms.rows));
  229. }
  230. /// <summary>
  231. /// Excel 导出
  232. /// </summary>
  233. /// <returns></returns>
  234. [HttpPost]
  235. public ActionResult StockOutDetailExcel(Guid? stockOutId)
  236. {
  237. NpoiExcelHelper neh = new NpoiExcelHelper();
  238. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
  239. var dt = StockOutServices.GetStockOutDetailViewList(stockOutId).Select(x => new
  240. {
  241. x.SchoolyearName,
  242. x.StockOutNo,
  243. x.GetBookNo,
  244. x.TeachingMaterialCode,
  245. x.TeachingMaterialName,
  246. x.PublishName,
  247. SupplierName = x.PublishName,
  248. x.PublishTime,
  249. x.Author,
  250. x.Quantity,
  251. x.Price,
  252. x.DiscountStr,
  253. x.DiscountPriceStr,
  254. x.TotalPriceStr,
  255. x.TotalDollarStr,
  256. x.RecipientUserName,
  257. x.StockOutUserName,
  258. StockOutTime = x.StockOutTime.Value.ToString("yyyy-MM-dd"),
  259. x.Desc
  260. }).ToTable();
  261. string[] liststring = { "学年学期", "出库单据号","领书人", "教材编号", "教材名称", "供应商",
  262. "出版单位", "版本时间", "作者", "数量", "单价", "折扣率", "折合价", "码洋", "总价", "签收人","经手人", "出库日期", "出库说明" };
  263. neh.Export(dt, liststring, "出库明细信息");
  264. return RedirectToAction("MsgShow", "Common", new
  265. {
  266. msg = "导出成功!",
  267. url = Url.Content("~/StockOut/StockOutDetailList").AddMenuParameter()
  268. });
  269. }
  270. /// <summary>
  271. /// 教材信息明细
  272. /// </summary>
  273. /// <param name="stockOutID"></param>
  274. /// <returns></returns>
  275. [HttpPost]
  276. public ActionResult GetTMViewList(Guid? stockOutID)
  277. {
  278. if (stockOutID.HasValue)
  279. {
  280. var resultList = StockOutServices.GetStockOutByTMViewList(stockOutID.Value);
  281. return Json(new JsonDataGridResult<TeachingMaterialPoolView> { rows = resultList, total = resultList.Count });
  282. }
  283. else
  284. {
  285. return Json(new JsonDataGridResult<TeachingMaterialPoolView>());
  286. }
  287. }
  288. /// <summary>
  289. /// 提交
  290. /// </summary>
  291. /// <param name="roleID"></param>
  292. /// <returns></returns>
  293. [HttpPost]
  294. public ActionResult Submit(string stockOutIDs)
  295. {
  296. try
  297. {
  298. var user = HttpContext.User as EMIS.Utility.FormValidate.CustomPrincipal;
  299. var stockOutIDList = stockOutIDs.Split(',').Select(x => (Guid)new Guid(x)).ToList();
  300. StockOutServices.Submit(stockOutIDList, user.UserID);
  301. return base.Json("提交出库成功。");
  302. }
  303. catch (Exception ex)
  304. {
  305. string mge = ex.Message;
  306. return base.Json("提交出库失败,原因:" + mge);
  307. }
  308. }
  309. /// <summary>
  310. /// 添加教材
  311. /// </summary>
  312. /// <returns></returns>
  313. public ActionResult TeachingMaterial()
  314. {
  315. return View();
  316. }
  317. /// <summary>
  318. ///
  319. /// </summary>
  320. /// <returns></returns>
  321. [HttpGet]
  322. public ActionResult GetStockOutByTMList()
  323. {
  324. return View();
  325. }
  326. [HttpPost]
  327. public ActionResult GetStockOutByTMList(QueryParamsModel pararms)
  328. {
  329. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  330. bool? isLate = false;
  331. var teachingMaterialPoolID = pararms.getExtraGuid("TeachingMaterialDropdown");
  332. var coursematerialID = pararms.getExtraGuid("CourseDropdown");
  333. Guid? publishID = pararms.getExtraGuid("PublishDropdown");
  334. var schoolyearID = pararms.getExtraGuid("SchoolyearID");
  335. var isSelectMax = pararms.getExtraInt("hidIsSelectMax") == 1;
  336. // if (configuretView.Attribute == DropdownList.SELECT_ALL.ToString()) configuretView.Attribute = "";
  337. return base.Json(StockOutServices.GetStockInByTeachingMaterialPoolViewGrid(configuretView, isLate, teachingMaterialPoolID, coursematerialID, isSelectMax, (int)pararms.page, (int)pararms.rows));
  338. }
  339. [HttpGet]
  340. public ActionResult RefundListTeachingMaterial()
  341. {
  342. return View();
  343. }
  344. [HttpPost]
  345. public ActionResult GetTeachingMaterialForRefund(QueryParamsModel pararms)
  346. {
  347. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  348. bool? isLate = false;
  349. var teachingMaterialPoolID = pararms.getExtraGuid("TeachingMaterialDropdown");
  350. var coursematerialID = pararms.getExtraGuid("CourseDropdown");
  351. Guid? publishID = pararms.getExtraGuid("PublishDropdown");
  352. var schoolyearID = pararms.getExtraGuid("SchoolyearID");
  353. var isSelectMax = pararms.getExtraInt("hidIsSelectMax") == 1;
  354. // if (configuretView.Attribute == DropdownList.SELECT_ALL.ToString()) configuretView.Attribute = "";
  355. return base.Json(StockOutServices.GetTeachingMaterialViewForRefundGrid(configuretView, isLate, teachingMaterialPoolID, coursematerialID, isSelectMax, (int)pararms.page, (int)pararms.rows));
  356. }
  357. }
  358. }