123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154 |
- 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<FileUploadView>)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<Guid>();
- var collegeID = Request.Form["College"].ParseStrTo<Guid>();
- var supervisionCollegeID = Request.Form["SupervisionCollege"].ParseStrTo<Guid>();
- var startDate = Request.Form["StartDate"].ParseStrTo<DateTime>();
- var endDate = Request.Form["EndDate"].ParseStrTo<DateTime>();
- List<LessonRecordView> 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 = "保存成功!"
- });
- }
- }
- }
|