123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.Mvc;
- using EMIS.CommonLogic.DQPSystem;
- using EMIS.ViewModel;
- using EMIS.Web.Controls;
- using Bowin.Web.Controls.Mvc;
- using Bowin.Common.Data;
- using EMIS.Utility;
- using Bowin.Common.Exceptions;
- using Bowin.Common.Utility;
- using EMIS.ViewModel.DQPSystem;
- namespace EMIS.Web.Controllers.DQPSystem
- {
- [Authorization]
- public class SOCTemplateController : Controller
- {
- //
- // GET: /SOCTemplate/
- public ISOCTemplateServices SOCTemplateServices { get; set; }
- public ActionResult List()
- {
- return View();
- }
- [HttpPost]
- public ActionResult List(QueryParamsModel pararms)
- {
- ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
- var standardID = pararms.getExtraInt("StandardDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("StandardDictionaryDropDown");
- var facultymajorID = pararms.getExtraGuid("FacultymajorComboGrid");
- var departmentID = pararms.getExtraGuid("DepartmentComboGrid");
- 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");
- var coursematerialID = pararms.getExtraGuid("CoursematerialIDDropdownGridBo");
- 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 result = SOCTemplateServices.GetSOCTemplateViewGrid(configuretView, standardID, facultymajorID, departmentID, educationID, learningformID, LearnSystem, coursematerialID, schoolyearNumID, schoolcodeID, isEnable, (int)pararms.page, (int)pararms.rows);
- return Json(result);
- }
- [HttpGet]
- public ActionResult TemplateDetail(Guid? templateID)
- {
- ViewBag.TemplateID = templateID;
- return View();
- }
- [HttpPost]
- public ActionResult TemplateDetail(QueryParamsModel pararms)
- {
- ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
- var templateID = Request["templateID"].ParseStrTo<Guid>();
- return Json(SOCTemplateServices.GetSOCTemplateDetailViewGrid(templateID, (int)pararms.page, (int)pararms.rows));
- }
- //[HttpPost]
- //public ActionResult GetNewGuidForSOCTemplateItemID(int count)
- //{
- // var SOCTemplateItemID = Guid.NewGuid();
- // return Json(SOCTemplateItemID);
- //}
- /// <summary>
- /// 复制新增
- /// </summary>
- /// <param name="graduationApplyID"></param>
- /// <returns></returns>
- public ActionResult CopyAdd(Guid? templateID)
- {
- SOCTemplateView SOCTemplateView = new SOCTemplateView();
- SOCTemplateView = SOCTemplateServices.GetSOCTemplateViewByID(templateID);
- return View("Edit", SOCTemplateView);
- }
- /// <summary>
- /// 复制新增
- /// </summary>
- /// <param name="graduationApplyView"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult CopyAdd(SOCTemplateView SOCTemplateView)
- {
- SOCTemplateView.SOCTemplateID = Guid.Empty;
- return this.Edit(SOCTemplateView);
- }
- public ActionResult Edit(Guid? templateID)
- {
- var SOCTemplateView = new SOCTemplateView();
-
- if (templateID.HasValue)
- {
- SOCTemplateView = SOCTemplateServices.GetSOCTemplateViewByID(templateID);
- }
- return View(SOCTemplateView);
- }
- [HttpPost]
- public ActionResult Edit(SOCTemplateView SOCTemplateView)
- {
- try
- {
- //var count = Session.Count;
- List<FileUploadView> filelist = new List<FileUploadView>();
- //for (int i = 0; i < count; i++)
- //{
- // var file = Session[i];
- // if (file.GetType() == typeof(List<FileUploadView>))
- // {
- // filelist = (List<FileUploadView>)file;
- // }
- //}
- var TDList = DataGrid.GetTableData<SOCTemplateDetailView>("dgSOCTemplateDetailList");//获取底部列表项数据
- if (TDList.Count <= 0)
- {
- return Json(new ReturnMessage()
- {
- IsSuccess = false,
- Message = "保存失败,原因:SOC不能为空。"
- });
- }
- else
- {
- var detailIDList = TDList.Select(x => x.SOCTemplateItemID).ToList();
- foreach (var id in detailIDList)
- {
- var sessionName = FileUploadHelper.GetFileUploadSessionName(id);
- var sessionfileList = (List<FileUploadView>)Session[sessionName];
- if (sessionfileList != null)
- {
- foreach (var file in sessionfileList)
- {
- filelist.Add(file);
- }
- }
- }
- SOCTemplateServices.SOCTemplateEdit(SOCTemplateView,TDList,filelist);
- //StockOutServices.Save(stockOutView, TMList, user.UserID, type);
- }
- return Json(new ReturnMessage()
- {
- IsSuccess = true,
- Message = "保存成功。"
- });
- }
- catch (Exception ex)
- {
- return Json(new ReturnMessage()
- {
- IsSuccess = false,
- Message = "保存失败,原因:" + ex.Message
- });
- }
- }
- [HttpGet]
- public ActionResult Upload(Guid? SOCTemplateItemID)
- {
- SOCTemplateDetailView templateDetailView = new SOCTemplateDetailView();
- templateDetailView.SOCTemplateItemID = SOCTemplateItemID.Value;
- return View(templateDetailView);
- }
- [HttpPost]
- public ActionResult Upload()
- {
- return Json("上传成功");
- }
- [HttpPost]
- public ActionResult GetFileListByItemID(string TemplateDetailID)
- {
- var templateID = TemplateDetailID.ParseStrTo<Guid>();
- var sessionName = FileUploadHelper.GetFileUploadSessionName(templateID ?? Guid.Empty);
- var fileList = (List<FileUploadView>)Session[sessionName];
- //var count = Session.Count;
- //List<FileUploadView> filelist = new List<FileUploadView>();
- //for (int i = 0; i < count; i++)
- //{
- // var file = Session[i];
- // if (file.GetType() == typeof(List<FileUploadView>))
- // {
- // filelist = (List<FileUploadView>)file;
- // }
- //}
- //ViewBag.FileList = filelist;
- //foreach (var file in filelist)
- //{
-
- //}
- return Json(fileList);
- }
- /// <summary>
- /// 生成
- /// </summary>
- /// <returns></returns>
- [HttpGet]
- public ActionResult Generate()
- {
- return View();
- }
- /// <summary>
- /// 生成
- /// </summary>
- /// <param name="schoolYearID"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult Generate(QueryParamsModel pararms)
- {
- try
- {
- var collegeID = Request.Form["CollegeDropdown"].ParseStrTo<Guid>();
- var standardID = Request.Form["StandardDictionaryDropDown"].ParseStrTo<int>();
- var facultymajorID = Request.Form["FacultymajorDropDown"].ParseStrTo<Guid>();
- var coursematerialID = Request.Form["CoursematerialDropDown"].ParseStrTo<Guid>();
- SOCTemplateServices.GenerateTemplate(collegeID, standardID, facultymajorID, coursematerialID);
- return Json(new ReturnMessage()
- {
- IsSuccess = true,
- Message = "生成成功。"
- });
- }
- catch (Exception ex)
- {
- return Json(new ReturnMessage()
- {
- IsSuccess = false,
- Message = "生成失败:" + ex.Message
- });
- }
- }
- public ActionResult Delete(string SOCTemplateIDs)
- {
- try
- {
- List<Guid?> list = new List<Guid?>();
- for (int i = 0; i < SOCTemplateIDs.Split(',').Length; i++)
- {
- if (!string.IsNullOrEmpty(SOCTemplateIDs.Split(',')[i]))
- {
- Guid SOCTemplateID = new Guid(SOCTemplateIDs.Split(',')[i]);
- list.Add(SOCTemplateID);
- }
- }
- SOCTemplateServices.SOCTemplateDelete(list);
- return this.Json("删除成功!");
- }
- catch (Exception ex)
- {
- return this.Json("删除失败,原因:" + ex.Message);
- }
- }
- 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 facultymajorID = Request.Form["FacultymajorComboGrid"].ParseStrTo<Guid>();
- var departmentID = Request.Form["DepartmentComboGrid"].ParseStrTo<Guid>();
- 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"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? "" : Request.Form["DictionaryLearnSystem"].ParseStrTo<int>().ToString();
- 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 SOCTemplateIDString = Request.Form["SelectedID"];
- var SOCTemplateIDList = SOCTemplateIDString.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => (Guid?)new Guid(x)).ToList();
- var dt = SOCTemplateServices.GetSOCTemplateViewList(configuretView, standardID, facultymajorID, departmentID, educationID, learningformID, LearnSystem, coursematerialID, schoolyearNumID, schoolcodeID, isEnable, SOCTemplateIDList)
- .Select(x => new
- {
- x.StandardCode,
- x.StandardName,
- x.FacultymajorName,
- x.EducationName,
- x.LearningformName,
- x.LearnSystem,
- x.CourseCode,
- x.CourseName,
- x.Credit,
- x.SchoolyearNumName,
- x.SchoolcodeName,
- x.DepartmentName,
- x.RecordStatusStr,
- x.SOCCount
- }).ToTable();
- string[] liststring = {
- "专业代码", "专业名称", "院系专业", RSL.Get("EducationID"), "学习形式", "学制", "课程代码", "课程名称", "课程学分", "开课学年", "学期", "开课教研室", "是否可用", "SOC个数"
- };
- neh.Export(dt, liststring, "课程SOC设置信息" + DateTime.Now.ToString("yyyyMMdd"));
- return Json(new ReturnMessage()
- {
- IsSuccess = true,
- Message = "导出成功。"
- });
- }
- }
- }
|