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 EMIS.ViewModel.DQPSystem; using Bowin.Common.Utility; using Bowin.Common.Data; using Bowin.Common.Exceptions; namespace EMIS.Web.Controllers.DQPSystem { [Authorization] public class SOCDetailController : Controller { // // GET: /SOCDetail/ public ISOCDetailServices SOCDetailServices { get; set; } public ActionResult List() { return View(); } [HttpPost] public ActionResult List(QueryParamsModel pararms) { ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms); var schoolyearID = pararms.getExtraGuid("SchoolyearDropdown"); var coursematerialID = pararms.getExtraGuid("CoursematerialIDDropdownGridBo"); var collegeID = pararms.getExtraGuid("CollegeComboGrid"); var staffID = pararms.getExtraGuid("StaffDropdown"); var result = SOCDetailServices.GetSOCDetailViewGrid(configuretView, schoolyearID, coursematerialID, collegeID, staffID, (int)pararms.page, (int)pararms.rows); return Json(result); } [HttpPost] public ActionResult Excel() { NpoiExcelHelper neh = new NpoiExcelHelper(); ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null); var schoolyearID = Request.Form["SchoolyearDropdown"].ParseStrTo(); var coursematerialID = Request.Form["CoursematerialIDDropdownGridBo"].ParseStrTo(); var collegeID = Request.Form["CollegeComboGrid"].ParseStrTo(); var staffID = Request.Form["StaffDropdown"].ParseStrTo(); var socDetailIDString = Request.Form["SelectedID"]; var socDetailIDList = socDetailIDString.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => (Guid?)new Guid(x)).ToList(); var dt = SOCDetailServices.GetSOCDetailViewList(configuretView, schoolyearID, coursematerialID, collegeID, staffID, socDetailIDList) .Select(x => new { x.SchoolyearCode, x.CourseCode, x.CourseName, x.StudentCount, x.Name, x.Credit, x.Weight, x.IsGroupStr, x.StartTimeStr, x.EndTimeStr }).ToTable(); string[] liststring = { "学年学期", "课程代码", "课程名称", "学生人数", "成果名称", "成果学分", "成果权重", "是否分组", "开始上传时间", "截止上传时间" }; neh.Export(dt, liststring, "课程SOC明细" + DateTime.Now.ToString("yyyyMMdd")); return Json(new ReturnMessage() { IsSuccess = true, Message = "导出成功。" }); } /// /// 编辑 /// /// /// [HttpGet] public ActionResult Edit(Guid? SOCDetailID) { SOCDetailView SOCDetailView = new SOCDetailView(); if (SOCDetailID.HasValue && SOCDetailID != Guid.Empty) { SOCDetailView = SOCDetailServices.GetSOCDetailView(SOCDetailID); } return View(SOCDetailView); } /// /// 编辑 /// /// /// [HttpPost] public ActionResult Edit(SOCDetailView SOCDetailView) { 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; } } SOCDetailServices.SOCDetailEdit(SOCDetailView, filelist); return Json(new ReturnMessage() { IsSuccess = true, Message = "保存成功。" }); } catch (Exception ex) { return Json(new ReturnMessage() { IsSuccess = false, Message = "保存失败,原因:" + ex.Message + "。" }); } } public ActionResult Delete(string SOCDetailIDs) { try { List list = new List(); for (int i = 0; i < SOCDetailIDs.Split(',').Length; i++) { if (!string.IsNullOrEmpty(SOCDetailIDs.Split(',')[i])) { Guid SOCDetailID = new Guid(SOCDetailIDs.Split(',')[i]); list.Add(SOCDetailID); } } SOCDetailServices.SOCDetailDelete(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 = "请先删除所有关联的数据(SOC分组、SOC学生成果、SOC学生成绩等)。"; } return base.Json("删除失败,原因:" + mge); } } [HttpGet] public ActionResult Upload(Guid? detailID) { SOCDetailView SOCDetailView = new SOCDetailView(); SOCDetailView.SOCDetailID = detailID.Value; return View(SOCDetailView); } [HttpPost] public ActionResult Upload(SOCDetailView SOCDetailView) { return Json("上传成功"); //try //{ // var count = Session.Count; // List filelist = new List(); // for (int i = 0; i < count; i++) // { // var file = Session[i]; // filelist = (List)file; // } // SOCDetailServices.SOCDetailAttachmentSave(SOCDetailView.SOCDetailID, filelist); // return this.Json("上传成功!"); //} //catch (Exception ex) //{ // return this.Json("上传成功,原因:" + ex.Message); //} } [HttpPost] public ActionResult GetAttachmentList(QueryParamsModel pararms) { ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms); var socDetailID = pararms.getExtraGuid("hidSOCDetailID"); return base.Json(SOCDetailServices.GetSOCDetailAttachmentViewList(configuretView, socDetailID, (int)pararms.page, (int)pararms.rows)); } } }