using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using Bowin.Common.Data; using Bowin.Common.Utility; using EMIS.ViewModel; using EMIS.Web.Controls; using EMIS.CommonLogic.SupervisionManage; using EMIS.ViewModel.SupervisionManage; using EMIS.Utility.FormValidate; using EMIS.Utility; namespace EMIS.Web.Controllers.SupervisionManage { [Authorization] public class LessonRecordController : Controller { public ILessonRecordServices LessonRecordServices { get; set; } public ISupervisionCollegeServices SupervisionCollegeServices { get; set; } public ActionResult List() { return View(); } public ActionResult Edit(Guid? lessonRecordID, int? isShow) { var lessonRecordView = new LessonRecordView(); if (lessonRecordID.HasValue) { lessonRecordView = LessonRecordServices.GetLessonRecordView(lessonRecordID.Value); } else { var curUser = CustomPrincipal.Current; var supervisionCollege = SupervisionCollegeServices.GetSupervisionCollegeViewByCollegeID(curUser.CollegeID ?? Guid.Empty); lessonRecordView.CreateUserID = curUser.UserID; lessonRecordView.CreateUserName = curUser.Name; if (supervisionCollege != null) { lessonRecordView.SupervisionCollegeID = supervisionCollege.SupervisionCollegeID; } } return View(lessonRecordView); } [HttpPost] public ActionResult Edit(LessonRecordView lessonRecordView) { var sessionName = FileUploadHelper.GetFileUploadSessionName(lessonRecordView.LessonRecordID); var fileList = (List)Session[sessionName]; try { LessonRecordServices.Save(lessonRecordView, fileList); return Json(new ReturnMessage() { IsSuccess = true, Message = "保存成功。" }); } catch (Exception ex) { return Json(new ReturnMessage() { IsSuccess = false, Message = "保存失败:" + ex.Message }); } } [HttpPost] public ActionResult List(QueryParamsModel pararms) { ConfiguretView conditionView = ConfiguretExtensions.GetConfiguretermsView(pararms); var schoolyearID = pararms.getExtraGuid("Schoolyear"); var collegeID = pararms.getExtraGuid("College"); var supervisionCollegeID = pararms.getExtraGuid("SupervisionCollege"); var startDate = pararms.getExtraDateTime("StartDate"); var endDate = pararms.getExtraDateTime("EndDate"); return base.Json(LessonRecordServices.GetLessonRecordViewGrid(conditionView, schoolyearID, collegeID, supervisionCollegeID, startDate, endDate, pararms.page, pararms.rows)); } [HttpPost] public ActionResult Delete(string lessonRecordIDs) { try { var lessonRecordIDList = lessonRecordIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => (Guid?)new Guid(x)).ToList(); LessonRecordServices.Delete(lessonRecordIDList); return base.Json(new ReturnMessage { IsSuccess = true, Message = "删除成功" }); } catch (Exception ex) { return base.Json(new ReturnMessage { IsSuccess = false, Message = "删除失败,原因:" + ex.Message }); } } [HttpPost] public ActionResult Excel() { NpoiExcelHelper neh = new NpoiExcelHelper(); ConfiguretView conditionView = ConfiguretExtensions.GetConfiguretermsView(null); var selectedID = Request.Form["LessonRecordIDs"] ?? ""; var schoolyearID = Request.Form["Schoolyear"].ParseStrTo(); var collegeID = Request.Form["College"].ParseStrTo(); var supervisionCollegeID = Request.Form["SupervisionCollege"].ParseStrTo(); var startDate = Request.Form["StartDate"].ParseStrTo(); var endDate = Request.Form["EndDate"].ParseStrTo(); List result; if (!string.IsNullOrEmpty(selectedID)) { var adjustmentIDList = selectedID.Split(',') .Where(x => !string.IsNullOrEmpty(x)).Select(x => new Guid(x)).ToList(); result = LessonRecordServices.GetLessonRecordViewList(conditionView, schoolyearID, collegeID, supervisionCollegeID, startDate, endDate); } else { result = LessonRecordServices.GetLessonRecordViewList(conditionView, schoolyearID, collegeID, supervisionCollegeID, startDate, endDate); } var dt = result.Select(x => new { x.SchoolyearCode, x.SupervisionTypeDesc, x.LessonDateDesc, x.SupervisionCollegeName, x.Location, x.UserName, x.ClassmajorName, x.CourseName, TotalScore = (x.TotalScore ?? 0).ToString("#0.##") }).ToTable(); string[] liststring = { "学年学期", "督导类型", "督导时间", "督导院系", "督导地点", "督导对象","授课班级", "课程名称", "评分" }; neh.Export(dt, liststring, "督导听课记录"); return Json(new ReturnMessage() { IsSuccess = true, Message = "保存成功!" }); } } }