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(); return Json(SOCTemplateServices.GetSOCTemplateDetailViewGrid(templateID, (int)pararms.page, (int)pararms.rows)); } //[HttpPost] //public ActionResult GetNewGuidForSOCTemplateItemID(int count) //{ // var SOCTemplateItemID = Guid.NewGuid(); // return Json(SOCTemplateItemID); //} /// /// 复制新增 /// /// /// public ActionResult CopyAdd(Guid? templateID) { SOCTemplateView SOCTemplateView = new SOCTemplateView(); SOCTemplateView = SOCTemplateServices.GetSOCTemplateViewByID(templateID); return View("Edit", SOCTemplateView); } /// /// 复制新增 /// /// /// [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 filelist = new List(); //for (int i = 0; i < count; i++) //{ // var file = Session[i]; // if (file.GetType() == typeof(List)) // { // filelist = (List)file; // } //} var TDList = DataGrid.GetTableData("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)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(); var sessionName = FileUploadHelper.GetFileUploadSessionName(templateID ?? Guid.Empty); var fileList = (List)Session[sessionName]; //var count = Session.Count; //List filelist = new List(); //for (int i = 0; i < count; i++) //{ // var file = Session[i]; // if (file.GetType() == typeof(List)) // { // filelist = (List)file; // } //} //ViewBag.FileList = filelist; //foreach (var file in filelist) //{ //} return Json(fileList); } /// /// 生成 /// /// [HttpGet] public ActionResult Generate() { return View(); } /// /// 生成 /// /// /// [HttpPost] public ActionResult Generate(QueryParamsModel pararms) { try { var collegeID = Request.Form["CollegeDropdown"].ParseStrTo(); var standardID = Request.Form["StandardDictionaryDropDown"].ParseStrTo(); var facultymajorID = Request.Form["FacultymajorDropDown"].ParseStrTo(); var coursematerialID = Request.Form["CoursematerialDropDown"].ParseStrTo(); 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 list = new List(); 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() == DropdownList.SELECT_ALL ? null : Request.Form["StandardDictionaryDropDown"].ParseStrTo(); var facultymajorID = Request.Form["FacultymajorComboGrid"].ParseStrTo(); var departmentID = Request.Form["DepartmentComboGrid"].ParseStrTo(); var educationID = Request.Form["DictionaryEducation"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryEducation"].ParseStrTo(); var learningformID = Request.Form["DictionaryLearningform"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryLearningform"].ParseStrTo(); var LearnSystem = Request.Form["DictionaryLearnSystem"].ParseStrTo() == DropdownList.SELECT_ALL ? "" : Request.Form["DictionaryLearnSystem"].ParseStrTo().ToString(); var coursematerialID = Request.Form["CoursematerialIDDropdownGridBo"].ParseStrTo(); var schoolyearNumID = Request.Form["DictionarySchoolYearNum"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["DictionarySchoolYearNum"].ParseStrTo(); var schoolcodeID = Request.Form["DictionarySchoolcode"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["DictionarySchoolcode"].ParseStrTo(); var isEnable = Request.Form["DictionaryIsEnable"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryIsEnable"].ParseStrTo(); 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 = "导出成功。" }); } } }