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.CalendarManage; using EMIS.CommonLogic.EducationManage; using EMIS.ViewModel.EducationManage; using Bowin.Common.Exceptions; namespace EMIS.Web.Controllers.EducationManage { [Authorization] public class ExecutableMinorPlanController : Controller { // // GET: /ExecutableMinorPlan/ public ISchoolYearServices SchoolYearServices { get; set; } public IExecutableMinorPlanServices ExecutableMinorPlanServices { get; set; } public ActionResult List() { var schoolYear = SchoolYearServices.GetSchoolYearIsCurrent(true); ViewBag.SchoolYearID = schoolYear == null ? "-1" : schoolYear.SchoolyearID.ToString();//默认当前学年 return View(); } /// /// 查询列表 /// /// /// [HttpPost] public ActionResult List(QueryParamsModel pararms) { ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms); var schoolyearID = pararms.getExtraGuid("SchoolyearDropdown"); var collegeID = pararms.getExtraGuid("CollegeDropdown"); 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 coursematerialID = pararms.getExtraGuid("CoursematerialIDDropdownGridBo"); var schoolyearNum = pararms.getExtraInt("DictionarySchoolyear") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionarySchoolyear"); var schoolcode = pararms.getExtraInt("DictionarySchoolcode") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionarySchoolcode"); var approvalStatus = pararms.getExtraInt("ApprovalStatusDropdownList") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ApprovalStatusDropdownList"); return Json(ExecutableMinorPlanServices.GetExecutableMinorPlanViewGrid(configuretView, schoolyearID, collegeID, yearID, standardID, coursematerialID, schoolyearNum, schoolcode, approvalStatus, (int)pararms.page, (int)pararms.rows)); } public ActionResult GenerateExecutablePlan() { return View(new ExecutablePlanGenerateView()); } [HttpPost] public ActionResult GenerateExecutablePlan(ExecutablePlanGenerateView executablePlanGenerateView) { try { ExecutableMinorPlanServices.GenerateExecutablePlan(executablePlanGenerateView.StandardID, executablePlanGenerateView.SchoolyearID, executablePlanGenerateView.IsOverwrite, executablePlanGenerateView.CampusID, executablePlanGenerateView.CollegeID, executablePlanGenerateView.YearID); return Json(new ReturnMessage() { IsSuccess = true, Message = "操作成功。" }); } catch (SuccessException ex) { return Json(new ReturnMessage() { IsSuccess = true, Message = ex.Message }); } catch (Exception ex) { return Json(new ReturnMessage() { IsSuccess = false, Message = "操作失败," + ex.Message }); } } /// /// 编辑 /// /// /// public ActionResult Edit(Guid? ExecutableMinorPlanID) { ExecutableMinorPlanView executableMinorPlanView = new ExecutableMinorPlanView(); if (ExecutableMinorPlanID.HasValue) { executableMinorPlanView = ExecutableMinorPlanServices.GetExecutableMinorPlanView(ExecutableMinorPlanID); } else { executableMinorPlanView.ResultTypeID = (int)CF_ResultType.Percentage; executableMinorPlanView.Credit = 0; executableMinorPlanView.TheoryCourse = 0; executableMinorPlanView.Practicehours = 0; executableMinorPlanView.Trialhours = 0; executableMinorPlanView.Totalhours = 0; executableMinorPlanView.TheoryWeeklyNum = 0; executableMinorPlanView.PracticeWeeklyNum = 0; executableMinorPlanView.TrialWeeklyNum = 0; executableMinorPlanView.SchoolweeksNum = 0; executableMinorPlanView.WeeklyHours = 0; executableMinorPlanView.WeeklyNum = 0; } return View(executableMinorPlanView); } /// /// 编辑 /// /// /// [HttpPost] public ActionResult Edit(ExecutableMinorPlanView executableMinorPlanView) { try { ExecutableMinorPlanServices.ExecutableMinorPlanEdit(executableMinorPlanView); return Json(new ReturnMessage() { IsSuccess = true, Message = "保存成功。" }); } catch (Exception ex) { return Json(new ReturnMessage() { IsSuccess = false, Message = "保存失败:" + ex.Message }); } } /// /// 删除 /// /// /// [HttpPost] public ActionResult Delete(string ExecutableMinorPlanIDs) { try { List list = new List(); for (int i = 0; i < ExecutableMinorPlanIDs.Split(',').Length; i++) { string id = ExecutableMinorPlanIDs.Split(',')[i]; if (!string.IsNullOrEmpty(id)) { Guid ExecutableMinorPlanID = new Guid(id); list.Add(ExecutableMinorPlanID); } } ExecutableMinorPlanServices.ExecutableMinorPlanDelete(list); return Json(new ReturnMessage { IsSuccess = true, Message = "删除成功。" }); } 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 TeachingModeType(Guid? ExecutableMinorPlanID) { List list = new List(); if (ExecutableMinorPlanID.HasValue && ExecutableMinorPlanID != Guid.Empty) list = ExecutableMinorPlanServices.GetTeachingModeType(ExecutableMinorPlanID); else list.Add(((int)EMIS.ViewModel.CF_TeachingMode.Theory).ToString()); return base.Json(list); } /// /// 获取已经存在在授课地点 /// /// /// [HttpPost] public ActionResult TeachingPlace(Guid? ExecutableMinorPlanID) { List list = new List(); if (ExecutableMinorPlanID.HasValue && ExecutableMinorPlanID != Guid.Empty) list = ExecutableMinorPlanServices.GetTeachingPlace(ExecutableMinorPlanID); return base.Json(list); } /// /// 生成任务班 /// /// [HttpPost] public ActionResult GenerateEducationMissionClassSubminit(string ExecutableMinorPlanIDs) { try { List list = new List(); for (int i = 0; i < ExecutableMinorPlanIDs.Split(',').Length; i++) { string id = ExecutableMinorPlanIDs.Split(',')[i]; if (!string.IsNullOrEmpty(id)) { Guid ExecutableMinorPlanID = new Guid(id); list.Add(ExecutableMinorPlanID); } } ExecutableMinorPlanServices.GenerateEducationMissionClassOptionalCourse(list); return Json("成功"); } catch (Exception ex) { return Json("生成教学任务班失败,原因:" + ex.Message); } } } }