using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using EMIS.ViewModel; using EMIS.Web.Controls; using EMIS.CommonLogic.DQPSystem; using Bowin.Common.Utility; using EMIS.ViewModel.DQPSystem; using EMIS.ViewModel.Students; using Bowin.Web.Controls.Mvc; using EMIS.ViewModel.SystemView; using Bowin.Common.Data; namespace EMIS.Web.Controllers.DQPSystem { [Authorization] public class SOCDetailGroupController : Controller { // // GET: /SOCDetailGroup/ public ISOCDetailGroupServices SOCDetailGroupServices { get; set; } public ISOCDetailScoreServices SOCDetialScoreServices { 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 result = SOCDetailGroupServices.GetSOCDetailViewGrid(configuretView, schoolyearID, null, null, null, coursematerialID, (int)pararms.page, (int)pararms.rows); return Json(result); } [HttpGet] public ActionResult Detail(Guid? SOCDetailID) { ViewBag.SOCDetailID = SOCDetailID; return View(); } [HttpPost] public ActionResult Detail() { var SOCID = Request["SOCID"].ParseStrTo(); return Json(""); } [HttpGet] public ActionResult Group(Guid? SOCDetailID) { ViewBag.SOCDetailID = SOCDetailID; return View(); } [HttpPost] public ActionResult Group(QueryParamsModel pararms) { ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms); var SOCDetailID = Request["SOCDetailID"].ParseStrTo(); var result = SOCDetailGroupServices.GetSOCDetailGroupViewGrid(configuretView, SOCDetailID, (int)pararms.page, (int)pararms.rows); return Json(result); } [HttpGet] public ActionResult AddGroup(Guid? SOCDetailID) { var groupSOCDetail = SOCDetailGroupServices.GetGroupSOCDetailViewGrid(SOCDetailID); return View(groupSOCDetail); } [HttpPost] public ActionResult AddGroup(GroupSOCDetailView groupSOCDetailView) { try { SOCDetailGroupServices.GroupSOCDetailSave(groupSOCDetailView); return base.Json( new ReturnMessage { IsSuccess = true, Message = "添加成功" }); } catch (Exception ex) { return base.Json( new ReturnMessage { IsSuccess = false, Message = "添加失败,原因:" + ex.Message + "!" }); } } /// /// 修改学生 /// /// /// public ActionResult StudentEdit(Guid? SOCDetailGroupID) { SOCDetailGroupView SOCDetailGroupView = new SOCDetailGroupView(); if (SOCDetailGroupID.HasValue) { SOCDetailGroupView = SOCDetailGroupServices.GetSOCDetailGroupView(SOCDetailGroupID); } else { SOCDetailGroupView.SOCDetailGroupID = Guid.NewGuid(); } return View(SOCDetailGroupView); } /// /// 修改学生 /// /// /// [HttpPost] public ActionResult StudentEdit(SOCDetailGroupView SOCDetailGroupView) { try { var studentList = DataGrid.GetTableData("dgStudentList"); SOCDetailGroupServices.SOCDetailGroupStudentAdd(SOCDetailGroupView.SOCDetailGroupID, studentList); return Json(new ReturnMessage() { IsSuccess = true, Message = "保存成功。" }); } catch (Exception ex) { return Json(new ReturnMessage() { IsSuccess = false, Message = "保存失败:" + ex.Message }); } } /// /// 添加学生 /// /// /// public ActionResult StudentAdd(Guid? SOCDetailGroupID) { ViewBag.SOCDetailGroupID = SOCDetailGroupID; return View(); } ///// ///// 添加学生 ///// ///// ///// //[HttpPost] //public ActionResult StudentAdd(FinalExaminationView finalExaminationView) //{ // try // { // finalExaminationServices.Value.StudentAdd(finalExaminationView); // return Json(new ReturnMessage() // { // IsSuccess = true, // Message = "保存成功。" // }); // } // catch (Exception ex) // { // return Json(new ReturnMessage() // { // IsSuccess = false, // Message = "保存失败:" + ex.Message // }); // } //} /// /// 学生名单 /// /// /// [HttpPost] public ActionResult SOCDetailGroupStudentList() { var SOCDetailGroupID = Request["SOCDetailGroupID"].ParseStrTo(); return Json(SOCDetailGroupServices.GetSOCDetailGroupStudent(SOCDetailGroupID)); } [HttpPost] public ActionResult SOCDetailGroupStudentNotGroupList(QueryParamsModel pararms) { ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms); var SOCDetailGroupID = Request["SOCDetailGroupID"].ParseStrTo(); return Json(SOCDetailGroupServices.GetNotGroupStudent(configuretView, SOCDetailGroupID)); } public ActionResult SOCDetailGroupDelete(string SOCDetailGroupIDs) { try { List list = new List(); for (int i = 0; i < SOCDetailGroupIDs.Split(',').Length; i++) { if (!string.IsNullOrEmpty(SOCDetailGroupIDs.Split(',')[i])) { Guid SOCDetailGroupID = new Guid(SOCDetailGroupIDs.Split(',')[i]); list.Add(SOCDetailGroupID); } } SOCDetailGroupServices.SOCDetailGroupDelete(list); return this.Json("删除成功!"); } catch (Exception ex) { return this.Json("删除失败,原因:" + ex.Message); } } [HttpGet] public ActionResult SendMessage(string socDetailGroupIDs) { var groupIDList = socDetailGroupIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => new Guid(x)).ToList(); var userIDList = SOCDetailGroupServices.GetUserIDByGroupID(groupIDList); var studentUserIDLists = ""; foreach (var userID in userIDList) { studentUserIDLists = studentUserIDLists + "," + userID.ToString(); } studentUserIDLists = studentUserIDLists.Substring(1); ViewBag.UserIDLists = studentUserIDLists; return View(); } public ActionResult SendMessage(AnnouncementView announcementView) { announcementView.Content = HttpContext.Server.HtmlDecode(announcementView.Content); var userIDs = Request.Form["idList"]; //var message = Request.Form["Message"]; var userIDList = userIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => new Guid(x)).ToList(); try { SOCDetialScoreServices.SendMessage(userIDList, announcementView); return Json(new ReturnMessage() { IsSuccess = true, Message = "发送成功。" }); } catch (Exception ex) { return Json(new ReturnMessage() { IsSuccess = false, Message = "发送失败:" + ex.Message }); } //return View(); } public ActionResult GroupExcel() { NpoiExcelHelper neh = new NpoiExcelHelper(); ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null); var SOCDetailID = Request["SOCDetailID"].ParseStrTo(); var dt = SOCDetailGroupServices.GetSOCDetailGroupViewList(configuretView, SOCDetailID) .Select(x => new { x.CourseName, x.Name, x.No, x.StudentName, }).ToTable(); string[] liststring = { "课程名称", "成果名称", "组别", "学生" }; neh.Export(dt, liststring, "学生分组信息"); return Json(new ReturnMessage() { IsSuccess = true, Message = "导出成功。" }); } } }