123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.Mvc;
- using EMIS.CommonLogic.SelectCourse;
- using EMIS.ViewModel;
- using EMIS.Web.Controls;
- using Bowin.Common.Data;
- using Bowin.Web.Controls.Mvc;
- using Bowin.Common.Mapping;
- using EMIS.ViewModel.SelectCourse;
- using EMIS.Utility.FormValidate;
- using Bowin.Common.Exceptions;
- using Bowin.Common.Utility;
- using Bowin.Common.Linq.Entity;
- using Bowin.Common.JSON;
- using EMIS.Utility;
- using EMIS.ViewModel.EnrollManage.SpecialtyManage;
- namespace EMIS.Web.Controllers.SelectCourseManage
- {
- [Authorization]
- public class FreeSelectionCourseApplyController : Controller
- {
- public IFreeSelectionCourseServices FreeSelectionCourseServices { get; set; }
- public IFreeSelectionCourseApplyServices FreeSelectionCourseApplyServices { get; set; }
- public IExecutableFreeSelectionCouseServices ExecutableFreeSelectionCouseServices { get; set; }
- /// <summary>
- /// 开课申请页面
- /// </summary>
- /// <returns></returns>
- public ActionResult List()
- {
- return View();
- }
- /// <summary>
- /// 查询列表
- /// </summary>
- /// <param name="pararms"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult List(QueryParamsModel pararms)
- {
- ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
- var campusID = pararms.getExtraGuid("CampusDropdown");
- var collegeID = pararms.getExtraGuid("CollegeDropdown");
- var departmentID = pararms.getExtraGuid("DepartmentDropdown");
- var schoolyear = pararms.getExtraGuid("SchoolYearDropdown").ToString() == DropdownList.SELECT_ALL.ToString() ? null : pararms.getExtraGuid("SchoolYearDropdown");
- var schoolyearNum = pararms.getExtraInt("DictionarySchoolyearNum").ToString() == DropdownList.SELECT_ALL.ToString() ? null : pararms.getExtraInt("DictionarySchoolyearNum");
- var schoolcode = pararms.getExtraInt("DictionarySchoolcode").ToString() == DropdownList.SELECT_ALL.ToString() ? null : pararms.getExtraInt("DictionarySchoolcode");
- var approvalStatus = pararms.getExtraInt("DictionaryApprovalStatus") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryApprovalStatus");
- return this.Json(FreeSelectionCourseApplyServices.GetFreeSelectionCoursePlanViewGrid(configuretView,
- schoolyear, campusID, collegeID, departmentID, approvalStatus, (int)pararms.page, (int)pararms.rows));
- }
- [HttpPost]
- public ActionResult Save()
- {
- try
- {
- var freeSelectionCourseApplyList = DataGrid.GetTableData<FreeSelectionCourseApplyView>("dgFreeSelectionCourseApplyList");
- this.FreeSelectionCourseApplyServices.FreeSelectionCourseApplyUpdate(freeSelectionCourseApplyList);
- return RedirectToAction("MsgShow", "Common", new
- {
- msg = "保存成功!",
- url = Url.Content("~/FreeSelectionCourseApply/List").AddMenuParameter()
- });
- }
- catch (Exception ex)
- {
- return RedirectToAction("MsgShow", "Common", new
- {
- msg = "保存失败!" + ex.Message,
- url = Url.Content("~/FreeSelectionCourseApply/List").AddMenuParameter()
- });
- }
- }
- public ActionResult Edit(Guid? freeSelectionCourseApplyID)
- {
- FreeSelectionCourseApplyView freeSelectCourseApplyView = new FreeSelectionCourseApplyView();
- freeSelectCourseApplyView.HandleModeID = (int)EMIS.ViewModel.CF_HandleMode.SelectionCourse;
- freeSelectCourseApplyView.DepartmentID = CustomPrincipal.Current.DepartmentID;
- ViewBag.LoginID = CustomPrincipal.Current.LoginID;
- ViewBag.Name = CustomPrincipal.Current.Name;
- ViewBag.UserID = CustomPrincipal.Current.UserID;
- ViewBag.StaffCode = "";
- if (freeSelectionCourseApplyID.HasValue)
- freeSelectCourseApplyView = FreeSelectionCourseApplyServices.GetFreeSelectionCourseApplyView(freeSelectionCourseApplyID);
- else
- {
- var staff = FreeSelectionCourseApplyServices.GetStaff(CustomPrincipal.Current.UserID);
- if (staff != null)
- {
- freeSelectCourseApplyView.DepartmentID = staff.DepartmentID;
- ViewBag.DepartmentID = staff.DepartmentID;
- ViewBag.StaffCode = staff.StaffCode;
- }
- freeSelectCourseApplyView.ResultTypeID = (int)CF_ResultType.Percentage;
- }
- return View(freeSelectCourseApplyView);
- }
- /// <summary>
- /// 编辑
- /// </summary>
- /// <param name="freeSelectionCourseApply"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult Edit(FreeSelectionCourseApplyView freeSelectionCourseApply)
- {
- int? type = 0;
- try
- {
- var teacherList = DataGrid.GetTableData<FreeSelectionCourseApplyTeacherListView>("dgTeacherList");
- var specialtyList = DataGrid.GetTableData<FreeSelectionCourseApplySpecialtyListView>("dgSpecialtyList");
- var schedulingList = DataGrid.GetTableData<ExecutableFreeSelectionCouseSchedulingView>("dgSchedulingList");
- if (freeSelectionCourseApply.FreeSelectionCouseApplyID == null || freeSelectionCourseApply.FreeSelectionCouseApplyID == Guid.Empty)
- {
- FreeSelectionCourseApplyServices.FreeSelectionCourseApplyAdd(freeSelectionCourseApply, teacherList, specialtyList, schedulingList, out type);
- }
- else
- {
- FreeSelectionCourseApplyServices.FreeSelectionCourseApplyUpdate(freeSelectionCourseApply, teacherList, specialtyList, schedulingList, out type);
- }
- return Json(new ReturnMessage()
- {
- IsSuccess = true,
- Message = "保存成功!"
- });
- }
- catch (Exception ex)
- { //如果验证到排课冲突type返回1,页面js根据type弹出选择框,用户可选择继续保存或不保存,如果不返回1,弹出一般的错误提示框
- if (type == 1)
- {
- return Json(new ReturnMessage()
- {
- Type = 1,
- IsSuccess = false,
- Message = "保存失败:" + ex.Message,
- });
- }
- else
- return Json(new ReturnMessage()
- {
- IsSuccess = false,
- Type = 2,
- Message = "保存失败:" + ex.Message,
- });
- }
- }
- /// <summary>
- /// 明细
- /// </summary>
- /// <param name="freeSelectionCourseApplyID"></param>
- /// <returns></returns>
- public ActionResult Details(Guid? freeSelectionCourseApplyID)
- {
- FreeSelectionCourseApplyView freeSelectCourseApplyView = new FreeSelectionCourseApplyView();
- if (freeSelectionCourseApplyID.HasValue)
- freeSelectCourseApplyView = FreeSelectionCourseApplyServices.GetFreeSelectionCourseApplyView(freeSelectionCourseApplyID);
- return View(freeSelectCourseApplyView);
- }
- public ActionResult TeacherEdit(Guid freeSelectionCourseApplyID)
- {
- return View();
- }
- /// <summary>
- /// 提交
- /// </summary>
- /// <param name="freeSelectionCourseApplyIDs"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult SubmitFreeSelectionCourseApply(string freeSelectionCourseApplyIDs)
- {
- try
- {
- var user = HttpContext.User as EMIS.Utility.FormValidate.CustomPrincipal;
- //for (int i = 0; i < freeSelectionCourseApplyIDs.Split(',').Length; i++)
- //{
- // if (!string.IsNullOrEmpty(freeSelectionCourseApplyIDs.Split(',')[i]))
- // {
- // Guid freeSelectionCourseApplyID = new Guid(freeSelectionCourseApplyIDs.Split(',')[i]);
- // FreeSelectionCourseApplyServices.StartUp(freeSelectionCourseApplyID, user.UserID);
- // }
- //}
- List<Guid> list = new List<Guid>();
- for (int i = 0; i < freeSelectionCourseApplyIDs.Split(',').Length; i++)
- {
- if (!string.IsNullOrEmpty(freeSelectionCourseApplyIDs.Split(',')[i]))
- {
- Guid planApplicationID = new Guid(freeSelectionCourseApplyIDs.Split(',')[i]);
- list.Add(planApplicationID);
- }
- }
- FreeSelectionCourseApplyServices.Submit(list, user.UserID, "");
- return this.Json("提交成功!");
- }
- catch (Exception ex)
- {
- return this.Json("提交失败,原因:" + ex.Message);
- }
- }
- /// <summary>
- /// 删除
- /// </summary>
- /// <param name="freeSelectionCourseApplyIDs"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult Delete(string freeSelectionCourseApplyIDs)
- {
- try
- {
- List<Guid?> list = new List<Guid?>();
- for (int i = 0; i < freeSelectionCourseApplyIDs.Split(',').Length; i++)
- {
- string id = freeSelectionCourseApplyIDs.Split(',')[i];
- if (!string.IsNullOrEmpty(id))
- {
- Guid freeSelectionCourseApplyID = new Guid(id);
- list.Add(freeSelectionCourseApplyID);
- }
- }
- FreeSelectionCourseApplyServices.FreeSelectionCourseApplyDelete(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);
- }
- }
- /// <summary>
- /// 导出Excel
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- public ActionResult Excel()
- {
- NpoiExcelHelper neh = new NpoiExcelHelper();
- ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
- var campusID = Request.Form["CampusDropdown"].ParseStrTo<Guid>();
- var collegeID = Request.Form["CollegeDropdown"].ParseStrTo<Guid>();
- var departmentID = Request.Form["DepartmentDropdown"].ParseStrTo<Guid>();
- var schoolyear = Request.Form["SchoolyearDropdown"] == DropdownList.SELECT_ALL.ToString() ? null : Request.Form["SchoolyearDropdown"].ParseStrTo<Guid>();
- //var schoolyearNum = Request.Form["DictionarySchoolyearNum"] == DropdownList.SELECT_ALL.ToString() ? null : Request.Form["DictionarySchoolyearNum"];
- //var schoolcode = Request.Form["DictionarySchoolcode"] == DropdownList.SELECT_ALL.ToString() ? null : Request.Form["DictionarySchoolcode"];
- var approvalStatus = Request.Form["DictionaryApprovalStatus"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryApprovalStatus"].ParseStrTo<int>();
- var dt = FreeSelectionCourseApplyServices.GetFreeSelectionCoursePlanViewList(configuretView, schoolyear, campusID, collegeID, departmentID, approvalStatus).Select(x => new
- {
- //x.FreeSelectionCouseNo,
- x.SchoolyearCode,
- x.DepartmentName,
- //x.CollegeName,
- x.DefaultClassName,
- //x.CourseCode,
- //x.CourseName,
- //x.CourseCategoryName,
- //x.CourseTypeName,
- //x.CourseQualityName,
- //x.Credit,
- //x.Totalhours,
- //x.SchoolweeksNum,
- //x.SchoolyearNumName,
- //x.SchoolcodeName,
- //x.StarttermName,
- x.TeacherNames,
- x.PeopleNumlower,
- x.PeopleNumlimit,
- x.CourseTypeName,
- x.IsNeedMaterialName,
- x.ApprovalStatusName
- }).ToTable();
- string[] liststring = { //"选课编号",
- "学年学期", "教研室", //RSL.Get("College"),
- "选修任务班名称",
- //"课程代码",
- //"课程名称", "课程属性", "课程类型", "课程性质", "学分","总学时",
- //"上课周数", "学年数", "学期", "开课学期"
- "授课教师","人数下限","人数上限","选修类型","是否需要教材","审批状态"};
- neh.Export(dt, liststring, "计划申请信息");
- return RedirectToAction("MsgShow", "Common", new
- {
- msg = "导出成功!",
- url = Url.Content("~/FreeSelectionCourseApply/List").AddMenuParameter()
- });
- }
- public ActionResult GetFreeSelectionCourseView(Guid? freeSelectionCourseID)
- {
- FreeSelectionCourseView freeSelectionCourseView = new FreeSelectionCourseView();
- if (freeSelectionCourseID.HasValue)
- freeSelectionCourseView = FreeSelectionCourseServices.GetFreeSelectionCourseView(freeSelectionCourseID);
- return base.Json(freeSelectionCourseView);
- }
- /// <summary>
- /// 获取任选课程已经存在在授课方式
- /// </summary>
- /// <param name="freeSelectionCourseID"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult TeachingModeType(Guid? freeSelectionCourseID)
- {
- List<int> list = new List<int>();
- if (freeSelectionCourseID.HasValue && freeSelectionCourseID != Guid.Empty)
- list = FreeSelectionCourseServices.GetTeachingModeType(freeSelectionCourseID);
- else
- list.Add(((int)EMIS.ViewModel.CF_TeachingMode.Theory));
- return base.Json(list.ConvertAll(x => x.ToString()));
- }
- /// <summary>
- /// 获取任选课程申请已经存在在授课方式
- /// </summary>
- /// <param name="freeSelectionCourseID"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult CourseApplyTeachingModeType(Guid? freeSelectionCourseID)
- {
- List<int> list = new List<int>();
- if (freeSelectionCourseID.HasValue && freeSelectionCourseID != Guid.Empty)
- list = FreeSelectionCourseApplyServices.GetCourseApplyTeachingModeType(freeSelectionCourseID);
- else
- list.Add(((int)EMIS.ViewModel.CF_TeachingMode.Theory));
- return base.Json(list.ConvertAll(x => x.ToString()));
- }
- [HttpPost]
- public ActionResult GradeYear(Guid? freeSelectionCourseApplyID)
- {
- List<int> list = new List<int>();
- if (freeSelectionCourseApplyID.HasValue && freeSelectionCourseApplyID != Guid.Empty)
- list = FreeSelectionCourseApplyServices.GetCourseApplyGradeYear(freeSelectionCourseApplyID);
- return base.Json(list.ConvertAll(x => x.ToString()));
- }
- /// <summary>
- /// 列表查询
- /// </summary>
- /// <param name="pararms"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult SpecialtyList(Guid freeSelectionCourseApplyID)
- {
- var specialtyList = this.FreeSelectionCourseApplyServices.GetFreeSelectionCourseApplySpecialtyListView(freeSelectionCourseApplyID);
- return base.Json(new GridResultSet<SpecialtyView>() { rows = specialtyList, total = specialtyList.Count });
- }
- /// <summary>
- /// 列表查询
- /// </summary>
- /// <param name="pararms"></param>
- /// <returns></returns>
- public ActionResult TeacherList(Guid freeSelectionCourseApplyID)
- {
- var teacherList = this.FreeSelectionCourseApplyServices.GetFreeSelectionCourseApplyTeacherListView(freeSelectionCourseApplyID);
- return base.Json(new GridResultSet<FreeSelectionCourseApplyTeacherListView>() { rows = teacherList, total = teacherList.Count });
- }
- [HttpPost]
- public ActionResult TeacherEdit(Guid freeSelectionCourseApplyID, string addTeacherListJson)
- {
- try
- {
- var addTeacherList = addTeacherListJson.JsonToObject<List<FreeSelectionCourseApplyTeacherListView>>();
- FreeSelectionCourseServices.SaveFreeSelectionCourseTeachers(freeSelectionCourseApplyID, addTeacherList);
- return Json(new ReturnMessage { IsSuccess = true });
- }
- catch (Exception ex)
- {
- return Json(new ReturnMessage { IsSuccess = false, Message = ex.Message });
- }
- }
- [HttpPost]
- public ActionResult DefaultClassNo(Guid SchoolyearID, Guid freeSelectionCourseID, string StartWeeklyNum, string EndWeeklyNum)
- {
- try
- {
- var result = FreeSelectionCourseApplyServices.DefaultClassNo(SchoolyearID, freeSelectionCourseID, StartWeeklyNum, EndWeeklyNum);
- return base.Json(result);
- }
- catch (Exception ex)
- {
- return Json("");
- }
- }
- public ActionResult GetSchedulingViewList(Guid FreeSelectionCouseApplyID)
- {
- var courseProcessList = FreeSelectionCourseApplyServices.GetSchedulingView(FreeSelectionCouseApplyID);
- return Json(new GridResultSet<ExecutableFreeSelectionCouseSchedulingView> { rows = courseProcessList, total = courseProcessList.Count });
- }
- public ActionResult CourseProcessClassroomList()
- {
- return View();
- }
- public ActionResult CoursesTimeList()
- {
- return View();
- }
- /// <summary>
- /// 列出课程进度中的可选教室
- /// </summary>
- /// <param name="pararms"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult GetCourseProcessClassroomList(QueryParamsModel pararms)
- {
- ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
- int? classroomType = pararms.getExtraString("ClassroomType").ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : pararms.getExtraString("ClassroomType").ParseStrTo<int>();
- string schedulingWeek = pararms.getExtraString("schedulingWeek");
- int? weekday = pararms.getExtraString("weekDay").ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : pararms.getExtraString("weekDay").ParseStrTo<int>();
- var coursesTimeID = pararms.getExtraGuid("coursesTimeID") ?? Guid.Empty;
- //int? minSeatCount = pararms.getExtraString("MinSeatCount").ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : pararms.getExtraString("MinSeatCount").ParseStrTo<int>();
- //var collegeID = pararms.getExtraGuid("CollegeDropdown") ?? Guid.Empty;
- var buildingsID = pararms.getExtraInt("BuildingsDropdown") == DropdownList.SELECT_ALL ? null : pararms.getExtraGuid("BuildingsDropdown");
- return base.Json(ExecutableFreeSelectionCouseServices.GetAvailableClassroom(configuretView, buildingsID, schedulingWeek, weekday, coursesTimeID, classroomType, (int)pararms.page, (int)pararms.rows));
- }
- }
- }
|