123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.Mvc;
- using EMIS.CommonLogic.CalendarManage;
- using EMIS.CommonLogic.EducationSchedule;
- using EMIS.ViewModel;
- using EMIS.Web.Controls;
- using Bowin.Web.Controls.Mvc;
- using Bowin.Common.Utility;
- using System.Text;
- using EMIS.Utility;
- using Bowin.Common.Data;
- using EMIS.ViewModel.EducationManagement;
- using EMIS.ViewModel.EducationManage;
- using Bowin.Common.Exceptions;
- namespace EMIS.Web.Controllers.EducationSchedule
- {
- [Authorization]
- public class EducationMissionClassScheduleAdultController : Controller
- {
- //
- // GET: /EducationMissionClassScheduleAdult/
- public ISchoolYearServices SchoolYearServices { get; set; }
- public IEducationMissionClassScheduleAdultServices IEducationMissionClassScheduleAdultServices { get; set; }
- public ActionResult List()
- {
- var schoolYear = SchoolYearServices.GetSchoolYearIsCurrent(true);
- ViewBag.SchoolYearID = schoolYear == null ? "-1" : schoolYear.SchoolyearID.ToString();//默认当前学年
- return View();
- }
- #region 查询任务班排课列表
- /// <summary>
- /// 查询任务班排课列表
- /// </summary>
- /// <param name="pararms"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult List(QueryParamsModel pararms)
- {
- ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
- var schoolyearID = pararms.getExtraGuid("SchoolyearDropdownList");
- var coursematerialID = pararms.getExtraGuid("CoursematerialComboGrid");
- var campusID = pararms.getExtraGuid("ComboGridCampus");
- var collegeID = pararms.getExtraGuid("ComboGridCollege");
- var StandardID = pararms.getExtraInt("DictionaryStandard");
- var departmentID = pararms.getExtraGuid("DepartmentDropdown");
- var grademajorID = pararms.getExtraGuid("GrademajorComboGrid");
- var gradeYearID = pararms.getExtraInt("DictionaryGrade") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryGrade");
- var approvalStatus = pararms.getExtraInt("ApprovalStatusDropdownList") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ApprovalStatusDropdownList");
- var teachingMode = pararms.getExtraInt("DictionaryTeachingMode") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryTeachingMode");
- var CoursesTimeID = pararms.getExtraGuid("TimeComboGrid");
- var learningformID = pararms.getExtraInt("LearningformDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("LearningformDictionaryDropDown");
- var education = pararms.getExtraInt("DictionaryEducation") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryEducation");
- var LearnSystem = pararms.getExtraString("DictionaryLearnSystem");
- var result = IEducationMissionClassScheduleAdultServices.GetEducationMissionClassScheduleViewGrid(configuretView, campusID, collegeID, schoolyearID, departmentID, coursematerialID, approvalStatus, teachingMode, grademajorID, gradeYearID, StandardID, CoursesTimeID,learningformID,education,LearnSystem, (int)pararms.page, (int)pararms.rows);
-
- return Json(result);
- }
- #endregion
- [HttpPost]
- public ActionResult Delete(string educationMissionClassIDs)
- {
- try
- {
- List<Guid?> list = new List<Guid?>();
- var educationMissionClassArray = educationMissionClassIDs.Split(',');
- for (int i = 0; i < educationMissionClassArray.Length; i++)
- {
- if (!string.IsNullOrEmpty(educationMissionClassArray[i]))
- {
- Guid? educationMissionClassID = new Guid(educationMissionClassArray[i]);
- list.Add(educationMissionClassID);
- }
- }
- IEducationMissionClassScheduleAdultServices.EducationMissionClassScheduleDelete(list);
- return Json(new ReturnMessage { IsSuccess = true });
- }
- catch (Exception ex)
- {
- string mge = ex.Message;
- System.Data.SqlClient.SqlException num = ExceptionHelper.GetSqlException(ex);
- if (num != null)
- {
- if (num.Number == 547)
- mge = "请先删除所有关联的数据,排课课表,学生成绩,教学评价等";
- }
- return Json(new ReturnMessage { IsSuccess = false, Message = "删除失败:" + mge });
- }
- }
- [HttpGet]
- public ActionResult Import(string errorFile, string operationTips)
- {
- ViewBag.ErrorFile = errorFile;
- var schoolYearView = SchoolYearServices.GetSchoolYearIsCurrent(true);
- var schoolyear = SchoolYearServices.GetSchoolYearViewListAfterCurrent().OrderBy(x => x.Code).Where(x => x.Value > schoolYearView.Value).FirstOrDefault();
- EducationMissionImportClassView classView = new EducationMissionImportClassView();
- if (schoolyear != null)
- {
- classView.SchoolyearID = schoolyear.SchoolYearID;
- }
- else
- {
- classView.SchoolyearID = schoolYearView.SchoolyearID;
- }
- if (string.IsNullOrEmpty(operationTips))
- {
- operationTips = "错误数据下载";
- }
- ViewBag.operationTips = operationTips;
- return View(classView);
- }
- #region 导入
- [HttpPost]
- public ActionResult Import(HttpPostedFileBase file,EducationMissionClassView classView)
- {
- try
- {
- Guid schoolyearID = (Guid)classView.SchoolyearID;
- //1.0 HSSFWorkbook:是操作Excel2003以前(包括2003)的版本,扩展名是.xls
- //2.0 XSSFWorkbook:是操作Excel2007的版本,扩展名是.xlsx
- if (!NpoiExcelHelper.GetIsCompatible(file.FileName))
- {
- throw new Exception("只允许上传xls和xlsx格式的Excel文件!");
- }
- StringBuilder errorMsg = new StringBuilder(); // 错误信息
- string sourceWebPath = FileUploadHelper.UploadFile(file);
- var sourcePhysicalPath = Server.MapPath(sourceWebPath);
- List<EducationMissionImportClassView> errList = new List<EducationMissionImportClassView>();
- int errCount = 0;//失败条数
- int OkCount = 0;//成功条数
- string errorWebPath = "";
- string Errinfo = "";
- IEducationMissionClassScheduleAdultServices.EducationMissionClassImport(out errCount, out errList, out OkCount, sourcePhysicalPath, sourceWebPath, out errorWebPath, out Errinfo,schoolyearID);
- System.IO.File.Delete(sourcePhysicalPath);//删除本地缓存文件
- if (errCount > 0)
- {
- ViewBag.ErrorFile = errorWebPath;
- ViewBag.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
- #region 2.0 Excel导出
- /// <summary>
- /// 导出Excel
- /// </summary>
- /// <param name="pararms"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult Excel()
- {
- NpoiExcelHelper neh = new NpoiExcelHelper();
- ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
- var EducationMissionClassID = Request.Form["EducationMissionClassID"];
- var campusID = Request.Form["ComboGridCampus"].ParseStrTo<Guid>();
- var collegeID = Request.Form["ComboGridCollege"].ParseStrTo<Guid>();
- var coursematerialID = Request.Form["CoursematerialComboGrid"].ParseStrTo<Guid>();
- var grademajorID = Request.Form["GrademajorComboGrid"].ParseStrTo<Guid>();
- var gradeYearID = Request.Form["DictionaryGrade"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryGrade"].ParseStrTo<int>();
- var schoolyearID = Request.Form["SchoolyearDropdownList"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["SchoolyearDropdownList"].ParseStrTo<Guid>();
- var approvalStatus = Request.Form["ApprovalStatusDropdownList"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["ApprovalStatusDropdownList"].ParseStrTo<int>();
- var teachingModeID = Request.Form["DictionaryTeachingMode"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryTeachingMode"].ParseStrTo<int>();
- var StandardID = Request.Form["DictionaryStandard"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryStandard"].ParseStrTo<int>();
- var departmentID = Request.Form["DepartmentDropdown"].ParseStrTo<Guid>();
- List<Guid?> EducationMissionClassList =new List<Guid?>();
- var CoursesTimeID = Request.Form["TimeComboGrid"].ParseStrTo<Guid>();
- var learningformID = Request.Form["LearningformDictionaryDropDown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["LearningformDictionaryDropDown"].ParseStrTo<int>();
- var education = Request.Form["DictionaryEducation"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryEducation"].ParseStrTo<int>();
- var LearnSystem = Request.Form["DictionaryLearnSystem"].ToString();
- if (EducationMissionClassID != "")
- {
- EducationMissionClassList = EducationMissionClassID.SplitIDString();
- }
- else
- {
- EducationMissionClassList = null;
- }
- var dt = IEducationMissionClassScheduleAdultServices.GetEducationMissionClassScheduleViewGridExcel(configuretView, campusID, collegeID, schoolyearID, departmentID, coursematerialID, approvalStatus, teachingModeID, grademajorID, gradeYearID, StandardID, EducationMissionClassList, CoursesTimeID, learningformID, education, LearnSystem).Select(x => new
- {
- x.CollegeName,
- x.EducationName,
- x.LearningformName,
- x.ClassNum,
- x.Name,
- x.CourseName,
- x.Totalhours,
- x.ExamDay,
- x.date,
- x.showClassRoom,
- x.TeacherNames,
- x.ExaminationModeName,
- x.ExamWeekShow,
- x.Examedate_time,
- x.Assistant,
- x.StandardName,
- x.CourseCode,
- courseTimeShow = x.CourseTimeShow,
- x.TheoryCourse,
- x.Practicehours,
- teachingDay = x.TeachingDay,
- teachingHours = x.TeachingHours
- }).ToTable();
- string[] liststring = { RSL.Get("College"), RSL.Get("CultureModel"),"学习形式","班级人数", "任务班名称",
- "课程名称", "总学时","参考天数","上课时间","课室",
- "授课教师", "考试方式","考试周次","考试时间",
- "班主任","年级专业","课程代码","课时类别", "理论学时" ,
- "实践学时", "执行天数","执行学时"};
- neh.Export(dt, liststring, "教学任务班基础信息");
- return Json(new ReturnMessage()
- {
- IsSuccess = true,
- Message = "导出成功!"
- });
- }
- #endregion
- }
- }
|