StudentChargeController.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361
  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 EMIS.CommonLogic.ChargeManage.ChargeSituation;
  9. using Bowin.Web.Controls.Mvc;
  10. using Bowin.Common.Exceptions;
  11. using Bowin.Common.Utility;
  12. using Bowin.Common.Data;
  13. using Bowin.Common.JSON;
  14. using EMIS.ViewModel.ChargeManage.ChargeSituation;
  15. using EMIS.CommonLogic.CalendarManage;
  16. using EMIS.Utility;
  17. namespace EMIS.Web.Controllers.ChargeManage.ChargeSituation
  18. {
  19. [Authorization]
  20. public class StudentChargeController : Controller
  21. {
  22. public IStudentChargeServices StudentChargeServices { get; set; }
  23. /// <summary>
  24. /// 应收名单页面
  25. /// </summary>
  26. /// <returns></returns>
  27. public ActionResult List()
  28. {
  29. return View();
  30. }
  31. /// <summary>
  32. /// 应收名单列表查询
  33. /// </summary>
  34. /// <param name="pararms"></param>
  35. /// <returns></returns>
  36. [HttpPost]
  37. public ActionResult List(QueryParamsModel pararms)
  38. {
  39. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  40. var collegeID = pararms.getExtraGuid("CollegeDropdown");
  41. var yearID = pararms.getExtraInt("SchoolyearDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("SchoolyearDictionaryDropDown");
  42. var standardID = pararms.getExtraInt("StandardDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("StandardDictionaryDropDown");
  43. var educationID = pararms.getExtraInt("DictionaryEducation") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryEducation");
  44. var learningformID = pararms.getExtraInt("DictionaryLearningform") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryLearningform");
  45. var learnSystem = pararms.getExtraString("DictionaryLearnSystem");
  46. var chargeYearID = pararms.getExtraInt("ChargeYearDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ChargeYearDropDown");
  47. var chargeProjectID = pararms.getExtraGuid("ChargeProjectComboGrid");
  48. var chargeTagID = pararms.getExtraInt("DictionaryChargeTag") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryChargeTag");
  49. //在校状态
  50. var inSchoolStatus = pararms.getExtraInt("DictionaryInschoolStatus") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryInschoolStatus");
  51. //是否圆梦计划
  52. var isDream = pararms.getExtraInt("IsDreamDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("IsDreamDropDown");
  53. return base.Json(StudentChargeServices.GetStudentChargeViewGrid(configuretView, collegeID, yearID, standardID, educationID,
  54. learningformID, learnSystem, chargeYearID, chargeProjectID, chargeTagID, inSchoolStatus,
  55. isDream, (int)pararms.page, (int)pararms.rows));
  56. }
  57. /// <summary>
  58. /// 编辑
  59. /// </summary>
  60. /// <param name="studentChargeID"></param>
  61. /// <returns></returns>
  62. [HttpGet]
  63. public ActionResult Edit(Guid? studentChargeID)
  64. {
  65. StudentChargeView studentChargeView = new StudentChargeView();
  66. if (studentChargeID.HasValue && studentChargeID != Guid.Empty)
  67. {
  68. studentChargeView = StudentChargeServices.GetStudentChargeView(studentChargeID);
  69. }
  70. else
  71. {
  72. studentChargeView.ChargeYear = BaseExtensions.GetCurrentYearID();
  73. studentChargeView.ChargeTag = (int)EC_ChargeTag.Normal;
  74. }
  75. return View(studentChargeView);
  76. }
  77. /// <summary>
  78. /// 编辑(新增、修改)
  79. /// 存在对应的收费标准时,才可新增
  80. /// 业务主键不可修改(业务主键:用户ID、缴费学年、收费项目ID)
  81. /// </summary>
  82. /// <param name="sudentChargeView"></param>
  83. /// <returns></returns>
  84. [HttpPost]
  85. public ActionResult Edit(StudentChargeView sudentChargeView)
  86. {
  87. try
  88. {
  89. StudentChargeServices.StudentChaegeEdit(sudentChargeView);
  90. return Json(new ReturnMessage()
  91. {
  92. IsSuccess = true,
  93. Message = "保存成功。"
  94. });
  95. }
  96. catch (Exception ex)
  97. {
  98. return Json(new ReturnMessage()
  99. {
  100. IsSuccess = false,
  101. Message = "保存失败,原因:" + ex.Message + "。"
  102. });
  103. }
  104. }
  105. /// <summary>
  106. /// 查询对应的收费标准应收金额
  107. /// </summary>
  108. /// <param name="userID"></param>
  109. /// <param name="chargeYear"></param>
  110. /// <param name="chargeProjectID"></param>
  111. /// <returns></returns>
  112. [HttpPost]
  113. public ActionResult StudentChargeStandard(Guid? userID, int? chargeYearID, Guid? chargeProjectID)
  114. {
  115. try
  116. {
  117. var result = "";
  118. var chargeStandardView = StudentChargeServices.StudentChargeChargeStandard(userID, chargeYearID, chargeProjectID);
  119. if (chargeStandardView != null)
  120. {
  121. result = chargeStandardView.Amount.ToString();
  122. }
  123. return Json(new ReturnMessage()
  124. {
  125. IsSuccess = true,
  126. Message = result
  127. });
  128. }
  129. catch (Exception ex)
  130. {
  131. return Json(new ReturnMessage()
  132. {
  133. IsSuccess = false,
  134. Message = "数据有误,请核查,原因:" + ex.Message + "。"
  135. });
  136. }
  137. }
  138. /// <summary>
  139. /// 删除(当选择删除的信息中存在对应的学生缴费信息时,无法删除)
  140. /// </summary>
  141. /// <param name="chargeStandardIDs"></param>
  142. /// <returns></returns>
  143. [HttpPost]
  144. public ActionResult Delete(string studentChargeIDs)
  145. {
  146. try
  147. {
  148. List<Guid> list = new List<Guid>();
  149. for (int i = 0; i < studentChargeIDs.Split(',').Length; i++)
  150. {
  151. string id = studentChargeIDs.Split(',')[i];
  152. if (!string.IsNullOrEmpty(id))
  153. {
  154. Guid chargeStandardID = new Guid(id);
  155. list.Add(chargeStandardID);
  156. }
  157. }
  158. StudentChargeServices.StudentChargedDelete(list);
  159. return base.Json("删除成功。");
  160. }
  161. catch (Exception ex)
  162. {
  163. string mge = ex.Message;
  164. System.Data.SqlClient.SqlException num = ExceptionHelper.GetSqlException(ex);
  165. if (num != null)
  166. {
  167. if (num.Number == 547)
  168. mge = "请先删除与其关联的数据,如:缓交名单信息、学生缴费信息等";
  169. }
  170. return base.Json("删除失败,原因:" + mge);
  171. }
  172. }
  173. /// <summary>
  174. /// 费用调整
  175. /// </summary>
  176. /// <returns></returns>
  177. [HttpGet]
  178. public ActionResult ChangeActualAmount()
  179. {
  180. return View();
  181. }
  182. /// <summary>
  183. /// 费用调整
  184. /// </summary>
  185. /// <param name="changeJsonStr"></param>
  186. /// <returns></returns>
  187. [HttpPost]
  188. public ActionResult ChangeActualAmount(string changeJsonStr)
  189. {
  190. try
  191. {
  192. changeJsonStr = Request.Form["hid_JsonStr"];
  193. string actualAmount = Request.Form["ActualAmount"];
  194. string chargeTag = Request.Form["ChargeTag"];
  195. string remark = Request.Form["Remark"];
  196. var sutdentChargeViewlist = changeJsonStr.JsonToObject<List<StudentChargeView>>();
  197. StudentChargeServices.UpdateActualAmount(sutdentChargeViewlist, Convert.ToDecimal(actualAmount),
  198. Convert.ToInt32(chargeTag), remark);
  199. return Json(new ReturnMessage()
  200. {
  201. IsSuccess = true,
  202. Message = "保存成功。"
  203. });
  204. }
  205. catch (Exception ex)
  206. {
  207. return Json(new ReturnMessage()
  208. {
  209. IsSuccess = false,
  210. Message = "保存失败,原因:" + ex.Message + "。"
  211. });
  212. }
  213. }
  214. /// <summary>
  215. /// 缓交申请(同时对相应的缓交信息进行验证)
  216. /// </summary>
  217. /// <param name="studentChargeID"></param>
  218. /// <returns></returns>
  219. [HttpGet]
  220. public ActionResult ChargeDelay(Guid? studentChargeID)
  221. {
  222. ChargeDelayView chargeDelayView = new ChargeDelayView();
  223. if (studentChargeID.HasValue && studentChargeID != Guid.Empty)
  224. {
  225. chargeDelayView = StudentChargeServices.GetStudentChargeChargeDelayView(studentChargeID);
  226. }
  227. return View(chargeDelayView);
  228. }
  229. /// <summary>
  230. /// 缓交申请
  231. /// </summary>
  232. /// <param name="studentChargeID"></param>
  233. /// <returns></returns>
  234. [HttpPost]
  235. public ActionResult ChargeDelay(ChargeDelayView chargeDelayView)
  236. {
  237. try
  238. {
  239. StudentChargeServices.ChargeDelay(chargeDelayView);
  240. return Json(new ReturnMessage()
  241. {
  242. IsSuccess = true,
  243. Message = "申请成功。"
  244. });
  245. }
  246. catch (Exception ex)
  247. {
  248. return Json(new ReturnMessage()
  249. {
  250. IsSuccess = false,
  251. Message = "申请失败,原因:" + ex.Message + "。"
  252. });
  253. }
  254. }
  255. /// <summary>
  256. /// 验证
  257. /// </summary>
  258. /// <param name="studentChargeID"></param>
  259. /// <param name="chargeProjectID"></param>
  260. /// <returns></returns>
  261. [HttpPost]
  262. public ActionResult Verification(Guid? studentChargeID, Guid? userID, int? chargeYearID, Guid? chargeProjectID)
  263. {
  264. return Json(StudentChargeServices.GetVerification(studentChargeID, userID, chargeYearID, chargeProjectID));
  265. }
  266. /// <summary>
  267. /// 导出Excel
  268. /// </summary>
  269. /// <returns></returns>
  270. [HttpPost]
  271. public ActionResult Excel()
  272. {
  273. NpoiExcelHelper neh = new NpoiExcelHelper();
  274. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
  275. var collegeID = Request.Form["CollegeDropdown"].ParseStrTo<Guid>();
  276. var yearID = Request.Form["SchoolyearDictionaryDropDown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["SchoolyearDictionaryDropDown"].ParseStrTo<int>();
  277. var standardID = Request.Form["StandardDictionaryDropDown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["StandardDictionaryDropDown"].ParseStrTo<int>();
  278. var educationID = Request.Form["DictionaryEducation"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryEducation"].ParseStrTo<int>();
  279. var learningFormID = Request.Form["DictionaryLearningform"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryLearningform"].ParseStrTo<int>();
  280. var learnSystem = Request.Form["DictionaryLearnSystem"].ToString();
  281. var chargeYearID = Request.Form["ChargeYearDropDown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["ChargeYearDropDown"].ParseStrTo<int>();
  282. var chargeProjectID = Request.Form["ChargeProjectComboGrid"].ParseStrTo<Guid>();
  283. var chargeTagID = Request.Form["DictionaryChargeTag"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryChargeTag"].ParseStrTo<int>();
  284. //在校状态
  285. var inSchoolStatus = Request.Form["DictionaryInschoolStatus"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryInschoolStatus"].ParseStrTo<int>();
  286. //是否圆梦计划
  287. var isDream = Request.Form["IsDreamDropDown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["IsDreamDropDown"].ParseStrTo<int>();
  288. var dt = StudentChargeServices.GetStudentChargeViewGrid(configuretView, collegeID, yearID, standardID, educationID,
  289. learningFormID, learnSystem, chargeYearID, chargeProjectID, chargeTagID, inSchoolStatus, isDream)
  290. .Select(x => new
  291. {
  292. x.StudentNo,
  293. x.UserName,
  294. x.SexName,
  295. x.ClassNo,
  296. x.ClassName,
  297. x.GradeMajorCode,
  298. x.GradeMajoyStr,
  299. x.CollegeCode,
  300. x.CollegeStr,
  301. x.ChargeYear,
  302. x.ChargeProjectStr,
  303. x.Amount,
  304. x.ChargeAmount,
  305. x.ActualAmount,
  306. x.ChargeTagName,
  307. x.PaidAmount,
  308. x.GradeStr,
  309. x.StandardID,
  310. x.StandardCode,
  311. x.MajorStr,
  312. x.EducationName,
  313. x.LearningformName,
  314. x.LearnSystem,
  315. x.IsDreamProject,
  316. x.InSchoolStatusName,
  317. x.StudentStatusName,
  318. x.Remark
  319. }).ToTable();
  320. string[] liststring = {
  321. "学号", "姓名", "性别", "班级编号", "班级名称", "年级专业编号", "年级专业名称",
  322. RSL.Get("CollegeCode"), RSL.Get("CollegeName"),
  323. "缴费学年", "收费项目", "应收金额", "调整金额", "实收金额", "缴费标记", "已缴金额",
  324. "年级", "专业ID(Value)", "专业代码", "专业名称", RSL.Get("EducationID"), "学习形式",
  325. "学制", "是否圆梦计划", "在校状态", "学籍状态", "备注"
  326. };
  327. neh.Export(dt, liststring, "应收名单信息" + DateTime.Now.ToString("yyyyMMdd"));
  328. return Json(new ReturnMessage()
  329. {
  330. IsSuccess = true,
  331. Message = "导出成功。"
  332. });
  333. }
  334. }
  335. }