StudentChargePaymenController.cs 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Text;
  6. using System.Web.Mvc;
  7. using EMIS.ViewModel;
  8. using EMIS.Web.Controls;
  9. using Bowin.Web.Controls.Mvc;
  10. using Bowin.Common.Exceptions;
  11. using Bowin.Common.Utility;
  12. using Bowin.Common.Data;
  13. using EMIS.Utility;
  14. using EMIS.ViewModel.ChargeManage.ChargeSituation;
  15. using EMIS.CommonLogic.ChargeManage.ChargeSituation;
  16. using EMIS.CommonLogic.CalendarManage;
  17. using System.Data;
  18. namespace EMIS.Web.Controllers.ChargeManage.ChargeSituation
  19. {
  20. [Authorization]
  21. public class StudentChargePaymenController : Controller
  22. {
  23. public IStudentChargePaymenServices StudentChargePaymenServices { get; set; }
  24. public ISchoolYearServices SchoolYearServices { get; set; }
  25. /// <summary>
  26. /// 学生缴费页面
  27. /// </summary>
  28. /// <returns></returns>
  29. public ActionResult List()
  30. {
  31. return View();
  32. }
  33. /// <summary>
  34. /// 列表查询
  35. /// </summary>
  36. /// <param name="pararms"></param>
  37. /// <returns></returns>
  38. [HttpPost]
  39. public ActionResult List(QueryParamsModel pararms)
  40. {
  41. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  42. var collegeID = pararms.getExtraGuid("CollegeDropdown");
  43. var yearID = pararms.getExtraInt("SchoolyearDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("SchoolyearDictionaryDropDown");
  44. var standardID = pararms.getExtraInt("StandardDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("StandardDictionaryDropDown");
  45. var educationID = pararms.getExtraInt("DictionaryEducation") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryEducation");
  46. var learningformID = pararms.getExtraInt("DictionaryLearningform") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryLearningform");
  47. var learnSystem = pararms.getExtraString("DictionaryLearnSystem");
  48. var chargeYearID = pararms.getExtraInt("ChargeYearDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ChargeYearDropDown");
  49. var chargeProjectID = pararms.getExtraGuid("ChargeProjectComboGrid");
  50. var chargeTagID = pararms.getExtraInt("DictionaryChargeTag") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryChargeTag");
  51. //在校状态
  52. var inSchoolStatus = pararms.getExtraInt("DictionaryInschoolStatus") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryInschoolStatus");
  53. //是否圆梦计划
  54. var isDream = pararms.getExtraInt("IsDreamDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("IsDreamDropDown");
  55. //备注
  56. var Remark = pararms.getExtraString("DictionaryRemark");
  57. return base.Json(StudentChargePaymenServices.GetStudentChargePamenViewGrid(configuretView, collegeID, yearID, standardID,
  58. educationID, learningformID, learnSystem,chargeYearID, chargeProjectID,
  59. inSchoolStatus, isDream, chargeTagID, Remark, (int)pararms.page, (int)pararms.rows));
  60. }
  61. /// <summary>
  62. /// 学生缴费页面缴费金额统计
  63. /// </summary>
  64. /// <param name="pararms"></param>
  65. /// <returns></returns>
  66. public ActionResult AmountCountList(QueryParamsModel pararms)
  67. {
  68. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  69. var collegeID = pararms.getExtraGuid("CollegeDropdown");
  70. var yearID = pararms.getExtraInt("SchoolyearDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("SchoolyearDictionaryDropDown");
  71. var standardID = pararms.getExtraInt("StandardDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("StandardDictionaryDropDown");
  72. var educationID = pararms.getExtraInt("DictionaryEducation") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryEducation");
  73. var learningformID = pararms.getExtraInt("DictionaryLearningform") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryLearningform");
  74. var learnSystem = pararms.getExtraString("DictionaryLearnSystem");
  75. var chargeYearID = pararms.getExtraInt("ChargeYearDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ChargeYearDropDown");
  76. var chargeProjectID = pararms.getExtraGuid("ChargeProjectComboGrid");
  77. var chargeTagID = pararms.getExtraInt("DictionaryChargeTag") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryChargeTag");
  78. //在校状态
  79. var inSchoolStatus = pararms.getExtraInt("DictionaryInschoolStatus") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryInschoolStatus");
  80. //是否圆梦计划
  81. var isDream = pararms.getExtraInt("IsDreamDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("IsDreamDropDown");
  82. //备注
  83. var Remark = pararms.getExtraString("DictionaryRemark");
  84. var amountCount = StudentChargePaymenServices.GetAmountCount(configuretView, collegeID, yearID, standardID,
  85. educationID, learningformID, learnSystem,chargeYearID, chargeProjectID,
  86. inSchoolStatus, isDream, chargeTagID, Remark, 1, 1);
  87. return Json(new StudentChargePaymenView { AmountSum = amountCount });
  88. }
  89. /// <summary>
  90. /// 编辑
  91. /// </summary>
  92. /// <param name="studentChargePaymentID"></param>
  93. /// <returns></returns>
  94. [HttpGet]
  95. public ActionResult Edit(Guid? studentChargePaymentID)
  96. {
  97. StudentChargePaymenView studentChargePaymenView = new StudentChargePaymenView();
  98. if (studentChargePaymentID.HasValue && studentChargePaymentID != Guid.Empty)
  99. {
  100. studentChargePaymenView = StudentChargePaymenServices.GetStudentChargePaymenView(studentChargePaymentID);
  101. }
  102. else
  103. {
  104. studentChargePaymenView.ChargeYear = BaseExtensions.GetCurrentYearID();
  105. }
  106. return View(studentChargePaymenView);
  107. }
  108. /// <summary>
  109. /// 编辑(新增、修改)
  110. /// 存在对应的应收名单时,才可新增
  111. /// 业务主键不可修改(业务主键:用户ID、缴费学年、收费项目ID)
  112. /// </summary>
  113. /// <param name="StudentChargePaymenView"></param>
  114. /// <returns></returns>
  115. [HttpPost]
  116. public ActionResult Edit(StudentChargePaymenView StudentChargePaymenView)
  117. {
  118. try
  119. {
  120. StudentChargePaymenServices.StudentChargePaymenEdit(StudentChargePaymenView);
  121. return Json(new ReturnMessage()
  122. {
  123. IsSuccess = true,
  124. Message = "保存成功。"
  125. });
  126. }
  127. catch (Exception ex)
  128. {
  129. return Json(new ReturnMessage()
  130. {
  131. IsSuccess = false,
  132. Message = "保存失败,原因:" + ex.Message + "。"
  133. });
  134. }
  135. }
  136. /// <summary>
  137. /// 查询对应的应收名单及缴费信息(根据应收名单业务主键)
  138. /// </summary>
  139. /// <param name="userID"></param>
  140. /// <param name="chargeYearID"></param>
  141. /// <param name="chargeProjectID"></param>
  142. /// <returns></returns>
  143. [HttpPost]
  144. public ActionResult StudentChargeStandard(Guid? userID, int? chargeYearID, Guid? chargeProjectID)
  145. {
  146. try
  147. {
  148. var result = StudentChargePaymenServices.QueryStudentChargePaymenView(userID, chargeYearID, chargeProjectID);
  149. return Json(new ReturnMessage<StudentChargeView>()
  150. {
  151. IsSuccess = true,
  152. Data = result
  153. });
  154. }
  155. catch (Exception ex)
  156. {
  157. return Json(new ReturnMessage()
  158. {
  159. IsSuccess = false,
  160. Message = ex.Message
  161. });
  162. }
  163. }
  164. /// <summary>
  165. /// 批量修改(重写)
  166. /// </summary>
  167. /// <param name="studentChargePaymentIDs"></param>
  168. /// <param name="chargeProjectID"></param>
  169. /// <param name="amount"></param>
  170. /// <returns></returns>
  171. public ActionResult BatchModifyControl(string studentChargePaymentIDs, decimal? amount)
  172. {
  173. try
  174. {
  175. string result = StudentChargePaymenServices.BatchModify(studentChargePaymentIDs, amount);
  176. return Json(new ReturnMessage()
  177. {
  178. IsSuccess = true,
  179. Message = "批量修改成功" + result + "。"
  180. });
  181. }
  182. catch (Exception ex)
  183. {
  184. return Json(new ReturnMessage()
  185. {
  186. IsSuccess = false,
  187. Message = "批量修改失败,原因:" + ex.Message + "。"
  188. });
  189. }
  190. }
  191. /// <summary>
  192. /// 删除
  193. /// </summary>
  194. /// <param name="studentChargeIDs"></param>
  195. /// <returns></returns>
  196. [HttpPost]
  197. public ActionResult Delete(string studentChargePaymenIDs)
  198. {
  199. try
  200. {
  201. List<Guid> list = new List<Guid>();
  202. for (int i = 0; i < studentChargePaymenIDs.Split(',').Length; i++)
  203. {
  204. string id = studentChargePaymenIDs.Split(',')[i];
  205. if (!string.IsNullOrEmpty(id))
  206. {
  207. Guid chargeStandardID = new Guid(id);
  208. list.Add(chargeStandardID);
  209. }
  210. }
  211. StudentChargePaymenServices.StudentChargePaymenDelete(list);
  212. return base.Json("删除成功。");
  213. }
  214. catch (Exception ex)
  215. {
  216. return base.Json("删除失败,原因:" + ex.Message);
  217. }
  218. }
  219. /// <summary>
  220. /// 获取学生缴费备注信息
  221. /// </summary>
  222. /// <param name="pararms"></param>
  223. /// <returns></returns>
  224. public ActionResult GetRemark(QueryParamsModel pararms)
  225. {
  226. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  227. var Remark = pararms.getExtraString("DictionaryRemark");
  228. return base.Json(StudentChargePaymenServices.GetRemarkViewGrid(configuretView, Remark, (int)pararms.page, (int)pararms.rows));
  229. }
  230. /// <summary>
  231. /// 验证
  232. /// </summary>
  233. /// <param name="studentChargePaymentID"></param>
  234. /// <param name="userID"></param>
  235. /// <param name="chargeYearID"></param>
  236. /// <param name="chargeProjectID"></param>
  237. /// <param name="amount"></param>
  238. /// <param name="chargeDate"></param>
  239. /// <returns></returns>
  240. [HttpPost]
  241. public ActionResult Verification(Guid? studentChargePaymentID, Guid? userID, int? chargeYearID,
  242. Guid? chargeProjectID, decimal? amount, DateTime? chargeDate)
  243. {
  244. return Json(StudentChargePaymenServices.GetVerification(studentChargePaymentID, userID, chargeYearID,
  245. chargeProjectID, amount, chargeDate));
  246. }
  247. /// <summary>
  248. /// 导出Excel
  249. /// </summary>
  250. /// <returns></returns>
  251. [HttpPost]
  252. public ActionResult Excel()
  253. {
  254. NpoiExcelHelper neh = new NpoiExcelHelper();
  255. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
  256. var collegeID = Request.Form["CollegeDropdown"].ParseStrTo<Guid>();
  257. var yearID = Request.Form["SchoolyearDictionaryDropDown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["SchoolyearDictionaryDropDown"].ParseStrTo<int>();
  258. var standardID = Request.Form["StandardDictionaryDropDown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["StandardDictionaryDropDown"].ParseStrTo<int>();
  259. var educationID = Request.Form["DictionaryEducation"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryEducation"].ParseStrTo<int>();
  260. var learningFormID = Request.Form["DictionaryLearningform"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryLearningform"].ParseStrTo<int>();
  261. var learnSystem = Request.Form["DictionaryLearnSystem"].ToString();
  262. var chargeYearID = Request.Form["ChargeYearDropDown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["ChargeYearDropDown"].ParseStrTo<int>();
  263. var chargeProjectID = Request.Form["ChargeProjectComboGrid"].ParseStrTo<Guid>();
  264. //在校状态
  265. var inSchoolStatus = Request.Form["DictionaryInschoolStatus"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryInschoolStatus"].ParseStrTo<int>();
  266. //是否圆梦计划
  267. var isDream = Request.Form["IsDreamDropDown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["IsDreamDropDown"].ParseStrTo<int>();
  268. //缴费标记
  269. var chargeTagID = Request.Form["DictionaryChargeTag"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryChargeTag"].ParseStrTo<int>();
  270. //备注
  271. var remark = Request.Form["DictionaryRemark"].ToString();
  272. //统计
  273. var amountCount = StudentChargePaymenServices.GetAmountCount(configuretView, collegeID, yearID, standardID,
  274. educationID, learningFormID, learnSystem, chargeYearID, chargeProjectID,
  275. inSchoolStatus, isDream, chargeTagID, remark, 1, 1);
  276. var dt = StudentChargePaymenServices.GetStudentChargePaymenList(configuretView, collegeID, yearID, standardID, educationID,
  277. learningFormID, learnSystem, chargeYearID, chargeProjectID, inSchoolStatus, isDream, chargeTagID, remark)
  278. .Select(x => new
  279. {
  280. x.StudentNo,
  281. x.UserName,
  282. x.SexName,
  283. x.ClassNo,
  284. x.ClassName,
  285. x.GradeMajorCode,
  286. x.GradeMajorStr,
  287. x.CollegeCode,
  288. x.CollegeName,
  289. x.ChargeYear,
  290. x.ChargeProjectStr,
  291. x.StandardAmount,
  292. x.ChargeAmount,
  293. x.ActualAmount,
  294. x.ChargeTagName,
  295. x.Amount,
  296. x.ChargeDate,
  297. x.GradeStr,
  298. x.StandardID,
  299. x.StandardCode,
  300. x.MajorStr,
  301. x.EducationName,
  302. x.LearningformName,
  303. x.LearnSystem,
  304. x.IsDreamProject,
  305. x.InSchoolStatusName,
  306. x.StudentStatusName,
  307. x.Remark
  308. }).ToTable();
  309. //追加统计列
  310. DataRow newRow = dt.NewRow();
  311. newRow[0] = "统计:";
  312. newRow[15] = amountCount ?? 0;
  313. dt.Rows.Add(newRow);
  314. string[] liststring = { "学号", "姓名", "性别", "班级编号", "班级名称", "年级专业编号", "年级专业名称",
  315. RSL.Get("CollegeCode"), RSL.Get("CollegeName"), "缴费学年", "收费项目",
  316. "应收金额", "调整金额", "实收金额", "缴费标记", "缴费金额", "缴费日期",
  317. "年级", "专业ID(Value)", "专业代码", "专业名称", RSL.Get("EducationID"), "学习形式",
  318. "学制", "是否圆梦计划", "在校状态", "学籍状态", "备注"
  319. };
  320. neh.Export(dt, liststring, "学生缴费信息" + DateTime.Now.ToString("yyyyMMdd"));
  321. return Json(new ReturnMessage()
  322. {
  323. IsSuccess = true,
  324. Message = "导出成功。"
  325. });
  326. }
  327. /// <summary>
  328. /// Excel导入
  329. /// </summary>
  330. /// <param name="errorFile"></param>
  331. /// <param name="operationTips"></param>
  332. /// <returns></returns>
  333. [HttpGet]
  334. public ActionResult Import(string errorFile, string operationTips)
  335. {
  336. ViewBag.ErrorFile = errorFile;
  337. if (string.IsNullOrEmpty(operationTips))
  338. {
  339. operationTips = "点击查看失败原因...";
  340. }
  341. ViewBag.operationTips = operationTips;
  342. return View();
  343. }
  344. /// <summary>
  345. /// Excel导入
  346. /// </summary>
  347. /// <param name="file"></param>
  348. /// <returns></returns>
  349. [HttpPost]
  350. public ActionResult Import(HttpPostedFileBase file)
  351. {
  352. try
  353. {
  354. if (!NpoiExcelHelper.GetIsCompatible(file.FileName))
  355. {
  356. throw new Exception("格式错误,只允许导入xls或xlsx格式的Excel文件。");
  357. }
  358. //注:只获取Excel模板中的有效列
  359. Dictionary<string, string> cellheader = new Dictionary<string, string>
  360. {
  361. { "StudentNo", "学号" }, //学号
  362. { "ChargeProjectStr", "收费项目" }, //收费项目
  363. { "ChargeYearStr", "缴费学年" }, //缴费学年
  364. { "ChargeDateStr", "缴费日期" }, //缴费日期
  365. { "AmountStr", "缴费金额" }, //缴费金额
  366. { "Remark", "备注" }, //备注
  367. { "ErrorMessage", "未导入原因" }
  368. };
  369. StringBuilder errorMsg = new StringBuilder(); // 错误信息
  370. string sourceWebPath = FileUploadHelper.UploadFile(file);
  371. var sourcePhysicalPath = Server.MapPath(sourceWebPath);
  372. List<StudentChargePaymenView> errList = new List<StudentChargePaymenView>();
  373. List<StudentChargePaymenView> dataList = new List<StudentChargePaymenView>();
  374. int? inCount = 0; //导入个数
  375. int? upCount = 0; //更新个数
  376. int? errCount = 0; //失败个数
  377. //导入
  378. StudentChargePaymenServices.StudentChargePaymenImport(cellheader, out inCount, out upCount, out errList,
  379. out errCount, sourcePhysicalPath);
  380. System.IO.File.Delete(sourcePhysicalPath);//删除本地缓存文件
  381. if (errList.Count() > 0)
  382. {
  383. //获取错误数据文件路径
  384. string errorWebPath = string.Format("{0}", NpoiExcelHelper
  385. .EntityListToExcel2003(cellheader, errList, "学生缴费导入失败文件", sourcePhysicalPath));
  386. ViewBag.ErrorFile = errorWebPath;
  387. string Errinfo = string.Format("提示:{0}个学生缴费成功,{1}个学生缴费更新成功,{2}个学生缴费失败,点击查看。",
  388. inCount, upCount, errCount);
  389. ViewBag.operationTips = Errinfo;
  390. return RedirectToAction("MsgShow", "Common", new
  391. {
  392. WindowID = "none",
  393. msg = Errinfo,
  394. url = Url.Action("Import").AddMenuParameter() + "&errorFile="
  395. + errorWebPath + "&operationTips=" + Errinfo + "&WindowID=" + Request["WindowID"]
  396. });
  397. }
  398. else
  399. {
  400. string successInfo = string.Format("提示:{0}个学生缴费成功,{1}个学生缴费更新成功。", inCount, upCount);
  401. return RedirectToAction("MsgShow", "Common", new
  402. {
  403. WindowID = Request["WindowID"],
  404. msg = successInfo,
  405. url = Url.Action("List").AddMenuParameter()
  406. });
  407. }
  408. }
  409. catch (Exception ex)
  410. {
  411. return RedirectToAction("MsgShow", "Common", new
  412. {
  413. WindowID = "none",
  414. msg = "导入失败,原因:" + ex.Message,
  415. url = Url.Action("Import").AddMenuParameter() + "&WindowID=" + Request["WindowID"]
  416. });
  417. }
  418. }
  419. }
  420. }