123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.Mvc;
- using EMIS.CommonLogic.ExamManage;
- using EMIS.ViewModel;
- using EMIS.Web.Controls;
- using Bowin.Common.Exceptions;
- using Bowin.Common.Utility;
- using Bowin.Common.Data;
- using Bowin.Web.Controls.Mvc;
- namespace EMIS.Web.Controllers.ExamManage
- {
- [Authorization]
- public class ExamProjectControlController : Controller
- {
- public IExamProjectControlServices IExamProjectControlService { get; set; }
- public IExamBatchProjectServices IExamBatchProjectService { get; set; }
- public IProjectFeeServices IProjectFeeService { get; set; }
- //
- // GET: /ExaminationBatch/
- public ActionResult List()
- {
- return View();
- }
- public ActionResult Select()
- {
- return View();
- }
- /// <summary>
- /// 项目列表查询
- /// </summary>
- /// <param name="pararms"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult List(QueryParamsModel pararms)
- {
- List<ConfiguretView> configuretViews = new List<ConfiguretView>();
- configuretViews.Add(ConfiguretExtensions.GetConfiguretermsView(pararms));
- configuretViews.AddRange(pararms.getConditions());
- var StartDate = configuretViews.Where(x => x.Attribute == "StartDate").SingleOrDefault();
- if (StartDate != null) StartDate.Condition = ">=";
- var EndDate = configuretViews.Where(x => x.Attribute == "EndDate").SingleOrDefault();
- if (EndDate != null) EndDate.Condition = "<=";
- return base.Json(IExamProjectControlService.GetListGridView((int)pararms.page, (int)pararms.rows, configuretViews.ToArray()));
- }
- /// <summary>
- /// 控制考试类型列表查询
- /// </summary>
- /// <param name="pararms"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult GetControlExamTypeListViewGrid(QueryParamsModel pararms)
- {
- List<ConfiguretView> configuretViews = new List<ConfiguretView>();
- configuretViews.Add(ConfiguretExtensions.GetConfiguretermsView(pararms));
- configuretViews.AddRange(pararms.getConditions());
- return base.Json(IExamProjectControlService.GetControlExamTypeListViewGrid((int)pararms.page, (int)pararms.rows, configuretViews.ToArray()));
- }
- /// <summary>
- /// 控制考试列表查询
- /// </summary>
- /// <param name="pararms"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult GetControlProjectListViewGrid(QueryParamsModel pararms)
- {
- List<ConfiguretView> configuretViews = new List<ConfiguretView>();
- configuretViews.Add(ConfiguretExtensions.GetConfiguretermsView(pararms));
- configuretViews.AddRange(pararms.getConditions());
- return base.Json(IExamProjectControlService.GetControlProjectListViewGrid((int)pararms.page, (int)pararms.rows, configuretViews.ToArray()));
- }
- /// <summary>
- /// 控制收费项目列表查询
- /// </summary>
- /// <param name="pararms"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult GetControlProjectFeeListViewGrid(QueryParamsModel pararms)
- {
- List<ConfiguretView> configuretViews = new List<ConfiguretView>();
- var ExaminationBatchProjectID = pararms.getExtraGuid("ExaminationBatchProjectID");
- var view = IExamBatchProjectService.GetView(x => x.ExaminationBatchProjectID == ExaminationBatchProjectID);
- if (view != null)
- {
- configuretViews.Add(new ConfiguretView()
- {
- Attribute = "ExaminationProjectID",
- Condition = "=",
- ConditionValue = view.ExaminationProjectID.ToString()
- });
- }
- else {
- configuretViews.Add(new ConfiguretView()
- {
- Attribute = "ExaminationProjectID",
- Condition = "=",
- ConditionValue = null
- });
- }
- return base.Json(IProjectFeeService.GetProjectFeeGrid((int)pararms.page, (int)pararms.rows, configuretViews.ToArray()));
- }
- /// <summary>
- /// 设置编辑页
- /// </summary>
- /// <param name="ExaminationProjectFeeID"></param>
- /// <returns></returns>
- [HttpGet]
- public ActionResult Edit(Guid? ViewID)
- {
- EMIS.ViewModel.ExamProjectControlView projectFeeView = new EMIS.ViewModel.ExamProjectControlView() { ExaminationBatchProjectControlID = Guid.NewGuid(), SchoolYearCode = BaseExtensions.GetCurrentSchoolYearID() };
- if (ViewID.HasValue && ViewID != Guid.Empty)
- {
- projectFeeView = IExamProjectControlService.GetView(ViewID);
- }
- return View(projectFeeView);
- }
- /// <summary>
- /// 设置编辑页提交
- /// </summary>
- /// <param name="campusView"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult Edit(ExamProjectControlView view)
- {
- try
- {
- var standardList = DataGrid.GetTableData<EMIS.ViewModel.ExamProjectControlView>("dgStandardList");
- //新增时候是批量,修改为单条操作
- if (standardList == null || standardList.Count == 0)
- {
- IExamProjectControlService.Edit(view);
- }
- else
- {
- IExamProjectControlService.Edit(view, standardList);
- }
- 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 Delete(string IDs)
- {
- try
- {
- List<Guid?> list = IDs.Split(',').Where(x => !string.IsNullOrEmpty(x))
- .Select(x => (Guid?)new Guid(x)).ToList();
- IExamProjectControlService.Delete(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);
- }
- }
- [HttpPost]
- public ActionResult Excel(QueryParamsModel pararms)
- {
- List<ConfiguretView> configuretViews = new List<ConfiguretView>();
- configuretViews.Add(ConfiguretExtensions.GetConfiguretermsView(pararms));
- configuretViews.AddRange(pararms.getConditions());
- var StartDate = configuretViews.Where(x => x.Attribute == "StartDate").SingleOrDefault();
- if (StartDate != null) StartDate.Condition = ">=";
- var EndDate = configuretViews.Where(x => x.Attribute == "EndDate").SingleOrDefault();
- if (EndDate != null) EndDate.Condition = "<=";
- var query = IExamProjectControlService.GetList(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.ExaminationBatchProjectControlID));
- }
- var dt = query.ToList().Select(q =>
- new
- {
- q.Schoolyear,
- q.ExaminationBatchProject,
- q.ExaminationType,
- q.ProjectName,
- q.ExaminationProjectFee,
- q.SchoolyearID,
- q.CollegeName,
- q.StandardName,
- q.IsOnlinePayName,
- }).ToTable();
- NpoiExcelHelper neh = new NpoiExcelHelper();
- string[] liststring = {
- "学年学期","考试批次","考试类型","项目名称","收费标准名称","年级","院系所","专业","能否线上缴费"};
- neh.Export(dt, liststring, "批次报名控制列表" + DateTime.Now.ToString("yyyyMMddhhmmss"));
- return RedirectToAction("MsgShow", "Common", new
- {
- msg = "导出成功!",
- url = Url.Content("~/ExaminationBatc/List").AddMenuParameter()
- });
- }
- }
- }
|