StockInSetController.cs 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.Mvc;
  6. using EMIS.ViewModel;
  7. using EMIS.Web.Controls;
  8. using Bowin.Web.Controls.Mvc;
  9. using EMIS.ViewModel.TeachingMaterial;
  10. using EMIS.CommonLogic.TeachingMaterial;
  11. using Bowin.Common.Utility;
  12. using Bowin.Common.Data;
  13. namespace EMIS.Web.Controllers.TeachingMaterial
  14. {
  15. [Authorization]
  16. public class StockInSetController : Controller
  17. {
  18. public ISupplierDiscountSetServices supplierDiscountSetServices { get; set; }
  19. /// <summary>
  20. /// 供应商折扣率设置
  21. /// </summary>
  22. /// <returns></returns>
  23. [HttpGet]
  24. public ActionResult List()
  25. {
  26. return View();
  27. }
  28. /// <summary>
  29. /// 列表查询
  30. /// </summary>
  31. /// <param name="pararms"></param>
  32. /// <returns></returns>
  33. [HttpPost]
  34. public ActionResult List(QueryParamsModel pararms)
  35. {
  36. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  37. bool? isDefault = null;
  38. if (configuretView.Attribute == DropdownList.SELECT_ALL.ToString()) configuretView.Attribute = "";
  39. return base.Json(supplierDiscountSetServices.GetSupplierDiscountSetViewGrid(configuretView, isDefault, (int)pararms.page, (int)pararms.rows));
  40. }
  41. /// <summary>
  42. /// 复制新增
  43. /// </summary>
  44. /// <param name="GraduationConditionPackageID"></param>
  45. /// <returns></returns>
  46. public ActionResult CopyAdd(Guid supplierDiscountSetID)
  47. {
  48. SupplierDiscountSetView supplierDiscountSetView = new SupplierDiscountSetView();
  49. supplierDiscountSetView = supplierDiscountSetServices.GetSupplierDiscountSetView(supplierDiscountSetID);
  50. return View("Edit", supplierDiscountSetView);
  51. }
  52. /// <summary>
  53. /// 复制新增
  54. /// </summary>
  55. /// <param name="graduationConditionPackageView"></param>
  56. /// <returns></returns>
  57. [HttpPost]
  58. public ActionResult CopyAdd(SupplierDiscountSetView supplierDiscountSetView)
  59. {
  60. supplierDiscountSetView.SupplierDiscountSetID = Guid.Empty;
  61. return this.Edit(supplierDiscountSetView);
  62. }
  63. /// <summary>
  64. /// 新增、修改
  65. /// </summary>
  66. /// <param name="GraduationConditionID"></param>
  67. /// <returns></returns>
  68. [HttpGet]
  69. public ActionResult Edit(Guid? supplierDiscountSetID)
  70. {
  71. SupplierDiscountSetView supplierDiscountSetView = new SupplierDiscountSetView();
  72. if (supplierDiscountSetID.HasValue && supplierDiscountSetID != Guid.Empty)
  73. {
  74. supplierDiscountSetView = supplierDiscountSetServices.GetSupplierDiscountSetView((Guid)supplierDiscountSetID);
  75. }
  76. return View(supplierDiscountSetView);
  77. }
  78. /// <summary>
  79. /// 新增、修改
  80. /// </summary>
  81. /// <param name="graduationConditionView"></param>
  82. /// <returns></returns>
  83. [HttpPost]
  84. public ActionResult Edit(SupplierDiscountSetView supplierDiscountSetView)
  85. {
  86. try
  87. {
  88. supplierDiscountSetServices.SupplierDiscountSetViewEdit(supplierDiscountSetView);
  89. return Json(new ReturnMessage()
  90. {
  91. IsSuccess = true,
  92. Message = "保存成功。"
  93. });
  94. }
  95. catch (Exception ex)
  96. {
  97. return Json(new ReturnMessage()
  98. {
  99. IsSuccess = false,
  100. Message = "保存失败,原因:" + ex.Message + "。"
  101. });
  102. }
  103. }
  104. /// <summary>
  105. /// 删除
  106. /// </summary>
  107. /// <param name="graduationCourseIDs"></param>
  108. /// <returns></returns>
  109. [HttpPost]
  110. public ActionResult Delete(string supplierDiscountSetIDs)
  111. {
  112. try
  113. {
  114. List<Guid?> list = supplierDiscountSetIDs.Split(',').Where(x => !string.IsNullOrEmpty(x))
  115. .Select(x => (Guid?)new Guid(x)).ToList();
  116. supplierDiscountSetServices.SupplierDiscountSetDelete(list);
  117. return base.Json("删除成功。");
  118. }
  119. catch (Exception ex)
  120. {
  121. return base.Json("删除失败,原因:" + ex.Message);
  122. }
  123. }
  124. /// <summary>
  125. /// 导出
  126. /// </summary>
  127. /// <param name="graduationCourseIDs"></param>
  128. /// <returns></returns>
  129. [HttpPost]
  130. public ActionResult Excel()
  131. {
  132. NpoiExcelHelper neh = new NpoiExcelHelper();
  133. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
  134. var supplierDiscountSetID = Request.Form["SupplierDiscountSetID"];
  135. List<Guid?> supplierDiscountSetIDList = new List<Guid?>();
  136. bool? isDefault = null;
  137. if (supplierDiscountSetID != "")
  138. {
  139. supplierDiscountSetIDList = supplierDiscountSetID.SplitIDString();
  140. }
  141. else
  142. {
  143. supplierDiscountSetIDList = null;
  144. }
  145. //var collegeID = Request.Form["CollegeComboGrid"].ParseStrTo<Guid>();
  146. //var departmentID = Request.Form["DepartmentComboGrid"].ParseStrTo<Guid>();
  147. //var yearID = Request.Form["DictionaryGrade"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryGrade"].ParseStrTo<int>();
  148. //var grademajorID = Request.Form["GrademajorComboGrid"].ParseStrTo<Guid>();
  149. //var classmajorID = Request.Form["ClassmajorDropdown"].ParseStrTo<Guid>();
  150. //var coursematerialID = Request.Form["CoursematerialComboGrid"].ParseStrTo<Guid>();
  151. //var courseTypeID = Request.Form["DictionaryCourseType"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryCourseType"].ParseStrTo<int>();
  152. //var examsCategoryID = Request.Form["DictionaryExamsCategory"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryExamsCategory"].ParseStrTo<int>();
  153. //var schoolyearID = Request.Form["SchoolyearDropdown"].ParseStrTo<Guid>();
  154. //var learningformID = Request.Form["LearningformDictionaryDropDown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["LearningformDictionaryDropDown"].ParseStrTo<int>();
  155. //var education = Request.Form["DictionaryEducation"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryEducation"].ParseStrTo<int>();
  156. //var LearnSystem = Request.Form["DictionaryLearnSystem"].ToString();
  157. var dt = supplierDiscountSetServices.GetSupplierDiscountSetViewList(configuretView, isDefault, supplierDiscountSetIDList).Select(x => new
  158. {
  159. x.UnitName,
  160. x.IsDefaultName,
  161. x.Discount
  162. }).ToTable();
  163. string[] liststring = { "供应商名称","是否默认","折扣率" };
  164. neh.Export(dt, liststring, "供应商折扣率设置信息");
  165. return RedirectToAction("MsgShow", "Common", new
  166. {
  167. msg = "导出成功!",
  168. url = Url.Action("List").AddMenuParameter()
  169. });
  170. }
  171. [HttpPost]
  172. public ActionResult GetDiscountByID(Guid supplierID)
  173. {
  174. decimal? discount = supplierDiscountSetServices.GetDiscountByPublishID(supplierID);
  175. return base.Json(discount.ToString());
  176. }
  177. }
  178. }