123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425 |
- 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.CultureplanManage.PlanManagement;
- using EMIS.ViewModel.SelectCourse;
- using Bowin.Common.Linq.Entity;
- using Bowin.Common.JSON;
- using Bowin.Common.Utility;
- using Bowin.Common.Data;
- using EMIS.CommonLogic.SelectCourse;
- using Bowin.Common.Exceptions;
- using EMIS.CommonLogic.UniversityManage.SpecialtyClassManage;
- namespace EMIS.Web.Controllers.SelectCourseManage
- {
- [Authorization]
- public class OptionalCourseSettingController : Controller
- {
- public IConditionServices ConditionServices { get; set; }
- public IClassmajorServices ClassmajorServices { get; set; }
- public IOptionalCourseSettingServices optionalCourseSettingServices { get; set; }
- /// <summary>
- /// 限选设定页面
- /// </summary>
- /// <returns></returns>
- public ActionResult List()
- {
- var conditionView = ConditionServices.GetSelectCourseConditionView();
- ViewBag.SelectSchoolYearID = conditionView.Schoolyear;
- return View();
- }
- /// <summary>
- /// 列表查询
- /// </summary>
- /// <param name="pararms"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult List(QueryParamsModel pararms)
- {
- ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
- var collegeID = pararms.getExtraGuid("CollegeDropdown");
- var coursematerialID = pararms.getExtraGuid("CoursematerialIDDropdownGridBo");
- var standardID = pararms.getExtraInt("StandardDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("StandardDictionaryDropDown");
- //var schoolYearNumID = pararms.getExtraInt("DictionarySchoolYearNum") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionarySchoolYearNum");
- var schoolYearID = pararms.getExtraGuid("SchoolyearDropdown");
- //var schoolCodeID = pararms.getExtraInt("DictionarySchoolCode") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionarySchoolCode");
- //var isEnable = pararms.getExtraInt("DictionaryIsEnable") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryIsEnable");
- var Years = pararms.getExtraInt("SchoolyearDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("SchoolyearDictionaryDropDown");
- var Status = pararms.getExtraInt("DictionaryStatus") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryStatus");
- var isOpen = pararms.getExtraInt("DictionaryIsOpen") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryIsOpen");
- return this.Json(optionalCourseSettingServices.GetOptionalCourseSettingViewGrid(configuretView, collegeID, standardID, coursematerialID, schoolYearID, Years, Status, isOpen, (int)pararms.page, (int)pararms.rows));
- }
- /// <summary>
- ///
- /// </summary>
- /// <param name="pararms"></param>
- /// <param name="GrademajorID"></param>
- /// <returns></returns>
- public ActionResult Class(QueryParamsModel pararms, Guid GrademajorID)
- {
- ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
- var schoolYearID = pararms.getExtraGuid("SchoolyearDropdown");
- var campusID = pararms.getExtraGuid("CampusDropdown");
- var collegeID = pararms.getExtraGuid("CollegeDropdown");
- var standardID = pararms.getExtraInt("StandardDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("StandardDictionaryDropDown");
- var grademajorID = pararms.getExtraGuid("GrademajorComboGrid");
- 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 schoolyear = pararms.getExtraInt("SchoolyearDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("SchoolyearDictionaryDropDown");
- return base.Json(ClassmajorServices.GetClassmajorViewGrid(configuretView, campusID, collegeID, schoolyear, standardID, educationID, learningformID, null , GrademajorID, null, null, (int)pararms.page, (int)pararms.rows));
- }
- /// <summary>
- /// 获取任务班授课老师
- /// </summary>
- /// <param name="educationMissionClassID"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult TeacherList(Guid executableOptionalCourseID)
- {
- var teacherList = optionalCourseSettingServices.GetEducationMissionClassTeacherListViewList(executableOptionalCourseID);
- return Json(new GridResultSet<OptionalCourseTeacherListView>() { rows = teacherList, total = teacherList.Count });
- }
- public ActionResult ClassList(Guid executableOptionalCourseID, string Type)
- {
- ViewBag.ID = executableOptionalCourseID;
- ViewBag.Type = Type;
- return View();
- }
- /// <summary>
- /// 获取可选课的班级
- /// </summary>
- /// <param name="educationMissionClassID"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult ClassList(Guid executableOptionalCourseID)
- {
- var classList = optionalCourseSettingServices.GetClassmajorList(executableOptionalCourseID);
- return Json(new GridResultSet<OptionalCourseClassListView>() { rows = classList, total = classList.Count });
- }
- /// <summary>
- /// 限选任务生成弹出页面
- /// </summary>
- /// <returns></returns>
- public ActionResult Create()
- {
- var conditionView = ConditionServices.GetSelectCourseConditionView();
- ViewBag.SelectSchoolYearID = conditionView.Schoolyear;
- return View(new OptionalCourseSettingCreateView());
- }
- /// <summary>
- /// 限选任务生成
- /// </summary>
- /// <param name="optionalCourseSettingView"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult Create(OptionalCourseSettingCreateView optionalCourseSettingView)
- {
- try
- {
- optionalCourseSettingServices.OptionalCourseSettingCreate(optionalCourseSettingView);
- 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
- });
- }
- }
- /// <summary>
- /// 编辑
- /// </summary>
- /// <returns></returns>
- public ActionResult Edit(Guid? ExecutableOptionalCourseIDs,string type)
- {
- OptionalCourseSettingView optionalCourseSettingView = new OptionalCourseSettingView();
- if (ExecutableOptionalCourseIDs.HasValue && ExecutableOptionalCourseIDs != Guid.Empty)
- optionalCourseSettingView = optionalCourseSettingServices.GetOptionalCourseSettingView(ExecutableOptionalCourseIDs);
- if (type == "add" && optionalCourseSettingView!=null)
- {
- optionalCourseSettingView.ExecutableOptionalCourseID = null;
- }
- ViewBag.RecordStatus = optionalCourseSettingView.RecordStatus;
- return View(optionalCourseSettingView);
- }
- /// <summary>
- /// 保存修改
- /// </summary>
- /// <param name="optionalCourseSettingView"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult Edit(OptionalCourseSettingView optionalCourseSettingView)
- {
- try
- {
- var teacherList = DataGrid.GetTableData<OptionalCourseTeacherListView>("dgTeacherList");
- var classList = DataGrid.GetTableData<OptionalCourseClassListView>("dgClassList");
- optionalCourseSettingServices.OptionalCourseSettingUpdate(optionalCourseSettingView, teacherList, classList);
- return Json(new ReturnMessage()
- {
- IsSuccess = true,
- Message = "保存成功!"
- });
- }
- catch (Exception ex)
- {
- return Json(new ReturnMessage()
- {
- IsSuccess = false,
- Message = "保存失败:" + ex.Message
- });
- }
- }
- /// <summary>
- /// 删除
- /// </summary>
- /// <param name="optionalCourseIDs"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult Delete(string optionalCourseSettingIDs)
- {
- try
- {
- List<Guid> list = new List<Guid>();
- for (int i = 0; i < optionalCourseSettingIDs.Split(',').Length; i++)
- {
- if (!string.IsNullOrEmpty(optionalCourseSettingIDs.Split(',')[i]))
- {
- Guid optionalCourseSettingID = new Guid(optionalCourseSettingIDs.Split(',')[i]);
- list.Add(optionalCourseSettingID);
- }
- }
- optionalCourseSettingServices.OptionalCourseSettingDelete(list);
- return this.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 this.Json("删除失败,原因:" + mge);
- }
- }
- /// <summary>
- /// 开放
- /// </summary>
- /// <param name="optionalCourseSettingIDs"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult Submit(string optionalCourseSettingIDs)
- {
- try
- {
- List<Guid> list = new List<Guid>();
- for (int i = 0; i < optionalCourseSettingIDs.Split(',').Length; i++)
- {
- if (!string.IsNullOrEmpty(optionalCourseSettingIDs.Split(',')[i]))
- {
- Guid optionalCourseSettingID = new Guid(optionalCourseSettingIDs.Split(',')[i]);
- list.Add(optionalCourseSettingID);
- }
- }
- optionalCourseSettingServices.OptionalCourseSettingSubmit(list);
- return this.Json("开放成功!");
- }
- catch (Exception ex)
- {
- string mge = ex.Message;
- System.Data.SqlClient.SqlException num = ExceptionHelper.GetSqlException(ex);
- return this.Json("开放失败,原因:" + mge);
- }
- }
- /// <summary>
- /// 取消
- /// </summary>
- /// <param name="optionalCourseSettingIDs"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult Cancel(string optionalCourseSettingIDs)
- {
- try
- {
- List<Guid?> list = new List<Guid?>();
- for (int i = 0; i < optionalCourseSettingIDs.Split(',').Length; i++)
- {
- string id = optionalCourseSettingIDs.Split(',')[i];
- if (!string.IsNullOrEmpty(id))
- {
- Guid optionalCourseSettingID = new Guid(id);
- list.Add(optionalCourseSettingID);
- }
- }
- optionalCourseSettingServices.OptionalCourseSettingCancel(list);
- return base.Json("取消成功!");
- }
- catch (Exception ex)
- {
- string mge = ex.Message;
- return base.Json("取消失败,原因:" + mge);
- }
- }
- /// <summary>
- ///
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- public ActionResult Excel()
- {
- //return View();
- NpoiExcelHelper neh = new NpoiExcelHelper();
- ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
- //避开全选值
- if (configuretView.Attribute == DropdownList.SELECT_ALL.ToString()) configuretView.Attribute = "";
- var standardID = Request.Form["StandardDictionaryDropDown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["StandardDictionaryDropDown"].ParseStrTo<int>();
- var coursematerialID = Request.Form["CoursematerialIDDropdownGridBo"].ParseStrTo<Guid>();
- var collegeID = Request.Form["ComboGridCollege"].ParseStrTo<Guid>();
- //var schoolYearNumID = Request.Form["DictionarySchoolYearNum"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionarySchoolYearNum"].ParseStrTo<int>();
- //var schoolCodeID = Request.Form["DictionarySchoolCode"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionarySchoolCode"].ParseStrTo<int>();
- //var isEnable = Request.Form["DictionaryIsEnable"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryIsEnable"].ParseStrTo<int>();
- var schoolYearID = Request.Form["SchoolYear"].ParseStrTo<Guid>();
- //var schoolCodeID = pararms.getExtraInt("DictionarySchoolCode") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionarySchoolCode");
- //var isEnable = pararms.getExtraInt("DictionaryIsEnable") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryIsEnable");
- var Years = Request.Form["DictionaryGrade"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryGrade"].ParseStrTo<int>();
- var Status = Request.Form["DictionaryStatus"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryStatus"].ParseStrTo<int>();
- var isOpened = Request.Form["DictionaryIsOpen"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryIsOpen"].ParseStrTo<int>();
- var dt = optionalCourseSettingServices.GetOptionalCourseSettingViewList(configuretView, collegeID, standardID, coursematerialID, schoolYearID, Years, Status, isOpened)
- .Select(x => new
- {
- x.SchoolYearCode,
- //x.GrademajorCode,
- x.GrademajorName,
- x.DefaultClassName,
- //x.CourseCode,
- x.CourseName,
- //x.CourseTypeName,
- //x.CourseCategoryName,
- //x.CourseQualityName,
- x.SchoolcodeName,
- x.SchoolyearNumName,
- x.Credit,
- x.Totalhours,
- //x.DepartmentName,
- //x.CollegeName,
- //x.IsEnableDesc,
- x.IsOpenedDesc,
- x.RecordStatusName,
- }).ToTable();
- string[] liststring = { "学年学期",
- //"年级专业代码",
- "年级专业名称", "班级名称",
- //"课程代码",
- "课程名称",
- //"课程类型", "课程属性", "课程性质",
- "学期", "开课学年",
- "学分","总学时",
- //"教研室", RSL.Get("College"),
- //"是否启用",
- "是否开放","状态"};
- neh.Export(dt, liststring, "限选设定");
- return RedirectToAction("MsgShow", "Common", new
- {
- msg = "导出成功!",
- url = Url.Content("~/OptionalCourseSetting/List").AddMenuParameter()
- });
- }
- [HttpPost]
- public ActionResult TeachingModeType(Guid? ExecutableOptionalCourseID)
- {
- List<string> list = new List<string>();
- if (ExecutableOptionalCourseID.HasValue && ExecutableOptionalCourseID != Guid.Empty)
- list = optionalCourseSettingServices.GetTeachingModeType(ExecutableOptionalCourseID);
- else
- list.Add(((int)EMIS.ViewModel.CF_TeachingMode.Theory).ToString());
- return base.Json(list);
- }
- [HttpPost]
- public ActionResult Save()
- {
- return View();
- //try
- //{
- // var optionalCourseSettingList = DataGrid.GetTableData<OptionalCourseSettingView>("dgOptionalCourseSettingList");
- // this.OptionalCoursePlanServices.SaveOptionalCourseSettings(optionalCourseSettingList);
- // return RedirectToAction("MsgShow", "Common", new
- // {
- // msg = "保存成功!",
- // url = Url.Content("~/OptionalCourseSetting/List").AddMenuParameter()
- // });
- //}
- //catch (Exception ex)
- //{
- // return RedirectToAction("MsgShow", "Common", new
- // {
- // msg = "保存失败!" + ex.Message,
- // url = Url.Content("~/OptionalCourseSetting/List").AddMenuParameter()
- // });
- //}
- }
- /// <summary>
- /// 编辑页新增班级
- /// </summary>
- /// <param name="pararms"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult ChooseClassList(QueryParamsModel pararms)
- {
- ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
- var GrademajorID = Request.Params["GrademajorID"].ParseStrTo<Guid>();
- //var campusID = pararms.getExtraGuid("CampusDropdown");
- //var collegeID = pararms.getExtraGuid("CollegeDropdown");
- //var grademajorID = pararms.getExtraGuid("GrademajorComboGrid");
- //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 schoolyear = pararms.getExtraInt("DictionarySchoolyear") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionarySchoolyear");
- return base.Json(ClassmajorServices.GetClassmajorViewGrid(configuretView, null, null, null, null, null, null, null, GrademajorID, null, null, (int)pararms.page, (int)pararms.rows));
- }
- }
- }
|