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 EMIS.CommonLogic.MinorManage.MinorPlanManage; using EMIS.ViewModel.MinorManage.MinorPlanManage; using Bowin.Common.JSON; using Bowin.Common.Utility; using Bowin.Common.Exceptions; using EMIS.Utility; using Bowin.Common.Data; using EMIS.CommonLogic.Students; namespace EMIS.Web.Controllers.MinorManage.MinorPlanManage { [Authorization] public class MinorPlanApplyController : Controller { // // GET: /MinorPlanApply/ public IMinorPlanApplyServices minorPlanApplyServices { get; set; } public Lazy StudentfileServices { get; set; } public ActionResult List() { return View(); } [HttpPost] public ActionResult List(QueryParamsModel pararms) { ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms); var yearID = pararms.getExtraInt("SchoolyearDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("SchoolyearDictionaryDropDown"); var standardID = pararms.getExtraInt("StandardDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("StandardDictionaryDropDown"); var collegeID = pararms.getExtraGuid("CollegeDropdown"); var approvalStatus = pararms.getExtraInt("DictionaryApprovalStatus") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryApprovalStatus"); return this.Json(minorPlanApplyServices.GetMinorPlanApplyViewGrid(configuretView, yearID, standardID, collegeID, approvalStatus,(int)pararms.page, (int)pararms.rows)); } /// /// 获取未申请过的辅修课程 /// /// /// [HttpPost] public ActionResult StandardAndMinorSpecialtyCourseViewList(QueryParamsModel pararms) { var yearID = pararms.getExtraInt("YearID") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("YearID"); var standardID = pararms.getExtraInt("StandardID") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("StandardID"); return this.Json(minorPlanApplyServices.StandardAndMinorSpecialtyCourseViewGrid(yearID, standardID,(int)pararms.page, (int)pararms.rows)); } /// /// 获取申请过的辅修课程 /// /// /// [HttpPost] public ActionResult existStandardAndMinorSpecialtyCourseViewList(QueryParamsModel pararms) { var GradeMinorApplicationID = Request["GradeMinorApplicationID"].ParseStrTo(); return this.Json(minorPlanApplyServices.existStandardAndMinorSpecialtyCourseViewGrid(GradeMinorApplicationID, (int)pararms.page, (int)pararms.rows)); } /// /// 获取不存在辅修计划的课程 /// /// [HttpGet] public ActionResult MinorPlanApplyChoiceList() { MinorPlanApplyView minorPlanApplyView = new MinorPlanApplyView(); var curUser = EMIS.Utility.FormValidate.CustomPrincipal.Current; var dataRange = StudentfileServices.Value.GetDataRange(); ViewBag.DataRange = dataRange; minorPlanApplyView.CollegeID=curUser.CollegeID; minorPlanApplyView.HandleModeID = 1; minorPlanApplyView.IsNeedMaterial = true; return View(minorPlanApplyView); } /// /// 批量添加 /// /// /// [HttpPost] public ActionResult MinorPlanApplyChoiceList(MinorPlanApplyView minorPlanApplyView) { try { var minorSpecialCourseViewList = Request["MinorSpecialtyCourse"].JsonToObject>(); if (minorSpecialCourseViewList.Count > 0) { minorPlanApplyServices.MinorPlanAdd(minorPlanApplyView, minorSpecialCourseViewList); //specialtyPlanServices.SpecialtyPlanAdd(specialtyPlanView, specialCourseViewList); } else { return Json(new ReturnMessage() { IsSuccess = false, Message = "保存失败,请选择要添加的专业课程。" }); } return Json(new ReturnMessage() { IsSuccess = true, Message = "保存成功!" }); } catch (Exception ex) { return Json(new ReturnMessage() { IsSuccess = false, Message = "保存失败:" + ex.Message }); } } /// /// 修改辅修计划的课程 /// /// [HttpGet] public ActionResult Edit(Guid? GradeMinorApplicationIDs) { MinorPlanApplyView minorPlanApplyView = new MinorPlanApplyView(); minorPlanApplyView=minorPlanApplyServices.GetMinorPlanApplyView(GradeMinorApplicationIDs); var dataRange = StudentfileServices.Value.GetDataRange(); ViewBag.DataRange = dataRange; minorPlanApplyView.HandleModeID = 1; minorPlanApplyView.IsNeedMaterial = true; return View(minorPlanApplyView); } /// /// 修改辅修计划的课程 /// /// /// [HttpPost] public ActionResult Edit(MinorPlanApplyView minorPlanApplyView) { try { var minorSpecialCourseViewList = DataGrid.GetTableData("dgStandardAndMinorSpecialtyCourseViewList"); if (minorSpecialCourseViewList.Count > 0) { minorPlanApplyServices.MinorPlanEdit(minorPlanApplyView, minorSpecialCourseViewList); //specialtyPlanServices.SpecialtyPlanAdd(specialtyPlanView, specialCourseViewList); } else { return Json(new ReturnMessage() { IsSuccess = false, Message = "保存失败,请选择要添加的专业课程。" }); } return Json(new ReturnMessage() { IsSuccess = true, Message = "保存成功!" }); } catch (Exception ex) { return Json(new ReturnMessage() { IsSuccess = false, Message = "保存失败:" + ex.Message }); } } /// /// 修改辅修计划的课程 /// /// [HttpGet] public ActionResult CopyAdd(Guid? GradeMinorApplicationIDs) { MinorPlanApplyView minorPlanApplyView = new MinorPlanApplyView(); minorPlanApplyView = minorPlanApplyServices.GetMinorPlanApplyView(GradeMinorApplicationIDs); var dataRange = StudentfileServices.Value.GetDataRange(); ViewBag.DataRange = dataRange; return View(minorPlanApplyView); } /// /// 修改辅修计划的课程 /// /// /// [HttpPost] public ActionResult CopyAdd(MinorPlanApplyView minorPlanApplyView) { try { var minorSpecialCourseViewList = DataGrid.GetTableData("dgStandardAndMinorSpecialtyCourseViewList"); if (minorSpecialCourseViewList.Count > 0) { minorPlanApplyView.GradeMinorApplicationID = null; minorPlanApplyServices.MinorPlanEdit(minorPlanApplyView, minorSpecialCourseViewList); //specialtyPlanServices.SpecialtyPlanAdd(specialtyPlanView, specialCourseViewList); } else { return Json(new ReturnMessage() { IsSuccess = false, Message = "保存失败,请选择要添加的专业课程。" }); } return Json(new ReturnMessage() { IsSuccess = true, Message = "保存成功!" }); } catch (Exception ex) { return Json(new ReturnMessage() { IsSuccess = false, Message = "保存失败:" + ex.Message }); } } //年级复制 public ActionResult CopyByGrade() { var dataRange = StudentfileServices.Value.GetDataRange(); ViewBag.DataRange = dataRange; return View(); } [HttpPost] public ActionResult CopyByGrade(MinorPlanApplyView minorPlanApplyView) { try { string Success = minorPlanApplyServices.SpecialtyPlanCopyByGrade(minorPlanApplyView); return Json(new ReturnMessage() { IsSuccess = true, Message = Success }); } catch (Exception ex) { return Json(new ReturnMessage() { IsSuccess = false, Message = "复制失败:" + ex.Message }); } } //年级复制 public ActionResult AddCourse(int? YearID, int StandardID) { return View(); } /// /// 删除 /// /// /// [HttpPost] public ActionResult Delete(string GradeMinorApplicationIDs) { try { List list = new List(); for (int i = 0; i < GradeMinorApplicationIDs.Split(',').Length; i++) { string id = GradeMinorApplicationIDs.Split(',')[i]; if (!string.IsNullOrEmpty(id)) { Guid GradeMinorApplicationID = new Guid(id); list.Add(GradeMinorApplicationID); } } minorPlanApplyServices.GradeMinorApplicationDelete(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 SubmitPlanApplication(string GradeMinorApplicationIDs, string statusNames) { try { var user = HttpContext.User as EMIS.Utility.FormValidate.CustomPrincipal; List list = new List(); for (int i = 0; i < GradeMinorApplicationIDs.Split(',').Length; i++) { if (!string.IsNullOrEmpty(GradeMinorApplicationIDs.Split(',')[i])) { Guid GradeMinorApplicationID = new Guid(GradeMinorApplicationIDs.Split(',')[i]); list.Add(GradeMinorApplicationID); } } List status = new List(); for (int i = 0; i < statusNames.Split(',').Length; i++) { if (!string.IsNullOrEmpty(statusNames.Split(',')[i])) { string statusName = statusNames.Split(',')[i]; status.Add(statusName); } } if (minorPlanApplyServices.GetStandardID_MinorPlanApplication_MinorSpecialtyPlanCount(list) > 0) { return Json("提交申请失败,请检查您提交的数据是否已存在专业计划不能重复提交申请!"); } minorPlanApplyServices.SubmitPlanApplicationApply(list, user.UserID, status, ""); return this.Json("成功"); } catch (Exception ex) { return this.Json("提交申请失败,原因:" + ex.Message); } } /// /// 导出Excel /// /// [HttpPost] public ActionResult Excel() { NpoiExcelHelper neh = new NpoiExcelHelper(); var GradeMinorApplicationID = Request.Form["GradeMinorApplicationID"]; ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null); var yearID = Request.Form["SchoolyearDictionaryDropDown"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["SchoolyearDictionaryDropDown"].ParseStrTo(); var standardID = Request.Form["StandardDictionaryDropDown"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["StandardDictionaryDropDown"].ParseStrTo(); var collegeID = Request.Form["CollegeDropdown"].ParseStrTo(); var approvalStatus = Request.Form["GrademinorStatusDictionaryDropDown"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["GrademinorStatusDictionaryDropDown"].ParseStrTo(); List GradeMinorApplicationIDList = new List(); if (GradeMinorApplicationID != "") { GradeMinorApplicationIDList = GradeMinorApplicationID.SplitIDString(); } else { GradeMinorApplicationIDList = null; } var dt = minorPlanApplyServices.GetMinorPlanApplyViewList(configuretView, yearID, standardID, collegeID, approvalStatus, GradeMinorApplicationIDList).Select(x => new { x.YearID, x.StandardCode, x.StandardName, x.CollegeName, x.StudentLimit, x.CreateTime, x.CreateUserName, x.ApprovalStatusName }).ToTable(); string[] liststring = { "年级", "专业代码", "专业名称", RSL.Get("College"), "人数上限","申请时间", "申请人","状态"}; neh.Export(dt, liststring, "辅修申请信息"); return Json(new ReturnMessage() { IsSuccess = true, Message = "导出成功。" }); } } }