123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.Mvc;
- using EMIS.ViewModel;
- using Bowin.Web.Controls.Mvc;
- using EMIS.Web.Controls;
- using EMIS.CommonLogic.CultureplanManage.PlanManagement;
- using EMIS.ViewModel.SelectCourse;
- using Bowin.Common.Exceptions;
- using EMIS.Entities;
- using Bowin.Common.Utility;
- using Bowin.Common.Data;
- using EMIS.CommonLogic.UniversityManage.SpecialtyClassManage;
- using EMIS.CommonLogic.CalendarManage;
- using EMIS.ViewModel.UniversityManage.SpecialtyClassManage;
- using EMIS.ViewModel.CultureplanManage.PlanManagement;
- using System.IO;
- using System.Text;
- using EMIS.Utility;
- using EMIS.ViewModel.EnrollManage.NewStudentManage;
- using EMIS.CommonLogic.SelectCourse;
- namespace EMIS.Web.Controllers.CultureplanManage.PlanManagement
- {
- [Authorization]
- public class OptionalCoursePlanController : Controller
- {
- public IOptionalCoursePlanServices optionalCourseSettingServices { 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 standardID = pararms.getExtraInt("StandardDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("StandardDictionaryDropDown");
- var schoolYearNumID = pararms.getExtraInt("DictionarySchoolYearNum") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionarySchoolYearNum");
- 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 isOpen = pararms.getExtraInt("DictionaryIsOpen") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryIsOpen");
- 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 LearnSystem = pararms.getExtraString("DictionaryLearnSystem");
- return this.Json(optionalCourseSettingServices.GetOptionalCourseSettingViewGrid(configuretView, standardID, coursematerialID, schoolYearNumID, schoolCodeID, isEnable, isOpen, educationID, learningFormID,LearnSystem, (int)pararms.page, (int)pararms.rows));
- }
- /// <summary>
- /// 编辑
- /// </summary>
- /// <returns></returns>
- public ActionResult Edit(Guid? optionalCoursePlanID)
- {
- OptionalCoursePlanView optionalCourseSettingView = new OptionalCoursePlanView();
- if (optionalCoursePlanID.HasValue && optionalCoursePlanID != Guid.Empty)
- optionalCourseSettingView = optionalCourseSettingServices.GetOptionalCourseSettingView(optionalCoursePlanID);
- return View(optionalCourseSettingView);
- }
- /// <summary>
- /// 保存修改
- /// </summary>
- /// <param name="optionalCourseSettingView"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult Edit(OptionalCoursePlanView optionalCourseSettingView)
- {
- try
- {
- optionalCourseSettingServices.OptionalCourseUpdate(optionalCourseSettingView);
- return Json(new ReturnMessage()
- {
- IsSuccess = true,
- Message = "保存成功!"
- });
- }
- catch (Exception ex)
- {
- return Json(new ReturnMessage()
- {
- IsSuccess = false,
- Message = "保存失败:" + ex.Message
- });
- }
- }
- [HttpPost]
- public ActionResult TeachingModeType(Guid? OptionalCourseID)
- {
- List<string> list = new List<string>();
- if (OptionalCourseID.HasValue && OptionalCourseID != Guid.Empty)
- list = optionalCourseSettingServices.GetTeachingModeType(OptionalCourseID);
- else
- list.Add(((int)EMIS.ViewModel.CF_TeachingMode.Theory).ToString());
- return base.Json(list);
- }
- /// <summary>
- /// 删除
- /// </summary>
- /// <param name="optionalCourseIDs"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult Delete(string optionalCoursePlanIDs)
- {
- try
- {
- List<Guid> list = new List<Guid>();
- for (int i = 0; i < optionalCoursePlanIDs.Split(',').Length; i++)
- {
- if (!string.IsNullOrEmpty(optionalCoursePlanIDs.Split(',')[i]))
- {
- Guid optionalCoursePlanID = new Guid(optionalCoursePlanIDs.Split(',')[i]);
- list.Add(optionalCoursePlanID);
- }
- }
- optionalCourseSettingServices.OptionalCourseDelete(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>
- /// <returns></returns>
- public ActionResult Add(Guid? optionalCoursePlanID)
- {
- OptionalCoursePlanView optionalCourseSettingView = new OptionalCoursePlanView();
- if (optionalCoursePlanID.HasValue && optionalCoursePlanID != Guid.Empty)
- {
- optionalCourseSettingView = optionalCourseSettingServices.GetOptionalCourseSettingView(optionalCoursePlanID);
- }
- //默认值
- optionalCourseSettingView.CourseStructureID = 1;
- optionalCourseSettingView.CourseCategoryID = 2;
- optionalCourseSettingView.CourseTypeID = 4;
- optionalCourseSettingView.CourseQualityID = 5;
- optionalCourseSettingView.ExaminationModeID = (int)EMIS.ViewModel.CF_ExaminationMode.WrittenExam;
- optionalCourseSettingView.TeachinglanguageID = 1;
- optionalCourseSettingView.IsEnable = true;
- return View(optionalCourseSettingView);
- }
- ///<summary>
- /// 添加
- /// </summary>
- /// <param name="planApplicationView"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult Add(OptionalCoursePlanView optionalCourseSettingView)
- {
- try
- {
- optionalCourseSettingServices.OptionalCourseAdd(optionalCourseSettingView);
- return Json(new ReturnMessage()
- {
- IsSuccess = true,
- Message = "保存成功!"
- });
- }
- catch (Exception ex)
- {
- return Json(new ReturnMessage()
- {
- IsSuccess = false,
- Message = "保存失败:" + ex.Message
- });
- }
- }
- ///<summary>
- ///导出Excel
- ///</summary>
- ///<returns></returns>
- [HttpPost]
- public ActionResult Excel()
- {
- NpoiExcelHelper neh = new NpoiExcelHelper();
- ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
- var standardID = Request.Form["StandardDictionaryDropDown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["StandardDictionaryDropDown"].ParseStrTo<int>();
- var coursematerialID = Request.Form["CoursematerialIDDropdownGridBo"].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 isOpen = Request.Form["DictionaryIsOpen"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryIsOpen"].ParseStrTo<int>();
- var educationID = Request.Form["DictionaryEducation"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryEducation"].ParseStrTo<int>();
- var learningFormID = Request.Form["DictionaryLearningform"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryLearningform"].ParseStrTo<int>();
- var LearnSystem = "";
- //Request.Form["DictionaryLearnSystem"].ToString();
- var dt = optionalCourseSettingServices.GetOptionalCourseSettingViewList(configuretView, standardID, coursematerialID, schoolYearNumID, schoolCodeID, isEnable, isOpen,educationID,learningFormID, LearnSystem).Select(x => new
- {
- x.StandardCode,
- x.StandardName,
- x.CourseCode,
- x.CourseName,
- x.CourseTypeName,
- x.CourseCategoryName,
- x.CourseQualityName,
- x.SchoolcodeName,
- x.SchoolyearNumName,
- //x.Credit,
- //x.Totalhours,
- //x.TheoryCourse,
- //x.Practicehours,
- x.DepartmentName,
- x.IsEnableDesc,
- //x.IsOpenedDesc
- }).ToTable();
- string[] liststring = { "专业代码", "专业名称", "课程代码","课程名称","课程类型","课程属性", "课程性质", "学期",
- //"学分","总学时","理论学时","实践学时",
- "开课年级","教研室","是否启用"
- //,"是否开放"
- };
- neh.Export(dt, liststring, "限选计划信息");
- return Json(new ReturnMessage()
- {
- IsSuccess = true,
- Message = "导出成功!"
- });
- }
- //#region 13.0 新生信息导入
- //[HttpGet]
- //public ActionResult Import(string errorFile, string operationTips)
- //{
- // ViewBag.ErrorFile = errorFile;
- // if (string.IsNullOrEmpty(operationTips))
- // {
- // operationTips = "错误数据下载";
- // }
- // ViewBag.operationTips = operationTips;
- // return View();
- //}
- //[HttpPost]
- //public ActionResult Import(HttpPostedFileBase file)
- //{
- // try
- // {
- // //1.0 HSSFWorkbook:是操作Excel2003以前(包括2003)的版本,扩展名是.xls
- // //2.0 XSSFWorkbook:是操作Excel2007的版本,扩展名是.xlsx
- // var accept = new[] { ".xls", ".xlsx" };
- // var p = Path.GetExtension(file.FileName);
- // if (!accept.Contains(p))
- // {
- // throw new Exception("只允许上传xls和xlsx格式的Excel文件!");
- // }
- // Dictionary<string, string> cellheader = new Dictionary<string, string>
- // {
- // { "ExamineeNum", "考生号" }, { "Name", "姓名" },
- // { "SexStr", "性别" }, { "NationStr", "民族" },
- // { "PoliticsStr", "政治面貌" }, { "BirthDateStr", "出生日期" },
- // { "CertificatesTypeStr", "证件类型" }, { "IDNumber", "证件号码" },
- // { "EntranceDateStr", "入学日期" }, { "YearID", "年级" },
- // { "StandardName", "专业名称" }, { "LearnSystemStr", "学制" },
- // { "EducationStr", EMIS.Utility.RSL.Get("EducationID") }, { "LearningformStr", "学习形式" },
- // { "ScoreStr", "总分" }, { "Telephone", "联系电话" },
- // { "Address", "通讯地址" },{ "Remark", "备注" }
- // };
- // StringBuilder errorMsg = new StringBuilder(); // 错误信息
- // string sourceWebPath = FileUploadHelper.UploadFile(file);
- // var sourcePhysicalPath = Server.MapPath(sourceWebPath);
- // List<OptionalCoursePlanView> errList = new List<OptionalCoursePlanView>();
- // List<OptionalCoursePlanView> dataList = new List<OptionalCoursePlanView>();
- // int errCount = 0;
- // int OkCount = 0;
- // otionalCourseSettingServices.OptionalCoursePlanImport(cellheader, out OkCount, out errList, out errCount, sourcePhysicalPath);
- // System.IO.File.Delete(sourcePhysicalPath);//删除本地缓存文件
- // if (errList.Count() > 0)
- // {
- // //将异常文件路径显示
- // string errorWebPath = string.Format("{0}", NpoiExcelHelper.EntityListToExcel2003(cellheader, errList, "新生信息导入失败文件", sourcePhysicalPath));
- // ViewBag.ErrorFile = errorWebPath;
- // string Errinfo = string.Format("提示:成功导入{0}条记录,失败{1}条,详情请点击错误数据下载查看。", OkCount < 1 ? 0 : OkCount, errCount < 1 ? 0 : errCount);
- // ViewBag.operationTips = Errinfo;
- // //return RedirectToAction("Import", new { errorFile = errorWebPath, operationTips = Errinfo });
- // return RedirectToAction("MsgShow", "Common", new
- // {
- // WindowID = "none",
- // msg = "导入失败!",
- // url = Url.Action("Import").AddMenuParameter() + "&errorFile=" + errorWebPath + "&operationTips=" + Errinfo + "&WindowID=" + Request["WindowID"]
- // });
- // }
- // else
- // {
- // return RedirectToAction("MsgShow", "Common", new
- // {
- // WindowID = Request["WindowID"],
- // msg = "导入成功!",
- // url = Url.Action("List").AddMenuParameter()
- // });
- // }
- // }
- // catch (Exception ex)
- // {
- // return RedirectToAction("MsgShow", "Common", new
- // {
- // WindowID = Request["WindowID"],
- // msg = "导入失败,原因:" + ex.Message + "!",
- // url = Url.Action("List").AddMenuParameter()
- // });
- // }
- //#endregion
- //}
- }
- }
|