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; using EMIS.ViewModel.Students; namespace EMIS.Web.Controllers.ExamManage { [Authorization] public class ExamPersonControlController : Controller { public IExamPersonControlServices IPersonControlServices { get; set; } // // GET: /ExaminationBatch/ public ActionResult List() { return View(); } /// /// 项目列表查询 /// /// /// [HttpPost] public ActionResult List(QueryParamsModel pararms) { List configuretViews = new List(); configuretViews.Add(ConfiguretExtensions.GetConfiguretermsView(pararms)); configuretViews.AddRange(pararms.getConditions()); var ExaminationBatchProjectID = Request.QueryString["ExaminationBatchProjectID"]; if (!string.IsNullOrEmpty(ExaminationBatchProjectID)) { configuretViews.Add(new ConfiguretView() { Attribute = "ExaminationBatchProjectID", Condition = "=", ConditionValue = ExaminationBatchProjectID }); } var UserID = Request.QueryString["UserID"]; if (!string.IsNullOrEmpty(UserID)) { configuretViews.Add(new ConfiguretView() { Attribute = "UserID", Condition = "=", ConditionValue = UserID }); } 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(IPersonControlServices.GetListGridView((int)pararms.page, (int)pararms.rows, configuretViews.ToArray())); } /// /// 控制考试类型列表查询 /// /// /// [HttpPost] public ActionResult GetControlExamTypeListViewGrid(QueryParamsModel pararms) { List configuretViews = new List(); configuretViews.Add(ConfiguretExtensions.GetConfiguretermsView(pararms)); configuretViews.AddRange(pararms.getConditions()); return base.Json(IPersonControlServices.GetControlExamTypeListViewGrid((int)pararms.page, (int)pararms.rows, configuretViews.ToArray())); } /// /// 控制考试列表查询 /// /// /// [HttpPost] public ActionResult GetControlProjectListViewGrid(QueryParamsModel pararms) { List configuretViews = new List(); configuretViews.Add(ConfiguretExtensions.GetConfiguretermsView(pararms)); configuretViews.AddRange(pararms.getConditions()); return base.Json(IPersonControlServices.GetControlProjectListViewGrid((int)pararms.page, (int)pararms.rows, configuretViews.ToArray())); } /// /// 设置编辑页 /// /// /// [HttpGet] public ActionResult Edit(Guid? ViewID) { EMIS.ViewModel.ExamPersonControlView projectFeeView = new EMIS.ViewModel.ExamPersonControlView() { ExaminationBatchProjectPersonControlID = Guid.NewGuid(), ExaminationBatchProjectID = Guid.Empty, SchoolYearCode = BaseExtensions.GetCurrentSchoolYearID() }; if (ViewID.HasValue && ViewID != Guid.Empty) { projectFeeView = IPersonControlServices.GetView(ViewID); } return View(projectFeeView); } /// /// 设置编辑页提交 /// /// /// [HttpPost] public ActionResult Edit(ExamPersonControlView view) { try { var studentList = DataGrid.GetTableData("dgStudentList"); IPersonControlServices.Edit(view, studentList); return Json(new ReturnMessage() { IsSuccess = true, Message = "保存成功。" }); } catch (Exception ex) { return Json(new ReturnMessage() { IsSuccess = false, Message = "保存失败,原因:" + ex.Message }); } } /// /// 删除项目设置 /// /// /// [HttpPost] public JsonResult Delete(string IDs) { try { List list = IDs.Split(',').Where(x => !string.IsNullOrEmpty(x)) .Select(x => (Guid?)new Guid(x)).ToList(); IPersonControlServices.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 configuretViews = new List(); 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 = IPersonControlServices.GetList(configuretViews.ToArray()); var SelectedID = Request.Form["SelectedID"]; List selectIDlist = new List(); if (SelectedID != "" && SelectedID != null) { selectIDlist = SelectedID.SplitIDString(); query = query.Where(x => selectIDlist.Contains(x.ExaminationBatchProjectPersonControlID)); } var dt = query.ToList().Select(q => new { q.Schoolyear, q.ExaminationBatchProject, q.ExaminationType, q.ProjectName, q.UserID, q.IsOnlinePayName, EndDate = q.EndDate.HasValue ? q.EndDate.Value.ToString("yyyy-MM-dd") : "" }).ToTable(); NpoiExcelHelper neh = new NpoiExcelHelper(); string[] liststring = { "学年学期","考试批次项目","项目类型","项目名称","用户ID","是否线上缴费","报名截止时间"}; neh.Export(dt, liststring, "个人报名控制列表" + DateTime.Now.ToString("yyyyMMddhhmmss")); return RedirectToAction("MsgShow", "Common", new { msg = "导出成功!", url = Url.Content("~/ExaminationBatc/List").AddMenuParameter() }); } } }