ChargeProjectController.cs 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527
  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.ExamManage;
  9. using EMIS.Entities;
  10. using EMIS.CommonLogic.SystemSetting;
  11. using Bowin.Common.Utility;
  12. using Bowin.Common.Exceptions;
  13. using Bowin.Common.Data;
  14. using Bowin.Web.Controls.Mvc;
  15. using EMIS.ViewModel.ExamManage;
  16. namespace EMIS.Web.Controllers.ExamManage
  17. {
  18. [Authorization]
  19. public class ChargeProjectController : Controller
  20. {
  21. public IProjectFeeServices IProjectFeeService { get; set; }
  22. public IDictionaryServices DictionaryService { 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. /// <returns></returns>
  35. public ActionResult ProjectList()
  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 ExaminationProjectFeeID = Request["ExaminationProjectFeeID"].ParseStrTo<Guid>();
  49. configuretView.Attribute = "ExaminationProjectFeeID";
  50. configuretView.Condition = "=";
  51. configuretView.ConditionValue = ExaminationProjectFeeID.ToString();
  52. return base.Json(IProjectFeeService.GetProjectFeeTypeGrid(configuretView, (int)pararms.page, (int)pararms.rows));
  53. }
  54. /// <summary>
  55. /// 项目类型列表查询
  56. /// </summary>
  57. /// <param name="pararms"></param>
  58. /// <returns></returns>
  59. [HttpPost]
  60. public ActionResult GetExaminationTypeList(QueryParamsModel pararms)
  61. {
  62. List<ConfiguretView> configuretViews = new List<ConfiguretView>();
  63. configuretViews.Add(ConfiguretExtensions.GetConfiguretermsView(pararms));
  64. configuretViews.AddRange(pararms.getConditions());
  65. return base.Json(IProjectFeeService.GetExaminationTypeList((int)pararms.page, (int)pararms.rows, configuretViews.ToArray()));
  66. }
  67. [HttpPost]
  68. public ActionResult ExaminationTypeDropdownList(DropdownListBindType? bindType)
  69. {
  70. var typeList = IProjectFeeService.GetExaminationTypeList()
  71. .Select(x => new DropdownListItem { Text = x.Name, Value = x.ExaminationTypeID }).ToList();
  72. DropdownListBindType dbt = bindType == null ? DropdownListBindType.SelectAll : bindType.Value;
  73. DropdownList.FormatDropdownItemList(dbt, typeList);
  74. return base.Json(typeList);
  75. }
  76. /// <summary>
  77. /// 考试科目列表查询
  78. /// </summary>
  79. /// <param name="pararms"></param>
  80. /// <returns></returns>
  81. [HttpPost]
  82. public ActionResult GetProjectSubjectListViewGrid(QueryParamsModel pararms)
  83. {
  84. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  85. var ExaminationProjectID = pararms.getExtraString("ExaminationProjectID");
  86. if (!string.IsNullOrEmpty(ExaminationProjectID))
  87. {
  88. configuretView.Attribute = "ExaminationProjectID";
  89. configuretView.Condition = "=";
  90. configuretView.ConditionValue = ExaminationProjectID;
  91. }
  92. return base.Json(IProjectFeeService.GetProjectSubjectListViewGrid(configuretView, (int)pararms.page, (int)pararms.rows));
  93. }
  94. /// <summary>
  95. /// 收费项目编辑页
  96. /// </summary>
  97. /// <param name="ProjectFeeTypeID"></param>
  98. /// <param name="ExaminationProjectFeeID"></param>
  99. /// <returns></returns>
  100. [HttpGet]
  101. public ActionResult Edit(Guid? ProjectFeeTypeID, Guid? ExaminationProjectFeeID)
  102. {
  103. ProjectFeeTypeView projectFeeTypeView = new ProjectFeeTypeView() { ExaminationProjectFeeID = ExaminationProjectFeeID };
  104. if (ProjectFeeTypeID.HasValue && ProjectFeeTypeID != Guid.Empty)
  105. {
  106. projectFeeTypeView = IProjectFeeService.GetProjectFeeType(ProjectFeeTypeID);
  107. }
  108. return View(projectFeeTypeView);
  109. }
  110. /// <summary>
  111. /// 收费项目编辑页提交
  112. /// </summary>
  113. /// <param name="campusView"></param>
  114. /// <returns></returns>
  115. [HttpPost]
  116. public ActionResult Edit(ProjectFeeTypeView view)
  117. {
  118. try
  119. {
  120. var feetype = IProjectFeeService.GetProjectFeeTypeList(x => (x.FeeTypeID == view.FeeTypeID && x.ExaminationProjectFeeID == view.ExaminationProjectFeeID) && x.ExaminationProjectFeeTypeID != view.ExaminationProjectFeeTypeID).FirstOrDefault();
  121. if (feetype != null)
  122. {
  123. return Json(new ReturnMessage()
  124. {
  125. IsSuccess = false,
  126. Message = "收费项已经存在,不允许重复。"
  127. });
  128. }
  129. IProjectFeeService.ProjectFeeTypeEdit(view);
  130. return Json(new ReturnMessage()
  131. {
  132. IsSuccess = true,
  133. Message = "保存成功。"
  134. });
  135. }
  136. catch (Exception ex)
  137. {
  138. return Json(new ReturnMessage()
  139. {
  140. IsSuccess = false,
  141. Message = "保存失败,原因:" + ex.Message
  142. });
  143. }
  144. }
  145. /// <summary>
  146. /// 删除项目设置
  147. /// </summary>
  148. /// <param name="campusIDs"></param>
  149. /// <returns></returns>
  150. [HttpPost]
  151. public JsonResult DeleteProjectFee(string ExaminationProjectFeeIDs)
  152. {
  153. try
  154. {
  155. List<Guid?> list = ExaminationProjectFeeIDs.Split(',').Where(x => !string.IsNullOrEmpty(x))
  156. .Select(x => (Guid?)new Guid(x)).ToList();
  157. IProjectFeeService.ProjectFeeDelete(list);
  158. return base.Json("删除成功。");
  159. }
  160. catch (Exception ex)
  161. {
  162. string mge = ex.Message;
  163. System.Data.SqlClient.SqlException num = ExceptionHelper.GetSqlException(ex);
  164. if (num != null)
  165. {
  166. if (num.Number == 547)
  167. {
  168. mge = "请先删除与其有关联的数据";
  169. }
  170. }
  171. return base.Json("删除失败,原因:" + mge);
  172. }
  173. }
  174. /// <summary>
  175. /// 删除项目费用
  176. /// </summary>
  177. /// <param name="campusIDs"></param>
  178. /// <returns></returns>
  179. [HttpPost]
  180. public JsonResult DeleteProjectFeeType(string ExaminationProjectFeeTypeIDs)
  181. {
  182. try
  183. {
  184. List<Guid?> list = ExaminationProjectFeeTypeIDs.Split(',').Where(x => !string.IsNullOrEmpty(x))
  185. .Select(x => (Guid?)new Guid(x)).ToList();
  186. IProjectFeeService.ProjectFeeTypeDelete(list);
  187. return base.Json("删除成功。");
  188. }
  189. catch (Exception ex)
  190. {
  191. string mge = ex.Message;
  192. System.Data.SqlClient.SqlException num = ExceptionHelper.GetSqlException(ex);
  193. if (num != null)
  194. {
  195. if (num.Number == 547)
  196. {
  197. mge = "请先删除与其有关联的数据";
  198. }
  199. }
  200. return base.Json("删除失败,原因:" + mge);
  201. }
  202. }
  203. /// <summary>
  204. /// 项目列表查询
  205. /// </summary>
  206. /// <param name="pararms"></param>
  207. /// <returns></returns>
  208. [HttpPost]
  209. public ActionResult GetProjectListViewGrid(QueryParamsModel pararms)
  210. {
  211. List<ConfiguretView> configuretViews = new List<ConfiguretView>();
  212. configuretViews.Add(ConfiguretExtensions.GetConfiguretermsView(pararms));
  213. configuretViews.AddRange(pararms.getConditions());
  214. var Name = configuretViews.Where(x => x.Attribute == "Name").SingleOrDefault();
  215. if (Name != null) Name.Condition = "中";
  216. return base.Json(IProjectFeeService.GetProjectListViewGrid((int)pararms.page, (int)pararms.rows,
  217. configuretViews.ToArray()));
  218. }
  219. /// <summary>
  220. /// 项目列表查询
  221. /// </summary>
  222. /// <param name="pararms"></param>
  223. /// <returns></returns>
  224. [HttpPost]
  225. public ActionResult ProjectDropdownList(DropdownListBindType? bindType, Guid? examinationTypeID)
  226. {
  227. var condition = new ConfiguretView { Attribute = "ExaminationTypeID", Condition = "=", ConditionValue = (examinationTypeID == null ? null : examinationTypeID.Value.ToString()) };
  228. var projectList = IProjectFeeService.GetProjectList(condition).ToList()
  229. .Select(x => new DropdownListItem { Text = x.Name, Value = x.ExaminationProjectID }).ToList();
  230. DropdownListBindType dbt = bindType == null ? DropdownListBindType.SelectAll : bindType.Value;
  231. DropdownList.FormatDropdownItemList(dbt, projectList);
  232. return base.Json(projectList);
  233. }
  234. [HttpPost]
  235. public ActionResult ExaminationSubjectDropdownList(DropdownListBindType? bindType, Guid? examinationProjectID)
  236. {
  237. var examinationSubjectList = IProjectFeeService.GetProjectSubjectListViewList(examinationProjectID)
  238. .Select(x => new DropdownListItem { Text = x.ExaminationSubject, Value = x.ExaminationSubjectID }).ToList();
  239. DropdownListBindType dbt = bindType == null ? DropdownListBindType.SelectAll : bindType.Value;
  240. DropdownList.FormatDropdownItemList(dbt, examinationSubjectList);
  241. return base.Json(examinationSubjectList);
  242. }
  243. [HttpPost]
  244. public ActionResult ProjectExcel(QueryParamsModel pararms)
  245. {
  246. List<ConfiguretView> configuretViews = new List<ConfiguretView>();
  247. configuretViews.Add(ConfiguretExtensions.GetConfiguretermsView(pararms));
  248. configuretViews.AddRange(pararms.getConditions());
  249. var query = IProjectFeeService.GetProjectList(configuretViews.ToArray());
  250. var SelectedID = Request.Form["SelectedID"];
  251. List<Guid?> selectIDlist = new List<Guid?>();
  252. if (SelectedID != "" && SelectedID != null)
  253. {
  254. selectIDlist = SelectedID.SplitIDString();
  255. query = query.Where(x => selectIDlist.Contains(x.ExaminationProjectID));
  256. }
  257. var dt = query.ToList().Select(q =>
  258. new
  259. {
  260. q.Name,
  261. q.ExaminationLevelText,
  262. q.ExaminationType,
  263. q.IssuedByIDText
  264. }).ToTable();
  265. NpoiExcelHelper neh = new NpoiExcelHelper();
  266. string[] liststring = {
  267. "项目名称","级别","考试类型","发证机关"};
  268. neh.Export(dt, liststring, "考试项目信息列表" + DateTime.Now.ToString("yyyyMMddhhmmss"));
  269. return RedirectToAction("MsgShow", "Common", new
  270. {
  271. msg = "导出成功!",
  272. url = Url.Content("~/ChargeProject/ProjectList").AddMenuParameter()
  273. });
  274. }
  275. [HttpPost]
  276. public ActionResult FeeExcel(QueryParamsModel pararms)
  277. {
  278. List<ConfiguretView> configuretViews = new List<ConfiguretView>();
  279. configuretViews.Add(ConfiguretExtensions.GetConfiguretermsView(pararms));
  280. configuretViews.AddRange(pararms.getConditions());
  281. var query = IProjectFeeService.GetProjectFeeList(configuretViews.ToArray());
  282. var SelectedID = Request.Form["SelectedID"];
  283. List<Guid?> selectIDlist = new List<Guid?>();
  284. if (SelectedID != "" && SelectedID != null)
  285. {
  286. selectIDlist = SelectedID.SplitIDString();
  287. query = query.Where(x => selectIDlist.Contains(x.ExaminationProjectFeeID));
  288. }
  289. var dt = query.ToList().Select(q =>
  290. new
  291. {
  292. q.ExaminationType,
  293. q.ProjectName,
  294. q.Name,
  295. }).ToTable();
  296. NpoiExcelHelper neh = new NpoiExcelHelper();
  297. string[] liststring = {
  298. "考试类型","项目名称","收费标准名称"};
  299. neh.Export(dt, liststring, "收费项目信息列表" + DateTime.Now.ToString("yyyyMMddhhmmss"));
  300. return RedirectToAction("MsgShow", "Common", new
  301. {
  302. msg = "导出成功!",
  303. url = Url.Content("~/ChargeProject/ProjectList").AddMenuParameter()
  304. });
  305. }
  306. /// <summary>
  307. /// 项目设置列表查询
  308. /// </summary>
  309. /// <param name="pararms"></param>
  310. /// <returns></returns>
  311. [HttpPost]
  312. public ActionResult GetProjectFeeListViewGrid(QueryParamsModel pararms)
  313. {
  314. List<ConfiguretView> configuretViews = new List<ConfiguretView>();
  315. configuretViews.Add(ConfiguretExtensions.GetConfiguretermsView(pararms));
  316. configuretViews.AddRange(pararms.getConditions());
  317. return base.Json(IProjectFeeService.GetProjectFeeGrid((int)pararms.page, (int)pararms.rows, configuretViews.ToArray()));
  318. }
  319. /// <summary>
  320. /// 项目费用编辑页
  321. /// </summary>
  322. /// <param name="ExaminationProjectFeeID"></param>
  323. /// <returns></returns>
  324. [HttpGet]
  325. public ActionResult FeeEdit(Guid? ExaminationProjectFeeID, bool? isCopy)
  326. {
  327. ExaminationProjectFeeView projectFeeView = new ExaminationProjectFeeView() { ExaminationProjectFeeID = Guid.NewGuid() };
  328. if (ExaminationProjectFeeID.HasValue && ExaminationProjectFeeID != Guid.Empty)
  329. {
  330. projectFeeView = IProjectFeeService.GetProjectFee(ExaminationProjectFeeID);
  331. //如果是复制新增
  332. if (isCopy == true)
  333. {
  334. projectFeeView.ExaminationProjectFeeID = Guid.NewGuid();
  335. projectFeeView.RecordStatus = (int)EMIS.ViewModel.SYS_STATUS.UNUSABLE;
  336. IProjectFeeService.ProjectFeeEdit(projectFeeView);
  337. var FeeTypeList = IProjectFeeService.GetProjectFeeTypeList(s => s.ExaminationProjectFeeID == ExaminationProjectFeeID).ToList();
  338. FeeTypeList.ForEach(s =>
  339. {
  340. s.ExaminationProjectFeeID = projectFeeView.ExaminationProjectFeeID;
  341. s.ExaminationProjectFeeTypeID = Guid.NewGuid();
  342. IProjectFeeService.ProjectFeeTypeEdit(s);
  343. });
  344. }
  345. }
  346. else
  347. {
  348. projectFeeView.RecordStatus = (int)EMIS.ViewModel.SYS_STATUS.UNUSABLE;
  349. IProjectFeeService.ProjectFeeEdit(projectFeeView);
  350. }
  351. return View(projectFeeView);
  352. }
  353. /// <summary>
  354. /// 项目费用编辑提交
  355. /// </summary>
  356. /// <param name="campusView"></param>
  357. /// <returns></returns>
  358. [HttpPost]
  359. public ActionResult FeeEdit(ExaminationProjectFeeView view)
  360. {
  361. try
  362. {
  363. var model = IProjectFeeService.GetProjectFeeView(x => (x.ExaminationProjectID == view.ExaminationProjectID && x.Name == view.Name) && x.ExaminationProjectFeeID != view.ExaminationProjectFeeID && x.RecordStatus != 0);
  364. if (model != null)
  365. {
  366. return Json(new ReturnMessage()
  367. {
  368. IsSuccess = false,
  369. Message = "同一项目名称,收费标准名称不能重复!"
  370. });
  371. }
  372. view.RecordStatus = (int)EMIS.ViewModel.SYS_STATUS.USABLE;
  373. IProjectFeeService.ProjectFeeEdit(view);
  374. return Json(new ReturnMessage()
  375. {
  376. IsSuccess = true,
  377. Message = "保存成功。"
  378. });
  379. }
  380. catch (Exception ex)
  381. {
  382. return Json(new ReturnMessage()
  383. {
  384. IsSuccess = false,
  385. Message = "保存失败,原因:" + ex.Message
  386. });
  387. }
  388. }
  389. /// <summary>
  390. /// 项目设置编辑页
  391. /// </summary>
  392. /// <param name="ExaminationProjectFeeID"></param>
  393. /// <returns></returns>
  394. [HttpGet]
  395. public ActionResult ProjectEdit(Guid? ExaminationProjectID)
  396. {
  397. ExaminationProjectView projectFeeView = new ExaminationProjectView() { ExaminationProjectID = Guid.NewGuid() };
  398. if (ExaminationProjectID.HasValue && ExaminationProjectID != Guid.Empty)
  399. {
  400. projectFeeView = IProjectFeeService.GetProject(ExaminationProjectID);
  401. }
  402. return View(projectFeeView);
  403. }
  404. /// <summary>
  405. /// 项目设置页面提交
  406. /// </summary>
  407. /// <param name="campusView"></param>
  408. /// <returns></returns>
  409. [HttpPost]
  410. public ActionResult ProjectEdit(ExaminationProjectView view)
  411. {
  412. try
  413. {
  414. //同一类型需作唯一性判断
  415. var model = IProjectFeeService.GetProjectView(x => x.Name == view.Name && x.ExaminationProjectID != view.ExaminationProjectID);
  416. if (model != null)
  417. {
  418. return Json(new ReturnMessage()
  419. {
  420. IsSuccess = false,
  421. Message = "项目名称不允许重复!"
  422. });
  423. }
  424. var subjectList = DataGrid.GetTableData<ExamSubjectView>("dgSubjectList");
  425. IProjectFeeService.ProjectEdit(view, subjectList);
  426. return Json(new ReturnMessage()
  427. {
  428. IsSuccess = true,
  429. Message = "保存成功。"
  430. });
  431. }
  432. catch (Exception ex)
  433. {
  434. return Json(new ReturnMessage()
  435. {
  436. IsSuccess = false,
  437. Message = "保存失败,原因:" + ex.Message
  438. });
  439. }
  440. }
  441. [HttpGet]
  442. public ActionResult SelectSubject(Guid? examinationProjectID)
  443. {
  444. ViewBag.ExaminationProjectID = examinationProjectID;
  445. return View();
  446. }
  447. [HttpPost]
  448. public ActionResult SubjectListByProjectID(QueryParamsModel pararms, Guid? projectID)
  449. {
  450. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  451. //examinationPlanID = Request.Form["examinationPlanID"].ParseStrTo<Guid>();
  452. return base.Json(IProjectFeeService.GetSubjectByProjectIDGrid(configuretView, projectID));
  453. }
  454. [HttpPost]
  455. public ActionResult SubjectList(QueryParamsModel pararms)
  456. {
  457. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  458. //examinationPlanID = Request.Form["examinationPlanID"].ParseStrTo<Guid>();
  459. return base.Json(IProjectFeeService.GetSubjectListGrid(configuretView, (int)pararms.page, (int)pararms.rows));
  460. }
  461. /// <summary>
  462. /// 删除项目
  463. /// </summary>
  464. /// <param name="campusIDs"></param>
  465. /// <returns></returns>
  466. [HttpPost]
  467. public JsonResult DeleteProject(string ExaminationProjectIDs)
  468. {
  469. try
  470. {
  471. List<Guid?> list = ExaminationProjectIDs.Split(',').Where(x => !string.IsNullOrEmpty(x))
  472. .Select(x => (Guid?)new Guid(x)).ToList();
  473. IProjectFeeService.ProjectDelete(list);
  474. return base.Json("删除成功。");
  475. }
  476. catch (Exception ex)
  477. {
  478. string mge = ex.Message;
  479. System.Data.SqlClient.SqlException num = ExceptionHelper.GetSqlException(ex);
  480. if (num != null)
  481. {
  482. if (num.Number == 547)
  483. {
  484. mge = "请先删除与其有关联的数据";
  485. }
  486. }
  487. return base.Json("删除失败,原因:" + mge);
  488. }
  489. }
  490. }
  491. }