using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using Bowin.Common.Utility; using Bowin.Common.Data; using Bowin.Common.Linq; using Bowin.Common.JSON; using Bowin.Web.Controls.Mvc; using EMIS.Utility; using EMIS.Web.Controls; using EMIS.ViewModel; using EMIS.ViewModel.EvaluationManage.EvaluationSetting; using EMIS.CommonLogic.EvaluationManage.EvaluationSetting; namespace EMIS.Web.Controllers.EvaluationManage.EvaluationSetting { [Authorization] public class EvaluationGradeControlController : Controller { public Lazy EvaluationGradeControlServices { get; set; } /// /// 评价控制(年级专业)页面 /// /// public ActionResult List() { return View(); } /// /// 评价控制(年级专业)列表查询 /// /// /// [HttpPost] public ActionResult List(QueryParamsModel pararms) { ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms); var schoolyearID = pararms.getExtraGuid("SchoolyearDropdown"); var campusID = pararms.getExtraGuid("CampusDropdown"); var collegeID = pararms.getExtraGuid("CollegeDropdown"); var gradeID = pararms.getExtraInt("DictionaryGrade") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryGrade"); var standardID = pararms.getExtraInt("DictionaryStandard") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryStandard"); var educationID = pararms.getExtraInt("DictionaryEducation") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryEducation"); var learningformID = pararms.getExtraInt("DictionaryLearningform") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryLearningform"); var learnSystem = pararms.getExtraString("DictionaryLearnSystem"); var inSchoolStatus = pararms.getExtraInt("DictionaryInschoolStatus") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryInschoolStatus"); var semesterID = pararms.getExtraInt("DictionarySemester") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionarySemester"); var dateRange = pararms.getExtraDateTime("txtDateRange"); return base.Json(EvaluationGradeControlServices.Value.GetEvaluationGradeControlViewGrid(configuretView, schoolyearID, campusID, collegeID, gradeID, standardID, educationID, learningformID, learnSystem, semesterID, dateRange, inSchoolStatus, (int)pararms.page, (int)pararms.rows)); } /// /// 复制新增 /// /// /// public ActionResult CopyAdd(Guid evaluationGradeControlID) { var evaluationGradeControlView = new EvaluationGradeControlView(); evaluationGradeControlView = EvaluationGradeControlServices.Value.GetEvaluationGradeControlView(evaluationGradeControlID); return View("Edit", evaluationGradeControlView); } /// /// 复制新增 /// /// /// [HttpPost] public ActionResult CopyAdd(EvaluationGradeControlView evaluationGradeControlView) { evaluationGradeControlView.EvaluationGradeControlID = Guid.Empty; return this.Edit(evaluationGradeControlView); } /// /// 编辑 /// /// /// [HttpGet] public ActionResult Edit(Guid? evaluationGradeControlID) { var evaluationGradeControlView = new EvaluationGradeControlView(); if (evaluationGradeControlID.HasValue && evaluationGradeControlID != Guid.Empty) { evaluationGradeControlView = EvaluationGradeControlServices.Value.GetEvaluationGradeControlView(evaluationGradeControlID); } else { evaluationGradeControlView.StartTime = DateTime.Now; evaluationGradeControlView.EndTime = DateTime.Now.AddMonths(1); } return View(evaluationGradeControlView); } /// /// 编辑 /// /// /// [HttpPost] public ActionResult Edit(EvaluationGradeControlView evaluationGradeControlView) { try { EvaluationGradeControlServices.Value.EvaluationGradeControlEdit(evaluationGradeControlView); return Json(new ReturnMessage() { IsSuccess = true, Message = "保存成功。" }); } catch (Exception ex) { return Json(new ReturnMessage() { IsSuccess = false, Message = "保存失败,原因:" + ex.Message }); } } /// /// 评价控制(年级专业)信息批量新增 /// /// [HttpGet] public ActionResult EvaluationGradeControlBatchAdd() { EvaluationGradeControlView evaluationGradeControlView = new EvaluationGradeControlView(); evaluationGradeControlView.StartTime = DateTime.Now; evaluationGradeControlView.EndTime = DateTime.Now.AddMonths(1); return View(evaluationGradeControlView); } /// /// 评价控制(年级专业)信息批量新增 /// /// /// public ActionResult EvaluationGradeControlBatchAdd(EvaluationGradeControlView evaluationGradeControlView) { try { var grademajorIDList = Request["grademajorIDList"].JsonToObject>(); string result = EvaluationGradeControlServices.Value.EvaluationGradeControlBatchAdd(grademajorIDList, evaluationGradeControlView); return Json(new ReturnMessage() { IsSuccess = true, Message = "新增成功" + result + "。" }); } catch (Exception ex) { return Json(new ReturnMessage() { IsSuccess = false, Message = "新增失败,原因:" + ex.Message }); } } /// /// 查询对应的未新增年级专业信息GrademajorView /// /// /// [HttpPost] public ActionResult GrademajorNoAddList(QueryParamsModel pararms) { ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms); var campusID = pararms.getExtraGuid("CampusDropdown"); var collegeID = pararms.getExtraGuid("CollegeDropdown"); var gradeID = pararms.getExtraInt("DictionaryGrade") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryGrade"); var standardID = pararms.getExtraInt("DictionaryStandard") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryStandard"); var educationID = pararms.getExtraInt("DictionaryEducation") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryEducation"); var learningformID = pararms.getExtraInt("DictionaryLearningform") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryLearningform"); var learnSystem = pararms.getExtraString("DictionaryLearnSystem"); var inSchoolStatus = pararms.getExtraInt("DictionaryInschoolStatus") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryInschoolStatus"); var schoolyearID = pararms.getExtraGuid("SchoolyearID"); return base.Json(EvaluationGradeControlServices.Value.GetGrademajorViewNoAddGrid(configuretView, campusID, collegeID, gradeID, standardID, educationID, learningformID, learnSystem, inSchoolStatus, schoolyearID, (int)pararms.page, (int)pararms.rows)); } /// /// 查询对应的未新增年级专业信息Excel导出 /// /// [HttpPost] public ActionResult GrademajorNoAddListExcel() { return null; } /// /// 删除 /// /// /// [HttpPost] public ActionResult Delete(string evaluationGradeControlIDs) { try { List list = evaluationGradeControlIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => (Guid?)new Guid(x)).ToList(); EvaluationGradeControlServices.Value.EvaluationGradeControlDelete(list); return base.Json(new ReturnMessage { IsSuccess = true, Message = "删除成功。" }); } catch (Exception ex) { return base.Json(new ReturnMessage() { IsSuccess = false, Message = "删除失败,原因:" + ex.Message }); } } /// /// Excel导出 /// /// [HttpPost] public ActionResult Excel() { try { NpoiExcelHelper neh = new NpoiExcelHelper(); ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null); var schoolyearID = Request.Form["SchoolyearDropdown"] == DropdownList.SELECT_ALL.ToString() ? null : Request.Form["SchoolyearDropdown"].ParseStrTo(); var campusID = Request.Form["CampusDropdown"].ParseStrTo(); var collegeID = Request.Form["CollegeDropdown"].ParseStrTo(); var gradeID = Request.Form["DictionaryGrade"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryGrade"].ParseStrTo(); var standardID = Request.Form["DictionaryStandard"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryStandard"].ParseStrTo(); var educationID = Request.Form["DictionaryEducation"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryEducation"].ParseStrTo(); var learningformID = Request.Form["DictionaryLearningform"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryLearningform"].ParseStrTo(); var learnSystem = Request.Form["DictionaryLearnSystem"].ToString(); var inSchoolStatus = Request.Form["DictionaryInschoolStatus"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryInschoolStatus"].ParseStrTo(); var semesterID = Request.Form["DictionarySemester"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["DictionarySemester"].ParseStrTo(); var dateRange = Request.Form["txtDateRange"].ParseStrTo(); var dt = EvaluationGradeControlServices.Value.GetEvaluationGradeControlViewList(configuretView, schoolyearID, campusID, collegeID, gradeID, standardID, educationID, learningformID, learnSystem, semesterID, dateRange, inSchoolStatus) .Select(x => new { x.SchoolyearCode, x.GrademajorCode, x.GrademajorName, x.FacultymajorNo, x.FacultymajorName, x.CollegeNo, x.CollegeName, x.CampusNo, x.CampusName, x.GradeID, x.SemesterName, x.StandardCode, x.StandardID, x.StandardName, x.EducationName, x.LearningformName, LearnSystem = x.LearnSystem.HasValue ? x.LearnSystem.Value.ToString("#.#") : null, x.StartSchoolyearCode, x.GraduateSchoolyearCode, x.Number, StartTime = x.StartTime == null ? null : x.StartTime.Value.ToString("yyyy-MM-dd HH:mm:ss"), EndTime = x.EndTime == null ? null : x.EndTime.Value.ToString("yyyy-MM-dd HH:mm:ss"), x.ClassmajorCount, x.StudentCount, x.CreateUserName, x.ModifyUserName, ModifyTime = x.ModifyTime == null ? null : x.ModifyTime.Value.ToString("yyyy-MM-dd HH:mm:ss") }).ToTable(); string[] liststring = { "学年学期", "年级专业编号", "年级专业名称", "院系专业编号", "院系专业名称", RSL.Get("CollegeCode"), RSL.Get("College"), RSL.Get("CampusCode"), RSL.Get("CampusName"), "年级", "入学学期", "专业代码", "专业ID(Value)", "专业名称", RSL.Get("EducationID"), "学习形式", "学制", "入学学年学期", "毕业学期", "可评次数", "开始时间", "结束时间", "班级数", "学生数", "创建人", "修改人", "修改时间" }; var title = "年级控制信息"; if (inSchoolStatus == (int)CF_INOrOutSchoolStatus.No) { title = "年级控制信息(非在校)"; } if (inSchoolStatus == (int)CF_INOrOutSchoolStatus.Yes) { title = "年级控制信息(在校)"; } neh.Export(dt, liststring, title + DateTime.Now.ToString("yyyyMMdd")); return Json(new ReturnMessage() { IsSuccess = true, Message = "导出成功。" }); } catch (Exception ex) { return Json(new ReturnMessage() { IsSuccess = false, Message = "导出失败,原因:" + ex.Message }); } } } }