ChargeStandardController.cs 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.Mvc;
  6. using System.Linq.Expressions;
  7. using Bowin.Common.Data;
  8. using Bowin.Common.Exceptions;
  9. using Bowin.Common.Utility;
  10. using Bowin.Common.JSON;
  11. using Bowin.Web.Controls.Mvc;
  12. using EMIS.Web.Controls;
  13. using EMIS.Utility;
  14. using EMIS.Entities;
  15. using EMIS.ViewModel;
  16. using EMIS.ViewModel.ChargeManage.ChargeSituation;
  17. using EMIS.ViewModel.UniversityManage.SpecialtyClassManage;
  18. using EMIS.CommonLogic.CalendarManage;
  19. using EMIS.CommonLogic.UniversityManage.SpecialtyClassManage;
  20. using EMIS.CommonLogic.ChargeManage.ChargeSituation;
  21. using EMIS.CommonLogic.UniversityManage.AdministrativeOrgan;
  22. namespace EMIS.Web.Controllers.ChargeManage.ChargeSituation
  23. {
  24. [Authorization]
  25. public class ChargeStandardController : Controller
  26. {
  27. public IChargeStandardServices ChargeStandardServices { get; set; }
  28. public ICollegeServices collegeServices { get; set; }
  29. public ISchoolYearServices SchoolYearServices { get; set; }
  30. public IGrademajorServices iGrademajorServices { get; set; }
  31. /// <summary>
  32. /// 收费标准页面
  33. /// </summary>
  34. /// <returns></returns>
  35. public ActionResult List()
  36. {
  37. return View();
  38. }
  39. /// <summary>
  40. /// 列表查询
  41. /// </summary>
  42. /// <param name="pararms"></param>
  43. /// <returns></returns>
  44. [HttpPost]
  45. public ActionResult List(QueryParamsModel pararms)
  46. {
  47. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  48. var collegeID = pararms.getExtraGuid("CollegeDropdown");
  49. var yearID = pararms.getExtraInt("SchoolyearDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("SchoolyearDictionaryDropDown");
  50. var standardID = pararms.getExtraInt("StandardDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("StandardDictionaryDropDown");
  51. var educationID = pararms.getExtraInt("DictionaryEducation") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryEducation");
  52. var learningFormID = pararms.getExtraInt("DictionaryLearningform") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryLearningform");
  53. var LearnSystem = pararms.getExtraString("DictionaryLearnSystem");
  54. var chargeYearID = pararms.getExtraInt("ChargeYearDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ChargeYearDropDown");
  55. var chargeProjectID = pararms.getExtraGuid("ChargeProjectComboGrid");
  56. //在校状态
  57. var inSchoolStatus = pararms.getExtraInt("DictionaryInschoolStatus") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryInschoolStatus");
  58. return base.Json(ChargeStandardServices.GetChargeStandardViewGrid(configuretView, collegeID, yearID, chargeYearID,
  59. standardID, educationID, learningFormID, chargeProjectID, LearnSystem, inSchoolStatus, (int)pararms.page, (int)pararms.rows));
  60. }
  61. /// <summary>
  62. /// 编辑
  63. /// </summary>
  64. /// <returns></returns>
  65. [HttpGet]
  66. public ActionResult Edit(Guid? chargeStandardID)
  67. {
  68. ChargeStandardView chargeStandardView = new ChargeStandardView();
  69. if (chargeStandardID != null && chargeStandardID.HasValue)
  70. {
  71. chargeStandardView = ChargeStandardServices.GetChargeStandardView(chargeStandardID);
  72. }
  73. return View(chargeStandardView);
  74. }
  75. /// <summary>
  76. /// 编辑页面
  77. /// </summary>
  78. /// <param name="facultymajorView"></param>
  79. /// <returns></returns>
  80. [HttpPost]
  81. public ActionResult Edit(ChargeStandardView chargeStandardView)
  82. {
  83. try
  84. {
  85. ChargeStandardServices.ChargeStandardEdit(chargeStandardView);
  86. return Json(new ReturnMessage()
  87. {
  88. IsSuccess = true,
  89. Message = "保存成功。"
  90. });
  91. }
  92. catch (Exception ex)
  93. {
  94. return Json(new ReturnMessage()
  95. {
  96. IsSuccess = false,
  97. Message = "保存失败,原因:" + ex.Message + "。"
  98. });
  99. }
  100. }
  101. /// <summary>
  102. /// 删除(当选择删除的信息中存在对应的应收名单时,无法删除)
  103. /// </summary>
  104. /// <param name="facultymajorView"></param>
  105. /// <returns></returns>
  106. [HttpPost]
  107. public ActionResult Delete(string chargeStandardIDs)
  108. {
  109. try
  110. {
  111. List<Guid> list = new List<Guid>();
  112. for (int i = 0; i < chargeStandardIDs.Split(',').Length; i++)
  113. {
  114. string id = chargeStandardIDs.Split(',')[i];
  115. if (!string.IsNullOrEmpty(id))
  116. {
  117. Guid chargeStandardID = new Guid(id);
  118. list.Add(chargeStandardID);
  119. }
  120. }
  121. ChargeStandardServices.ChargeStandardDelete(list);
  122. return base.Json("删除成功。");
  123. }
  124. catch (Exception ex)
  125. {
  126. string mge = ex.Message;
  127. System.Data.SqlClient.SqlException num = ExceptionHelper.GetSqlException(ex);
  128. if (num != null)
  129. {
  130. if (num.Number == 547)
  131. mge = "请先删除与其关联的数据,如:应收名单等";
  132. }
  133. return base.Json("删除失败,原因:" + mge + "。");
  134. }
  135. }
  136. /// <summary>
  137. /// 刷新名单(生成对应的收费标准应收名单)
  138. /// </summary>
  139. /// <param name="chargeStandardIDs"></param>
  140. /// <returns></returns>
  141. [HttpPost]
  142. public ActionResult CreatChargeList(string chargeStandardIDs, int? inschoolStatus)
  143. {
  144. try
  145. {
  146. List<Guid?> chargeStandardIDList = new List<Guid?>();
  147. for (int i = 0; i < chargeStandardIDs.Split(',').Length; i++)
  148. {
  149. string id = chargeStandardIDs.Split(',')[i];
  150. if (!string.IsNullOrEmpty(id))
  151. {
  152. Guid chargeStandardID = new Guid(id);
  153. chargeStandardIDList.Add(chargeStandardID);
  154. }
  155. }
  156. string result = ChargeStandardServices.CreatStudentChargeList(chargeStandardIDList, inschoolStatus);
  157. return Json(new ReturnMessage()
  158. {
  159. IsSuccess = true,
  160. Message = "刷新成功" + result + "。"
  161. });
  162. }
  163. catch (Exception ex)
  164. {
  165. string mge = ex.Message;
  166. return Json(new ReturnMessage()
  167. {
  168. IsSuccess = false,
  169. Message = "刷新失败,原因:" + ex.Message + "。"
  170. });
  171. }
  172. }
  173. /// <summary>
  174. /// 收费标准年级专业新增
  175. /// </summary>
  176. /// <param name="pararms"></param>
  177. /// <returns></returns>
  178. [HttpGet]
  179. public ActionResult Addlist()
  180. {
  181. ChargeStandardView chargeStandardView = new ChargeStandardView();
  182. chargeStandardView.InSchoolStatus = (int)CF_INOrOutSchoolStatus.Yes;
  183. chargeStandardView.ChargeYear = BaseExtensions.GetCurrentYearID();
  184. return View(chargeStandardView);
  185. }
  186. /// <summary>
  187. /// 收费标准年级专业新增
  188. /// </summary>
  189. /// <param name="amount"></param>
  190. /// <param name="chargeProjectID"></param>
  191. /// <param name="gradeMajorID"></param>
  192. /// <param name="chargeYear"></param>
  193. /// <returns></returns>
  194. [HttpPost]
  195. public ActionResult Addlist(ChargeStandardView chargeStandardView)
  196. {
  197. try
  198. {
  199. var gradeMajorIDs = Request["gradeMajorIDs"].JsonToObject<List<Guid?>>();
  200. string result = ChargeStandardServices.ChargeStandardAdd(gradeMajorIDs, chargeStandardView);
  201. return Json(new ReturnMessage()
  202. {
  203. IsSuccess = true,
  204. Message = "保存成功" + result + "。"
  205. });
  206. }
  207. catch (Exception ex)
  208. {
  209. string mge = ex.Message;
  210. return Json(new ReturnMessage()
  211. {
  212. IsSuccess = false,
  213. Message = "保存失败,原因:" + ex.Message + "。"
  214. });
  215. }
  216. }
  217. /// <summary>
  218. /// 收费标准新增年级专业列表
  219. /// </summary>
  220. /// <param name="pararms"></param>
  221. /// <returns></returns>
  222. [HttpPost]
  223. public ActionResult GradeMajorList(QueryParamsModel pararms)
  224. {
  225. //注:List页面取ID,Excel取Name
  226. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  227. var collegeID = pararms.getExtraGuid("CollegeDropdown");
  228. var yearID = pararms.getExtraInt("DictionarySchoolyear") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionarySchoolyear");
  229. var standardID = pararms.getExtraInt("DictionaryStandard") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryStandard");
  230. var educationID = pararms.getExtraInt("DictionaryEducation") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryEducation");
  231. var learningFormID = pararms.getExtraInt("DictionaryLearningform") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryLearningform");
  232. var LearnSystem = pararms.getExtraString("DictionaryLearnSystem");
  233. var gradeMajorID = pararms.getExtraGuid("GradeMajorComboGrid"); //暂时不做年级专业下拉查询
  234. var inschoolstatus = pararms.getExtraInt("InSchoolStatus") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("InSchoolStatus");
  235. var chargeYearID = pararms.getExtraInt("ChargeYear") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ChargeYear");
  236. //注:收费项目取Value值
  237. var chargeProjectID = pararms.getExtraGuid("ChargeProjectID");
  238. return base.Json(ChargeStandardServices.GetGradeMajorViewGrid(configuretView, gradeMajorID, collegeID, yearID, standardID,
  239. educationID, learningFormID, LearnSystem, inschoolstatus, chargeYearID, chargeProjectID, (int)pararms.page, (int)pararms.rows));
  240. }
  241. /// <summary>
  242. /// 查询年级专业下各班级学生名单
  243. /// </summary>
  244. /// <returns></returns>
  245. [HttpGet]
  246. public ActionResult StudentList()
  247. {
  248. return View();
  249. }
  250. /// <summary>
  251. /// 查询年级专业下各班级学生名单
  252. /// </summary>
  253. /// <param name="pararms"></param>
  254. /// <returns></returns>
  255. [HttpPost]
  256. public ActionResult StudentList(QueryParamsModel pararms)
  257. {
  258. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  259. var grademajorID = Request["grademajorID"].ParseStrTo<Guid>();
  260. int? inschoolStatus = Request["inschoolStatus"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request["inschoolStatus"].ParseStrTo<int>();
  261. return Json(ChargeStandardServices.GetGradeMajorStudentViewGrid(grademajorID, inschoolStatus, (int)pararms.page, (int)pararms.rows));
  262. }
  263. /// <summary>
  264. /// 应收名单列表
  265. /// </summary>
  266. /// <returns></returns>
  267. [HttpGet]
  268. public ActionResult StudentChargeList()
  269. {
  270. return View();
  271. }
  272. /// <summary>
  273. /// 应收名单查询列表
  274. /// </summary>
  275. /// <param name="pararms"></param>
  276. /// <returns></returns>
  277. [HttpPost]
  278. public ActionResult StudentChargeList(QueryParamsModel pararms)
  279. {
  280. var grademajorID = Request["grademajorID"].ParseStrTo<Guid>();
  281. int? chargeYearID = Request["chargeYearID"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request["chargeYearID"].ParseStrTo<int>();
  282. var chargeProjectID = Request["chargeProjectID"].ParseStrTo<Guid>();
  283. //在校状态暂时无效
  284. int? inschoolStatus = Request["inschoolStatus"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request["inschoolStatus"].ParseStrTo<int>();
  285. return Json(ChargeStandardServices.GetGradeMajorStudentChargeViewGrid(grademajorID, chargeYearID, chargeProjectID, inschoolStatus, (int)pararms.page, (int)pararms.rows));
  286. }
  287. /// <summary>
  288. /// 验证(业务主键:年级专业ID、缴费学年、收费项目ID)
  289. /// </summary>
  290. /// <param name="chargeStandardID"></param>
  291. /// <param name="grademajorID"></param>
  292. /// <param name="chargeYearID"></param>
  293. /// <param name="chargeProjectID"></param>
  294. /// <returns></returns>
  295. [HttpPost]
  296. public ActionResult Verification(Guid? chargeStandardID, Guid? grademajorID, int? chargeYearID, Guid? chargeProjectID)
  297. {
  298. return Json(ChargeStandardServices.GetVerification(chargeStandardID, grademajorID, chargeYearID, chargeProjectID));
  299. }
  300. /// <summary>
  301. /// Excel导出
  302. /// </summary>
  303. /// <returns></returns>
  304. [HttpPost]
  305. public ActionResult Excel()
  306. {
  307. NpoiExcelHelper neh = new NpoiExcelHelper();
  308. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
  309. var collegeID = Request.Form["CollegeDropdown"].ParseStrTo<Guid>();
  310. var yearID = Request.Form["SchoolyearDictionaryDropDown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["SchoolyearDictionaryDropDown"].ParseStrTo<int>();
  311. var standardID = Request.Form["StandardDictionaryDropDown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["StandardDictionaryDropDown"].ParseStrTo<int>();
  312. var educationID = Request.Form["DictionaryEducation"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryEducation"].ParseStrTo<int>();
  313. var learningFormID = Request.Form["DictionaryLearningform"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryLearningform"].ParseStrTo<int>();
  314. var LearnSystem = Request.Form["DictionaryLearnSystem"].ToString();
  315. var inSchoolStatus = Request.Form["DictionaryInschoolStatus"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryInschoolStatus"].ParseStrTo<int>();
  316. var chargeYearID = Request.Form["ChargeYearDropDown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["ChargeYearDropDown"].ParseStrTo<int>();
  317. var chargeProjectID = Request.Form["ChargeProjectComboGrid"].ParseStrTo<Guid>();
  318. var dt = ChargeStandardServices.GetChargeStandardList(configuretView, collegeID, yearID, standardID, learningFormID,
  319. chargeYearID, chargeProjectID, LearnSystem, educationID, inSchoolStatus).Select(x => new
  320. {
  321. x.GradeMajorCode,
  322. x.GrademajorStr,
  323. x.GradeStr,
  324. x.StandardID,
  325. x.StandardCode,
  326. x.MajorStr,
  327. x.EducationName,
  328. x.LearningformStr,
  329. x.LearnSystem,
  330. x.CollegeCode,
  331. x.CollegeStr,
  332. x.ChargeYear,
  333. x.ChargeProjectStr,
  334. x.Amount,
  335. x.StudentCount,
  336. x.StudentChargeCount
  337. }).ToTable();
  338. string[] liststring = { "年级专业代码", "年级专业名称", "年级", "专业ID(Value)",
  339. "专业代码", "专业名称", RSL.Get("EducationID"), "学习形式",
  340. "学制", RSL.Get("CollegeCode"), RSL.Get("CollegeName"),
  341. "缴费学年", "收费项目", "应收金额(¥)", "学生人数", "生成人数"
  342. };
  343. neh.Export(dt, liststring, "收费标准信息" + DateTime.Now.ToString("yyyyMMdd"));
  344. return Json(new ReturnMessage()
  345. {
  346. IsSuccess = true,
  347. Message = "导出成功。"
  348. });
  349. }
  350. /// <summary>
  351. /// 学生信息明细Excel导出
  352. /// </summary>
  353. /// <returns></returns>
  354. [HttpPost]
  355. public ActionResult GrademajorStudentExcel()
  356. {
  357. NpoiExcelHelper neh = new NpoiExcelHelper();
  358. var grademajorID = Request["grademajorID"].ParseStrTo<Guid>();
  359. int? inschoolstatus = Request["inschoolStatus"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request["inschoolStatus"].ParseStrTo<int>();
  360. var dt = ChargeStandardServices.GetGradeMajorStudentViewGrid(grademajorID, inschoolstatus).Select(x => new
  361. {
  362. x.LoginID,
  363. x.UserName,
  364. x.SexName,
  365. x.ClassMajorName,
  366. x.InSchoolStatusName,
  367. x.StudentStatusName
  368. }).ToTable();
  369. string[] liststring = { "学号", "姓名", "性别", "班级名称 ", "在校状态", "学籍状态" };
  370. neh.Export(dt, liststring, "学生信息明细" + DateTime.Now.ToString("yyyyMMdd"));
  371. return Json(new ReturnMessage()
  372. {
  373. IsSuccess = true,
  374. Message = "导出成功。"
  375. });
  376. }
  377. /// <summary>
  378. /// 应收名单明细Excel导出
  379. /// </summary>
  380. /// <returns></returns>
  381. [HttpPost]
  382. public ActionResult GrademajorStudentChargeExcel()
  383. {
  384. NpoiExcelHelper neh = new NpoiExcelHelper();
  385. var grademajorID = Request["grademajorID"].ParseStrTo<Guid>();
  386. int? chargeYearID = Request["chargeYearID"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request["chargeYearID"].ParseStrTo<int>();
  387. var chargeProjectID = Request["chargeProjectID"].ParseStrTo<Guid>();
  388. //在校状态暂时无效
  389. int? inschoolStatus = Request["inschoolStatus"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request["inschoolStatus"].ParseStrTo<int>();
  390. var dt = ChargeStandardServices.GetGradeMajorStudentChargeViewGrid(grademajorID, chargeYearID, chargeProjectID, inschoolStatus).Select(x => new
  391. {
  392. x.StudentNo,
  393. x.UserName,
  394. x.SexName,
  395. x.ClassName,
  396. x.ChargeYear,
  397. x.ChargeProjectStr,
  398. x.Amount,
  399. x.InSchoolStatusName,
  400. x.Remark
  401. }).ToTable();
  402. string[] liststring = { "学号", "姓名", "性别", "班级名称 ", "缴费学年 ",
  403. "收费项目", "应收金额", "在校状态", "备注" };
  404. neh.Export(dt, liststring, "应收名单明细" + DateTime.Now.ToString("yyyyMMdd"));
  405. return Json(new ReturnMessage()
  406. {
  407. IsSuccess = true,
  408. Message = "导出成功。"
  409. });
  410. }
  411. }
  412. }