123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208 |
- 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.Web.Controls.Mvc;
- using EMIS.ViewModel.SelectCourse;
- using EMIS.Entities;
- using Bowin.Common.Exceptions;
- using Bowin.Common.Data;
- using Bowin.Common.Utility;
- using EMIS.Utility;
- using EMIS.Utility.FormValidate;
- namespace EMIS.Web.Controllers.SelectCourseManage
- {
- [Authorization]
- public class FreeSelectionCourseController : Controller
- {
- public IFreeSelectionCourseServices FreeSelectionCourseServices { get; set; }
- public IFreeSelectionCourseApplyServices FreeSelectionCourseApplyServices { 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 coursematerialID = pararms.getExtraGuid("CoursematerialIDDropdownGridBo");
- var departmentID = pararms.getExtraGuid("DepartmentComboGrid");
- var schoolcodeID = pararms.getExtraInt("DictionarySchoolcode") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionarySchoolcode");
- var starttermID = pararms.getExtraInt("DictionaryStartterm") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryStartterm");
- var isEnable = pararms.getExtraInt("DictionaryIsEnable") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryIsEnable");
- return base.Json(FreeSelectionCourseServices.GetFreeSelectionCourseViewGrid(configuretView, coursematerialID, departmentID,schoolcodeID, starttermID, isEnable, (int)pararms.page, (int)pararms.rows));
- }
- public ActionResult Edit(Guid? freeSelectionCourseIDs,string type)
- {
- FreeSelectionCourseView freeSelectionCourseView = new FreeSelectionCourseView();
- if (freeSelectionCourseIDs.HasValue)
- freeSelectionCourseView = FreeSelectionCourseServices.GetFreeSelectionCourseView(freeSelectionCourseIDs);
- else
- {
- var staff = FreeSelectionCourseApplyServices.GetStaff(CustomPrincipal.Current.UserID);
- if (staff != null)
- {
- freeSelectionCourseView.DepartmentID = staff.DepartmentID;
-
- ViewBag.DepartmentID = staff.DepartmentID;
- }
- freeSelectionCourseView.ResultTypeID = (int)CF_ResultType.Percentage;
- }
- //默认启用
- freeSelectionCourseView.IsEnable = true;
- if (freeSelectionCourseIDs.HasValue && type == "copyAdd")
- {
- freeSelectionCourseView.FreeSelectionCouseID = Guid.Empty;
- }
- return View(freeSelectionCourseView);
- }
- /// <summary>
- /// 编辑
- /// </summary>
- /// <param name="freeSelectionCourseView"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult Edit(FreeSelectionCourseView freeSelectionCourseView)
- {
- try
- {
- var user = HttpContext.User as EMIS.Utility.FormValidate.CustomPrincipal;
- if (freeSelectionCourseView.FreeSelectionCouseID == null || freeSelectionCourseView.FreeSelectionCouseID == Guid.Empty)
- {
- FreeSelectionCourseServices.FreeSelectionCourseAdd(freeSelectionCourseView);
- }
- else
- {
- FreeSelectionCourseServices.FreeSelectionCourseUpdate(freeSelectionCourseView);
- }
- return Json(new ReturnMessage()
- {
- IsSuccess = true,
- Message = "保存成功!"
- });
- }
- catch (Exception ex)
- {
- return Json(new ReturnMessage()
- {
- IsSuccess = false,
- Message = "保存失败:" + ex.Message
- });
- }
- }
- /// <summary>
- /// 删除
- /// </summary>
- /// <param name="freeSelectionCourseIDs"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult Delete(string freeSelectionCourseIDs)
- {
- try
- {
- List<Guid?> list = new List<Guid?>();
- for (int i = 0; i < freeSelectionCourseIDs.Split(',').Length; i++)
- {
- string id = freeSelectionCourseIDs.Split(',')[i];
- if (!string.IsNullOrEmpty(id))
- {
- Guid specialtyCourseID = new Guid(id);
- list.Add(specialtyCourseID);
- }
- }
- FreeSelectionCourseServices.FreeSelectionCourseDelete(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 coursematerialID = Request.Form["CoursematerialIDDropdownGridBo"].ParseStrTo<Guid>();
- var departmentID = Request.Form["DepartmentComboGrid"].ParseStrTo<Guid>();
- var schoolcodeID = Request.Form["DictionarySchoolcode"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionarySchoolcode"].ParseStrTo<int>();
- var starttermID = Request.Form["DictionaryStartterm"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryStartterm"].ParseStrTo<int>();
- var isEnable = Request.Form["DictionaryIsEnable"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryIsEnable"].ParseStrTo<int>();
- var dt = FreeSelectionCourseServices.GetFreeSelectionCourseViewList(configuretView, coursematerialID,departmentID, schoolcodeID, starttermID, isEnable).Select(x => new
- {
- //x.No,
- x.CourseCode,
- x.CourseName,
- //x.CourseCategoryName,
- x.CourseTypeName,
- x.CourseQualityName,
- x.Credit,
- x.Totalhours,
- //x.SchoolweeksNum,
- //x.SchoolyearNumName,
- //x.SchoolcodeName,
- //x.StarttermName,
- x.TeachingModeName,
- x.DepartmentName,
- x.IsEnableDesc
- }).ToTable();
- string[] liststring = { //"选课编号",
- "课程代码", "课程名称", //"课程属性",
- "课程类型",
- "课程性质","学分","总学时",//"上课周数","学年数","学期","开课学期",
- "授课方式","教研室","是否启用"};
- neh.Export(dt, liststring, "任选课程信息");
- return RedirectToAction("MsgShow", "Common", new
- {
- msg = "导出成功!",
- url = Url.Content("~/FreeSelectionCourse/List").AddMenuParameter()
- });
- }
- /// <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()));
- }
- }
- }
|