using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using EMIS.ViewModel; using EMIS.Web.Controls; using Bowin.Web.Controls.Mvc; using Bowin.Common.Utility; using Bowin.Common.Data; using EMIS.CommonLogic.GraduationManage.GraduationSetting; using EMIS.ViewModel.GraduationManage.GraduationSetting; namespace EMIS.Web.Controllers.GraduationManage.GraduationSetting { [Authorization] public class GraduationSchoolYearController : Controller { public IGraduationSchoolYearServices GraduationSchoolYearServices { get; set; } /// /// 毕业学期页面 /// /// public ActionResult List() { return View(); } /// /// 毕业学期列表查询 /// /// /// [HttpPost] public ActionResult List(QueryParamsModel pararms) { ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms); var years = pararms.getExtraInt("DictionarySchoolyear") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionarySchoolyear"); var schoolcodeID = pararms.getExtraInt("DictionarySchoolcode") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionarySchoolcode"); var isCurrent = pararms.getExtraInt("IsCurrentDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("IsCurrentDropDown"); //启用状态 var isEnable = pararms.getExtraInt("IsEnableDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("IsEnableDropDown"); return base.Json(GraduationSchoolYearServices.GetGradSchoolYearViewGrid(configuretView, years, schoolcodeID, isCurrent, isEnable, (int)pararms.page, (int)pararms.rows)); } /// /// 复制新增 /// /// /// public ActionResult CopyAdd(Guid graduationSchoolYearSettingID) { GraduationSchoolYearView graduationSchoolYearView = new GraduationSchoolYearView(); graduationSchoolYearView = GraduationSchoolYearServices.GetGradSchoolYearView(graduationSchoolYearSettingID); return View("Edit", graduationSchoolYearView); } /// /// 复制新增 /// /// /// [HttpPost] public ActionResult CopyAdd(GraduationSchoolYearView graduationSchoolYearView) { graduationSchoolYearView.GraduationSchoolYearSettingID = Guid.Empty; return this.Edit(graduationSchoolYearView); } /// /// 编辑(新增、修改) /// /// /// [HttpGet] public ActionResult Edit(Guid? graduationSchoolYearSettingID) { GraduationSchoolYearView graduationSchoolYearView = new GraduationSchoolYearView(); if (graduationSchoolYearSettingID.HasValue && graduationSchoolYearSettingID != Guid.Empty) { graduationSchoolYearView = GraduationSchoolYearServices.GetGradSchoolYearView(graduationSchoolYearSettingID); } else { graduationSchoolYearView.GraduatingSemesterID = BaseExtensions.GetCurrentSchoolYearID(); graduationSchoolYearView.IsEnable = true; } return View(graduationSchoolYearView); } /// /// 编辑(新增、修改) /// /// /// [HttpPost] public ActionResult Edit(GraduationSchoolYearView graduationSchoolYearView) { try { GraduationSchoolYearServices.GraduationSchoolYearEdit(graduationSchoolYearView); return Json(new ReturnMessage() { IsSuccess = true, Message = "保存成功。" }); } catch (Exception ex) { return Json(new ReturnMessage() { IsSuccess = false, Message = "保存失败,原因:" + ex.Message }); } } /// /// 删除(注:需对设置的毕业学期进行处理) /// /// /// [HttpPost] public ActionResult Delete(string graduationSchoolYearSettingIDs) { try { List list = graduationSchoolYearSettingIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)) .Select(x => (Guid?)new Guid(x)).ToList(); GraduationSchoolYearServices.GraduationSchoolYearDelete(list); return base.Json("删除成功。"); } catch (Exception ex) { return base.Json("删除失败,原因:" + ex.Message); } } /// /// Excel导出 /// /// [HttpPost] public ActionResult Excel() { NpoiExcelHelper neh = new NpoiExcelHelper(); ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null); var years = Request.Form["DictionarySchoolyear"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["DictionarySchoolyear"].ParseStrTo(); var schoolcodeID = Request.Form["DictionarySchoolcode"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["DictionarySchoolcode"].ParseStrTo(); var isCurrent = Request.Form["IsCurrentDropDown"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["IsCurrentDropDown"].ParseStrTo(); var isEnable = Request.Form["IsEnableDropDown"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["IsEnableDropDown"].ParseStrTo(); var dt = GraduationSchoolYearServices.GetGradSchoolYearViewList(configuretView, years, schoolcodeID, isCurrent, isEnable) .Select(x => new { x.GraduatingSemesterCode, x.Years, x.SchoolcodeName, x.WeeksNum, GraduateDate = x.GraduateDate.HasValue ? x.GraduateDate.Value.ToLongDateString() : "", x.IsCurrentName, x.IsEnableName }).ToTable(); string[] liststring = { "毕业学期", "学年", "学期", "周数", "毕业日期", "是否当前学期", "启用状态" }; neh.Export(dt, liststring, "毕业学期信息" + DateTime.Now.ToString("yyyyMMdd")); return Json(new ReturnMessage() { IsSuccess = true, Message = "导出成功。" }); } } }