123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320 |
- 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 Bowin.Common.Utility;
- using Bowin.Common.Exceptions;
- using Bowin.Common.Data;
- using Bowin.Web.Controls.Mvc;
- using Bowin.Common.Linq.Entity;
- namespace EMIS.CommonLogic.ExamManage
- {
- [Authorization]
- public class ExamBatchProjectController : Controller
- {
- public IExaminationBatchServices IExaminationBatchService { get; set; }
- public IExamBatchProjectServices IExamBatchProjectService { get; set; }
- //
- // GET: /ExaminationBatch/
- public ActionResult List()
- {
- return View();
- }
- public ActionResult Select()
- {
- return View();
- }
- [HttpPost]
- public ActionResult TypeDropDownList(DropdownListBindType? bindType, Guid? examinationBatchID)
- {
- DropdownListBindType dbt = bindType == null ? DropdownListBindType.SelectAll : bindType.Value;
- var projectQuery = IExamBatchProjectService.GetBatchProjectList(new ConfiguretView());
- if (examinationBatchID.HasValue)
- {
- projectQuery = projectQuery.Where(x => x.ExaminationBatchID == examinationBatchID);
- }
- else
- {
- var emptyList = new List<DropdownListItem>();
- Bowin.Web.Controls.Mvc.DropdownList.FormatDropdownItemList(dbt, emptyList);
- return Json(emptyList);
- }
- List<DropdownListItem> list = projectQuery.Select(x => new { x.ExaminationTypeID, x.ExaminationType }).Distinct()
- .OrderBy(x => x.ExaminationType)
- .Select(x => new DropdownListItem { Text = x.ExaminationType, Value = x.ExaminationTypeID.ToString() }).ToList();
- Bowin.Web.Controls.Mvc.DropdownList.FormatDropdownItemList(dbt, list);
- return base.Json(list);
- }
- [HttpPost]
- public ActionResult DropDownList(DropdownListBindType? bindType, Guid? examinationBatchID, Guid? examinationTypeID)
- {
- DropdownListBindType dbt = bindType == null ? DropdownListBindType.SelectAll : bindType.Value;
- var projectQuery = IExamBatchProjectService.GetBatchProjectList(new ConfiguretView());
- if (examinationBatchID.HasValue)
- {
- projectQuery = projectQuery.Where(x => x.ExaminationBatchID == examinationBatchID);
- }
- else
- {
- var emptyList = new List<DropdownListItem>();
- Bowin.Web.Controls.Mvc.DropdownList.FormatDropdownItemList(dbt, emptyList);
- return Json(emptyList);
- }
- if (examinationTypeID.HasValue)
- {
- projectQuery = projectQuery.Where(x => x.ExaminationTypeID == examinationTypeID);
- }
- List<DropdownListItem> list = projectQuery
- .OrderBy(x => x.Name)
- .Select(x => new DropdownListItem { Text = x.Name, Value = x.ExaminationProjectID.ToString() }).ToList();
- Bowin.Web.Controls.Mvc.DropdownList.FormatDropdownItemList(dbt, list);
- return base.Json(list);
- }
- /// <summary>
- /// 项目类型列表查询
- /// </summary>
- /// <param name="pararms"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult GetExamTypeListViewGrid(QueryParamsModel pararms)
- {
- List<ConfiguretView> configuretViews = new List<ConfiguretView>();
- configuretViews.Add(ConfiguretExtensions.GetConfiguretermsView(pararms));
- configuretViews.AddRange(pararms.getConditions());
- var queryList = IExamBatchProjectService.GetBatchProjectList(configuretViews.ToArray()).Select(q => new
- {
- q.ExaminationType,
- q.ExaminationTypeID,
- }).Distinct().OrderBy(x => x.ExaminationTypeID)
- .ToGridResultSet<Object>((int)pararms.page, (int)pararms.rows);
- return base.Json(queryList);
- }
- /// <summary>
- /// 项目列表查询
- /// </summary>
- /// <param name="pararms"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult GetExamBatchProjectListViewGrid(QueryParamsModel pararms)
- {
- List<ConfiguretView> configuretViews = new List<ConfiguretView>();
- configuretViews.Add(ConfiguretExtensions.GetConfiguretermsView(pararms));
- configuretViews.AddRange(pararms.getConditions());
- configuretViews.Add(new ConfiguretView()
- {
- Attribute = "RecordStatus",
- Condition = "=",
- ConditionValue = ((int)SYS_STATUS.USABLE).ToString()
- });
- 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(IExamBatchProjectService.GetBatchProjectListGridView((int)pararms.page, (int)pararms.rows, configuretViews.ToArray()));
- }
- /// <summary>
- /// 批次考试类型列表查询
- /// </summary>
- /// <param name="pararms"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult GetExamBatchExamTypeListViewGrid(QueryParamsModel pararms)
- {
- List<ConfiguretView> configuretViews = new List<ConfiguretView>();
- configuretViews.Add(ConfiguretExtensions.GetConfiguretermsView(pararms));
- configuretViews.AddRange(pararms.getConditions());
- return base.Json(IExamBatchProjectService.GetExamBatchExamTypeListViewGrid((int)pararms.page, (int)pararms.rows, configuretViews.ToArray()));
- }
- /// <summary>
- /// 编辑页项目列表查询
- /// </summary>
- /// <param name="pararms"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult GetExamBatchProjectListEdiGrid(QueryParamsModel pararms)
- {
- List<ConfiguretView> configuretViews = new List<ConfiguretView>();
- configuretViews.Add(ConfiguretExtensions.GetConfiguretermsView(pararms));
- configuretViews.AddRange(pararms.getConditions());
- if (configuretViews.Count == 1)
- return null;
- 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(IExamBatchProjectService.GetBatchProjectListGridView((int)pararms.page, (int)pararms.rows, configuretViews.ToArray()));
- }
- /// <summary>
- /// 设置编辑页
- /// </summary>
- /// <param name="ExaminationProjectFeeID"></param>
- /// <returns></returns>
- [HttpGet]
- public ActionResult Edit(Guid? ExaminationBatchProjectID)
- {
- EMIS.ViewModel.ExamBatchProjectView projectFeeView = new EMIS.ViewModel.ExamBatchProjectView() { ExaminationBatchID = Guid.NewGuid(), SchoolyearID = BaseExtensions.GetCurrentSchoolYearID()};
- if (ExaminationBatchProjectID.HasValue && ExaminationBatchProjectID != Guid.Empty)
- {
- ConfiguretView config = new ConfiguretView();
- config.Attribute = "ExaminationBatchProjectID";
- config.Condition = "=";
- config.ConditionValue = ExaminationBatchProjectID.ToString();
- projectFeeView = IExamBatchProjectService.GetBatchProjectList(config).Single();
- }
- return View(projectFeeView);
- }
- /// <summary>
- /// 新增项目提交操作
- /// </summary>
- /// <param name="campusIDs"></param>
- /// <returns></returns>
- [HttpPost]
- public JsonResult SelectProjects(Guid ExaminationBatchID, string ExamProjectIDs)
- {
- try
- {
- List<Guid?> list = ExamProjectIDs.Split(',').Where(x => !string.IsNullOrEmpty(x))
- .Select(x => (Guid?)new Guid(x)).ToList();
- var addlist = IExamBatchProjectService.SelectProjects(ExaminationBatchID, list);
- //返回新增的行数
- return Json(new ReturnMessage<List<EMIS.ViewModel.ExamBatchProjectView>> { IsSuccess = true, Message = "新增成功。", Data = addlist });
- }
- catch (Exception ex)
- {
- return Json(new ReturnMessage { IsSuccess = true, Message = "新增失败,原因:" + ex.Message });
- }
- }
- /// <summary>
- /// 收费项目编辑页提交
- /// </summary>
- /// <param name="campusView"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult Edit(ExamBatchProjectView view)
- {
- try
- {
- var listData = DataGrid.GetTableData<ExamBatchProjectView>("dgProjectList");
- //IExamBatchProjectService.Edit(view, listData);
- //新增时候是批量,修改为单条操作
- if (listData == null || listData.Count == 0)
- {
- IExamBatchProjectService.Edit(view);
- }
- else
- {
- IExamBatchProjectService.Edit(view, listData);
- }
- 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 DeleteBatchProject(string ExamBatchProjectIDs)
- {
- try
- {
- List<Guid?> list = ExamBatchProjectIDs.Split(',').Where(x => !string.IsNullOrEmpty(x))
- .Select(x => (Guid?)new Guid(x)).ToList();
- IExamBatchProjectService.DeleteBatchProject(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 = IExamBatchProjectService.GetBatchProjectList(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.ExaminationBatchProjectID));
- }
- var dt = query.ToList().Select(q =>
- new
- {
- q.Schoolyear,
- q.BatchName,
- StartDate = q.StartDate.ToStringEx("yyyy-MM-dd"),
- EndDate = q.EndDate.ToStringEx("yyyy-MM-dd"),
- q.ExaminationType,
- q.Name,
- q.SimulateTime,
- q.Training,
- q.TakeCourseTime,
- q.MaxRegistCount,
- }).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()
- });
- }
- }
- }
|