using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using Bowin.Common.Data; using Bowin.Common.Exceptions; using Bowin.Common.Utility; using Bowin.Web.Controls.Mvc; using EMIS.Web.Controls; using EMIS.Utility; using EMIS.ViewModel; using EMIS.ViewModel.EvaluationManage.EvaluationResult; using EMIS.CommonLogic.EvaluationManage.EvaluationResult; namespace EMIS.Web.Controllers.EvaluationManage.EvaluationResult { [Authorization] public class EvaluationStaffScoreController : Controller { public Lazy EvaluationStaffScoreServices { get; set; } /// /// 教师评分页面 /// /// public ActionResult List() { return View(); } /// /// 教师评分列表查询 /// /// /// [HttpPost] public ActionResult List(QueryParamsModel pararms) { ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms); var schoolyearID = pararms.getExtraGuid("SchoolyearDropdown"); var campusID = pararms.getExtraGuid("CampusDropdown"); var collegeID = pararms.getExtraGuid("CollegeDropdown"); var departmentID = pararms.getExtraGuid("DepartmentDropdown"); var userID = pararms.getExtraGuid("StaffComboGrid"); var incumbencyState = pararms.getExtraInt("DictionaryIncumbencyState") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryIncumbencyState"); var coursematerialID = pararms.getExtraGuid("CourseComboGrid"); return base.Json(EvaluationStaffScoreServices.Value.GetEvaluationStaffScoreViewGrid(configuretView, schoolyearID, campusID, collegeID, departmentID, userID, incumbencyState, coursematerialID, (int)pararms.page, (int)pararms.rows)); } /// /// 评分生成 /// /// public ActionResult Create() { return View(); } /// /// 评分生成 /// /// /// [HttpPost] public ActionResult Create(EvaluationStaffScoreView evaluationStaffScoreView) { try { ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null); var campusID = Request.Form["CampusDropdown"].ParseStrTo(); var collegeID = Request.Form["CollegeDropdown"].ParseStrTo(); var departmentID = Request.Form["DepartmentDropdown"].ParseStrTo(); var coursematerialID = Request.Form["CourseComboGrid"].ParseStrTo(); var userID = Request.Form["StaffComboGrid"].ParseStrTo(); string result = EvaluationStaffScoreServices.Value.EvaluationStaffScoreCreate(campusID, collegeID, departmentID, coursematerialID, userID, evaluationStaffScoreView.SchoolyearID); return Json(new ReturnMessage() { IsSuccess = true, Message = "生成成功" + result + "。" }); } catch (Exception ex) { return Json(new ReturnMessage() { IsSuccess = false, Message = "生成失败,原因:" + ex.Message }); } } /// /// 复制新增 /// /// /// public ActionResult CopyAdd(Guid evaluationStaffScoreID) { var evaluationStaffScoreView = new EvaluationStaffScoreView(); evaluationStaffScoreView = EvaluationStaffScoreServices.Value.GetEvaluationStaffScoreView(evaluationStaffScoreID); return View("Edit", evaluationStaffScoreView); } /// /// 复制新增 /// /// /// [HttpPost] public ActionResult CopyAdd(EvaluationStaffScoreView evaluationStaffScoreView) { evaluationStaffScoreView.EvaluationStaffScoreID = Guid.Empty; return this.Edit(evaluationStaffScoreView); } /// /// 编辑(新增、修改) /// /// /// [HttpGet] public ActionResult Edit(Guid? evaluationStaffScoreID) { var evaluationStaffScoreView = new EvaluationStaffScoreView(); if (evaluationStaffScoreID.HasValue && evaluationStaffScoreID != Guid.Empty) { evaluationStaffScoreView = EvaluationStaffScoreServices.Value.GetEvaluationStaffScoreView(evaluationStaffScoreID); } return View(evaluationStaffScoreView); } /// /// 编辑(新增、修改) /// /// /// [HttpPost] public ActionResult Edit(EvaluationStaffScoreView evaluationStaffScoreView) { try { EvaluationStaffScoreServices.Value.EvaluationStaffScoreEdit(evaluationStaffScoreView); return Json(new ReturnMessage() { IsSuccess = true, Message = "保存成功。" }); } catch (Exception ex) { return Json(new ReturnMessage() { IsSuccess = false, Message = "保存失败,原因:" + ex.Message }); } } /// /// 删除 /// /// /// [HttpPost] public ActionResult Delete(string evaluationStaffScoreIDs) { try { List list = evaluationStaffScoreIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => (Guid?)new Guid(x)).ToList(); EvaluationStaffScoreServices.Value.EvaluationStaffScoreDelete(list); return base.Json(new ReturnMessage { IsSuccess = true, Message = "删除成功。" }); } catch (Exception ex) { return base.Json(new ReturnMessage() { IsSuccess = false, Message = "删除失败,原因:" + ex.Message }); } } /// /// Excel导出 /// /// [HttpPost] public ActionResult Excel() { NpoiExcelHelper neh = new NpoiExcelHelper(); ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null); var schoolyearID = Request.Form["SchoolyearDropdown"] == DropdownList.SELECT_ALL.ToString() ? null : Request.Form["SchoolyearDropdown"].ParseStrTo(); var campusID = Request.Form["CampusDropdown"].ParseStrTo(); var collegeID = Request.Form["CollegeDropdown"].ParseStrTo(); var departmentID = Request.Form["DepartmentDropdown"].ParseStrTo(); var userID = Request.Form["StaffComboGrid"].ParseStrTo(); var incumbencyState = Request.Form["DictionaryIncumbencyState"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryIncumbencyState"].ParseStrTo(); var coursematerialID = Request.Form["CourseComboGrid"].ParseStrTo(); var dt = EvaluationStaffScoreServices.Value.GetEvaluationStaffScoreViewList(configuretView, schoolyearID, campusID, collegeID, departmentID, userID, incumbencyState, coursematerialID) .Select(x => new { x.SchoolyearCode, x.StaffCode, x.StaffName, x.SexName, x.TeacherTypeName, x.IncumbencyStateName, x.TitleName, x.CourseCode, x.CourseName, x.DepartmentNo, x.DepartmentName, x.CollegeNo, x.CollegeName, x.CampusNo, x.CampusName, x.StudentScore, x.CollegeScore, x.TotalScore, x.Remark, ModifyTime = x.ModifyTime == null ? null : x.ModifyTime.Value.ToString("yyyy-MM-dd HH:mm:ss") }).ToTable(); string[] liststring = { "学年学期", "教师工号", "任课教师", "性别", "教师类型", "在职状态", "职称", "课程代码", "课程名称", "所属教研室代码", "所属教研室", RSL.Get("CollegeCode"), RSL.Get("College"), RSL.Get("CampusCode"), RSL.Get("CampusName"), RSL.Get("EvaluationStudentScore"), RSL.Get("EvaluationCollegeScore"), "总评分", "备注", "修改时间" }; neh.Export(dt, liststring, "教师评分信息" + DateTime.Now.ToString("yyyyMMdd")); return Json(new ReturnMessage() { IsSuccess = true, Message = "导出成功。" }); } } }