123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.Mvc;
- using EMIS.ViewModel;
- using EMIS.Web.Controls;
- using EMIS.CommonLogic.ExamManage;
- using EMIS.Entities;
- using EMIS.CommonLogic.SystemSetting;
- using Bowin.Common.Utility;
- using Bowin.Common.Exceptions;
- using Bowin.Common.Data;
- using Bowin.Web.Controls.Mvc;
- using EMIS.ViewModel.ExamManage;
- namespace EMIS.Web.Controllers.ExamManage
- {
- [Authorization]
- public class ChargeProjectController : Controller
- {
- public IProjectFeeServices IProjectFeeService { get; set; }
- public IDictionaryServices DictionaryService { get; set; }
- /// <summary>
- /// 收费项目页面
- /// </summary>
- /// <returns></returns>
- public ActionResult List()
- {
- return View();
- }
- /// <summary>
- ///项目设置列表页面
- /// </summary>
- /// <returns></returns>
- public ActionResult ProjectList()
- {
- return View();
- }
- /// <summary>
- /// 收费项目列表查询
- /// </summary>
- /// <param name="pararms"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult List(QueryParamsModel pararms)
- {
- ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
- var ExaminationProjectFeeID = Request["ExaminationProjectFeeID"].ParseStrTo<Guid>();
- configuretView.Attribute = "ExaminationProjectFeeID";
- configuretView.Condition = "=";
- configuretView.ConditionValue = ExaminationProjectFeeID.ToString();
- return base.Json(IProjectFeeService.GetProjectFeeTypeGrid(configuretView, (int)pararms.page, (int)pararms.rows));
- }
- /// <summary>
- /// 项目类型列表查询
- /// </summary>
- /// <param name="pararms"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult GetExaminationTypeList(QueryParamsModel pararms)
- {
- List<ConfiguretView> configuretViews = new List<ConfiguretView>();
- configuretViews.Add(ConfiguretExtensions.GetConfiguretermsView(pararms));
- configuretViews.AddRange(pararms.getConditions());
- return base.Json(IProjectFeeService.GetExaminationTypeList((int)pararms.page, (int)pararms.rows, configuretViews.ToArray()));
- }
- [HttpPost]
- public ActionResult ExaminationTypeDropdownList(DropdownListBindType? bindType)
- {
- var typeList = IProjectFeeService.GetExaminationTypeList()
- .Select(x => new DropdownListItem { Text = x.Name, Value = x.ExaminationTypeID }).ToList();
- DropdownListBindType dbt = bindType == null ? DropdownListBindType.SelectAll : bindType.Value;
- DropdownList.FormatDropdownItemList(dbt, typeList);
- return base.Json(typeList);
- }
- /// <summary>
- /// 考试科目列表查询
- /// </summary>
- /// <param name="pararms"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult GetProjectSubjectListViewGrid(QueryParamsModel pararms)
- {
- ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
- var ExaminationProjectID = pararms.getExtraString("ExaminationProjectID");
- if (!string.IsNullOrEmpty(ExaminationProjectID))
- {
- configuretView.Attribute = "ExaminationProjectID";
- configuretView.Condition = "=";
- configuretView.ConditionValue = ExaminationProjectID;
- }
- return base.Json(IProjectFeeService.GetProjectSubjectListViewGrid(configuretView, (int)pararms.page, (int)pararms.rows));
- }
- /// <summary>
- /// 收费项目编辑页
- /// </summary>
- /// <param name="ProjectFeeTypeID"></param>
- /// <param name="ExaminationProjectFeeID"></param>
- /// <returns></returns>
- [HttpGet]
- public ActionResult Edit(Guid? ProjectFeeTypeID, Guid? ExaminationProjectFeeID)
- {
- ProjectFeeTypeView projectFeeTypeView = new ProjectFeeTypeView() { ExaminationProjectFeeID = ExaminationProjectFeeID };
- if (ProjectFeeTypeID.HasValue && ProjectFeeTypeID != Guid.Empty)
- {
- projectFeeTypeView = IProjectFeeService.GetProjectFeeType(ProjectFeeTypeID);
- }
- return View(projectFeeTypeView);
- }
- /// <summary>
- /// 收费项目编辑页提交
- /// </summary>
- /// <param name="campusView"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult Edit(ProjectFeeTypeView view)
- {
- try
- {
- var feetype = IProjectFeeService.GetProjectFeeTypeList(x => (x.FeeTypeID == view.FeeTypeID && x.ExaminationProjectFeeID == view.ExaminationProjectFeeID) && x.ExaminationProjectFeeTypeID != view.ExaminationProjectFeeTypeID).FirstOrDefault();
- if (feetype != null)
- {
- return Json(new ReturnMessage()
- {
- IsSuccess = false,
- Message = "收费项已经存在,不允许重复。"
- });
- }
- IProjectFeeService.ProjectFeeTypeEdit(view);
- return Json(new ReturnMessage()
- {
- IsSuccess = true,
- Message = "保存成功。"
- });
- }
- catch (Exception ex)
- {
- return Json(new ReturnMessage()
- {
- IsSuccess = false,
- Message = "保存失败,原因:" + ex.Message
- });
- }
- }
- /// <summary>
- /// 删除项目设置
- /// </summary>
- /// <param name="campusIDs"></param>
- /// <returns></returns>
- [HttpPost]
- public JsonResult DeleteProjectFee(string ExaminationProjectFeeIDs)
- {
- try
- {
- List<Guid?> list = ExaminationProjectFeeIDs.Split(',').Where(x => !string.IsNullOrEmpty(x))
- .Select(x => (Guid?)new Guid(x)).ToList();
- IProjectFeeService.ProjectFeeDelete(list);
- return base.Json("删除成功。");
- }
- catch (Exception ex)
- {
- string mge = ex.Message;
- System.Data.SqlClient.SqlException num = ExceptionHelper.GetSqlException(ex);
- if (num != null)
- {
- if (num.Number == 547)
- {
- mge = "请先删除与其有关联的数据";
- }
- }
- return base.Json("删除失败,原因:" + mge);
- }
- }
- /// <summary>
- /// 删除项目费用
- /// </summary>
- /// <param name="campusIDs"></param>
- /// <returns></returns>
- [HttpPost]
- public JsonResult DeleteProjectFeeType(string ExaminationProjectFeeTypeIDs)
- {
- try
- {
- List<Guid?> list = ExaminationProjectFeeTypeIDs.Split(',').Where(x => !string.IsNullOrEmpty(x))
- .Select(x => (Guid?)new Guid(x)).ToList();
- IProjectFeeService.ProjectFeeTypeDelete(list);
- return base.Json("删除成功。");
- }
- catch (Exception ex)
- {
- string mge = ex.Message;
- System.Data.SqlClient.SqlException num = ExceptionHelper.GetSqlException(ex);
- if (num != null)
- {
- if (num.Number == 547)
- {
- mge = "请先删除与其有关联的数据";
- }
- }
- return base.Json("删除失败,原因:" + mge);
- }
- }
- /// <summary>
- /// 项目列表查询
- /// </summary>
- /// <param name="pararms"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult GetProjectListViewGrid(QueryParamsModel pararms)
- {
- List<ConfiguretView> configuretViews = new List<ConfiguretView>();
- configuretViews.Add(ConfiguretExtensions.GetConfiguretermsView(pararms));
- configuretViews.AddRange(pararms.getConditions());
- var Name = configuretViews.Where(x => x.Attribute == "Name").SingleOrDefault();
- if (Name != null) Name.Condition = "中";
- return base.Json(IProjectFeeService.GetProjectListViewGrid((int)pararms.page, (int)pararms.rows,
- configuretViews.ToArray()));
- }
- /// <summary>
- /// 项目列表查询
- /// </summary>
- /// <param name="pararms"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult ProjectDropdownList(DropdownListBindType? bindType, Guid? examinationTypeID)
- {
- var condition = new ConfiguretView { Attribute = "ExaminationTypeID", Condition = "=", ConditionValue = (examinationTypeID == null ? null : examinationTypeID.Value.ToString()) };
- var projectList = IProjectFeeService.GetProjectList(condition).ToList()
- .Select(x => new DropdownListItem { Text = x.Name, Value = x.ExaminationProjectID }).ToList();
- DropdownListBindType dbt = bindType == null ? DropdownListBindType.SelectAll : bindType.Value;
- DropdownList.FormatDropdownItemList(dbt, projectList);
- return base.Json(projectList);
- }
- [HttpPost]
- public ActionResult ExaminationSubjectDropdownList(DropdownListBindType? bindType, Guid? examinationProjectID)
- {
- var examinationSubjectList = IProjectFeeService.GetProjectSubjectListViewList(examinationProjectID)
- .Select(x => new DropdownListItem { Text = x.ExaminationSubject, Value = x.ExaminationSubjectID }).ToList();
- DropdownListBindType dbt = bindType == null ? DropdownListBindType.SelectAll : bindType.Value;
- DropdownList.FormatDropdownItemList(dbt, examinationSubjectList);
- return base.Json(examinationSubjectList);
- }
- [HttpPost]
- public ActionResult ProjectExcel(QueryParamsModel pararms)
- {
- List<ConfiguretView> configuretViews = new List<ConfiguretView>();
- configuretViews.Add(ConfiguretExtensions.GetConfiguretermsView(pararms));
- configuretViews.AddRange(pararms.getConditions());
- var query = IProjectFeeService.GetProjectList(configuretViews.ToArray());
- var SelectedID = Request.Form["SelectedID"];
- List<Guid?> selectIDlist = new List<Guid?>();
- if (SelectedID != "" && SelectedID != null)
- {
- selectIDlist = SelectedID.SplitIDString();
- query = query.Where(x => selectIDlist.Contains(x.ExaminationProjectID));
- }
- var dt = query.ToList().Select(q =>
- new
- {
- q.Name,
- q.ExaminationLevelText,
- q.ExaminationType,
- q.IssuedByIDText
- }).ToTable();
- NpoiExcelHelper neh = new NpoiExcelHelper();
- string[] liststring = {
- "项目名称","级别","考试类型","发证机关"};
- neh.Export(dt, liststring, "考试项目信息列表" + DateTime.Now.ToString("yyyyMMddhhmmss"));
- return RedirectToAction("MsgShow", "Common", new
- {
- msg = "导出成功!",
- url = Url.Content("~/ChargeProject/ProjectList").AddMenuParameter()
- });
- }
- [HttpPost]
- public ActionResult FeeExcel(QueryParamsModel pararms)
- {
- List<ConfiguretView> configuretViews = new List<ConfiguretView>();
- configuretViews.Add(ConfiguretExtensions.GetConfiguretermsView(pararms));
- configuretViews.AddRange(pararms.getConditions());
- var query = IProjectFeeService.GetProjectFeeList(configuretViews.ToArray());
- var SelectedID = Request.Form["SelectedID"];
- List<Guid?> selectIDlist = new List<Guid?>();
- if (SelectedID != "" && SelectedID != null)
- {
- selectIDlist = SelectedID.SplitIDString();
- query = query.Where(x => selectIDlist.Contains(x.ExaminationProjectFeeID));
- }
- var dt = query.ToList().Select(q =>
- new
- {
- q.ExaminationType,
- q.ProjectName,
- q.Name,
- }).ToTable();
- NpoiExcelHelper neh = new NpoiExcelHelper();
- string[] liststring = {
- "考试类型","项目名称","收费标准名称"};
- neh.Export(dt, liststring, "收费项目信息列表" + DateTime.Now.ToString("yyyyMMddhhmmss"));
- return RedirectToAction("MsgShow", "Common", new
- {
- msg = "导出成功!",
- url = Url.Content("~/ChargeProject/ProjectList").AddMenuParameter()
- });
- }
- /// <summary>
- /// 项目设置列表查询
- /// </summary>
- /// <param name="pararms"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult GetProjectFeeListViewGrid(QueryParamsModel pararms)
- {
- List<ConfiguretView> configuretViews = new List<ConfiguretView>();
- configuretViews.Add(ConfiguretExtensions.GetConfiguretermsView(pararms));
- configuretViews.AddRange(pararms.getConditions());
- return base.Json(IProjectFeeService.GetProjectFeeGrid((int)pararms.page, (int)pararms.rows, configuretViews.ToArray()));
- }
- /// <summary>
- /// 项目费用编辑页
- /// </summary>
- /// <param name="ExaminationProjectFeeID"></param>
- /// <returns></returns>
- [HttpGet]
- public ActionResult FeeEdit(Guid? ExaminationProjectFeeID, bool? isCopy)
- {
- ExaminationProjectFeeView projectFeeView = new ExaminationProjectFeeView() { ExaminationProjectFeeID = Guid.NewGuid() };
- if (ExaminationProjectFeeID.HasValue && ExaminationProjectFeeID != Guid.Empty)
- {
- projectFeeView = IProjectFeeService.GetProjectFee(ExaminationProjectFeeID);
- //如果是复制新增
- if (isCopy == true)
- {
- projectFeeView.ExaminationProjectFeeID = Guid.NewGuid();
- projectFeeView.RecordStatus = (int)EMIS.ViewModel.SYS_STATUS.UNUSABLE;
- IProjectFeeService.ProjectFeeEdit(projectFeeView);
- var FeeTypeList = IProjectFeeService.GetProjectFeeTypeList(s => s.ExaminationProjectFeeID == ExaminationProjectFeeID).ToList();
- FeeTypeList.ForEach(s =>
- {
- s.ExaminationProjectFeeID = projectFeeView.ExaminationProjectFeeID;
- s.ExaminationProjectFeeTypeID = Guid.NewGuid();
- IProjectFeeService.ProjectFeeTypeEdit(s);
- });
- }
- }
- else
- {
- projectFeeView.RecordStatus = (int)EMIS.ViewModel.SYS_STATUS.UNUSABLE;
- IProjectFeeService.ProjectFeeEdit(projectFeeView);
- }
- return View(projectFeeView);
- }
- /// <summary>
- /// 项目费用编辑提交
- /// </summary>
- /// <param name="campusView"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult FeeEdit(ExaminationProjectFeeView view)
- {
- try
- {
- var model = IProjectFeeService.GetProjectFeeView(x => (x.ExaminationProjectID == view.ExaminationProjectID && x.Name == view.Name) && x.ExaminationProjectFeeID != view.ExaminationProjectFeeID && x.RecordStatus != 0);
- if (model != null)
- {
- return Json(new ReturnMessage()
- {
- IsSuccess = false,
- Message = "同一项目名称,收费标准名称不能重复!"
- });
- }
- view.RecordStatus = (int)EMIS.ViewModel.SYS_STATUS.USABLE;
- IProjectFeeService.ProjectFeeEdit(view);
- return Json(new ReturnMessage()
- {
- IsSuccess = true,
- Message = "保存成功。"
- });
- }
- catch (Exception ex)
- {
- return Json(new ReturnMessage()
- {
- IsSuccess = false,
- Message = "保存失败,原因:" + ex.Message
- });
- }
- }
- /// <summary>
- /// 项目设置编辑页
- /// </summary>
- /// <param name="ExaminationProjectFeeID"></param>
- /// <returns></returns>
- [HttpGet]
- public ActionResult ProjectEdit(Guid? ExaminationProjectID)
- {
- ExaminationProjectView projectFeeView = new ExaminationProjectView() { ExaminationProjectID = Guid.NewGuid() };
- if (ExaminationProjectID.HasValue && ExaminationProjectID != Guid.Empty)
- {
- projectFeeView = IProjectFeeService.GetProject(ExaminationProjectID);
- }
- return View(projectFeeView);
- }
- /// <summary>
- /// 项目设置页面提交
- /// </summary>
- /// <param name="campusView"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult ProjectEdit(ExaminationProjectView view)
- {
- try
- {
- //同一类型需作唯一性判断
- var model = IProjectFeeService.GetProjectView(x => x.Name == view.Name && x.ExaminationProjectID != view.ExaminationProjectID);
- if (model != null)
- {
- return Json(new ReturnMessage()
- {
- IsSuccess = false,
- Message = "项目名称不允许重复!"
- });
- }
- var subjectList = DataGrid.GetTableData<ExamSubjectView>("dgSubjectList");
- IProjectFeeService.ProjectEdit(view, subjectList);
- return Json(new ReturnMessage()
- {
- IsSuccess = true,
- Message = "保存成功。"
- });
- }
- catch (Exception ex)
- {
- return Json(new ReturnMessage()
- {
- IsSuccess = false,
- Message = "保存失败,原因:" + ex.Message
- });
- }
- }
- [HttpGet]
- public ActionResult SelectSubject(Guid? examinationProjectID)
- {
- ViewBag.ExaminationProjectID = examinationProjectID;
- return View();
- }
- [HttpPost]
- public ActionResult SubjectListByProjectID(QueryParamsModel pararms, Guid? projectID)
- {
- ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
- //examinationPlanID = Request.Form["examinationPlanID"].ParseStrTo<Guid>();
- return base.Json(IProjectFeeService.GetSubjectByProjectIDGrid(configuretView, projectID));
- }
- [HttpPost]
- public ActionResult SubjectList(QueryParamsModel pararms)
- {
- ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
- //examinationPlanID = Request.Form["examinationPlanID"].ParseStrTo<Guid>();
- return base.Json(IProjectFeeService.GetSubjectListGrid(configuretView, (int)pararms.page, (int)pararms.rows));
- }
- /// <summary>
- /// 删除项目
- /// </summary>
- /// <param name="campusIDs"></param>
- /// <returns></returns>
- [HttpPost]
- public JsonResult DeleteProject(string ExaminationProjectIDs)
- {
- try
- {
- List<Guid?> list = ExaminationProjectIDs.Split(',').Where(x => !string.IsNullOrEmpty(x))
- .Select(x => (Guid?)new Guid(x)).ToList();
- IProjectFeeService.ProjectDelete(list);
- return base.Json("删除成功。");
- }
- catch (Exception ex)
- {
- string mge = ex.Message;
- System.Data.SqlClient.SqlException num = ExceptionHelper.GetSqlException(ex);
- if (num != null)
- {
- if (num.Number == 547)
- {
- mge = "请先删除与其有关联的数据";
- }
- }
- return base.Json("删除失败,原因:" + mge);
- }
- }
- }
- }
|