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.EvaluationTable; using EMIS.CommonLogic.EvaluationManage.EvaluationTable; namespace EMIS.Web.Controllers.EvaluationManage.EvaluationTable { [Authorization] public class EvaluationTableController : Controller { public Lazy EvaluationTableServices { get; set; } /// /// 评价表名页面 /// /// public ActionResult List() { return View(); } /// /// 评价表名列表查询 /// /// /// [HttpPost] public ActionResult List(QueryParamsModel pararms) { ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms); var evaluationParticipateTypeID = pararms.getExtraGuid("EvaluationParticipateTypeDropdown"); var evaluationTypeID = pararms.getExtraGuid("EvaluationTypeDropdown"); var isStudent = pararms.getExtraInt("IsStudentDropdown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("IsStudentDropdown"); var isEnabled = pararms.getExtraInt("IsEnabledDropdown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("IsEnabledDropdown"); return base.Json(EvaluationTableServices.Value.GetEvaluationTableViewGrid(configuretView, evaluationParticipateTypeID, evaluationTypeID, isStudent, isEnabled, (int)pararms.page, (int)pararms.rows)); } /// /// 评价表名列表查询(启用状态为是或已使用) /// /// /// [HttpPost] public ActionResult GetEvaluationTableEnabledAndUseList(QueryParamsModel pararms) { ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms); var evaluationTableID = Request["evaluationTableID"].ParseStrTo(); var evaluationParticipateTypeID = pararms.getExtraGuid("EvaluationParticipateTypeDropdown"); var evaluationTypeID = pararms.getExtraGuid("EvaluationTypeDropdown"); return base.Json(EvaluationTableServices.Value.GetEnabledAndUseEvaluationTableViewGrid(configuretView, evaluationTableID, evaluationParticipateTypeID, evaluationTypeID, (int)pararms.page, (int)pararms.rows)); } /// /// 复制新增 /// /// /// public ActionResult CopyAdd(Guid evaluationTableID) { var evaluationTableView = new EvaluationTableView(); evaluationTableView = EvaluationTableServices.Value.GetEvaluationTableView(evaluationTableID); return View("Edit", evaluationTableView); } /// /// 复制新增 /// /// /// [HttpPost] public ActionResult CopyAdd(EvaluationTableView evaluationTableView) { evaluationTableView.EvaluationTableID = Guid.Empty; return this.Edit(evaluationTableView); } /// /// 编辑(新增、修改) /// /// /// [HttpGet] public ActionResult Edit(Guid? evaluationTableID) { var evaluationTableView = new EvaluationTableView(); if (evaluationTableID.HasValue && evaluationTableID != Guid.Empty) { evaluationTableView = EvaluationTableServices.Value.GetEvaluationTableView(evaluationTableID); } else { evaluationTableView.IsEnabled = true; } return View(evaluationTableView); } /// /// 编辑(新增、修改) /// /// /// [HttpPost] public ActionResult Edit(EvaluationTableView evaluationTableView) { try { EvaluationTableServices.Value.EvaluationTableEdit(evaluationTableView); return Json(new ReturnMessage() { IsSuccess = true, Message = "保存成功。" }); } catch (Exception ex) { return Json(new ReturnMessage() { IsSuccess = false, Message = "保存失败,原因:" + ex.Message }); } } /// /// 删除 /// /// /// [HttpPost] public ActionResult Delete(string evaluationTableIDs) { try { List list = evaluationTableIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => (Guid?)new Guid(x)).ToList(); EvaluationTableServices.Value.EvaluationTableDelete(list); return base.Json(new ReturnMessage { IsSuccess = true, Message = "删除成功。" }); } catch (Exception ex) { string mge = ex.Message; System.Data.SqlClient.SqlException num = ExceptionHelper.GetSqlException(ex); if (num != null) { if (num.Number == 547) { mge = "请先删除所有关联的数据,如:评价设定、评价项目、评价指标等。"; } } return base.Json(new ReturnMessage { IsSuccess = false, Message = "删除失败,原因:" + mge }); } } /// /// 评价表对应的评价指标 /// /// public ActionResult TargetList() { return View(); } /// /// 评价表对应的评价指标 /// /// /// [HttpPost] public ActionResult TargetList(QueryParamsModel pararms) { ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms); var collegeID = Request["collegeID"].ParseStrTo(); return null; //return Json(CollegeServices.GetDepartmentListViewGrid(configuretView, collegeID, (int)pararms.page, (int)pararms.rows)); } /// /// 评价表对应的评价指标信息Excel导出 /// /// [HttpPost] public ActionResult TargetListExcel() { return null; } /// /// 评价表对应的评价项目 /// /// public ActionResult ProjectList() { return View(); } /// /// 评价表对应的评价项目 /// /// /// [HttpPost] public ActionResult ProjectList(QueryParamsModel pararms) { ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms); var collegeID = Request["collegeID"].ParseStrTo(); var departmentID = pararms.getExtraGuid("DepartmentDropdown"); var isPhotoUrl = pararms.getExtraInt("IsPhotoUrlDropdown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("IsPhotoUrlDropdown"); var teacherTypeID = pararms.getExtraInt("DictionaryTeacherType") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryTeacherType"); var incumbencyState = pararms.getExtraInt("DictionaryIncumbencyState") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryIncumbencyState"); var titleID = pararms.getExtraInt("DictionaryTitle") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryTitle"); var isDualTeacher = pararms.getExtraInt("IsDualTeacherDropdown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("IsDualTeacherDropdown"); return null; //return base.Json(CollegeServices.GetStaffListViewGrid(configuretView, collegeID, departmentID, isPhotoUrl, teacherTypeID, incumbencyState, titleID, isDualTeacher, (int)pararms.page, (int)pararms.rows)); } /// /// 评价表对应的评价项目信息Excel导出 /// /// [HttpPost] public ActionResult ProjectListExcel() { return null; } /// /// Excel导出 /// /// [HttpPost] public ActionResult Excel() { NpoiExcelHelper neh = new NpoiExcelHelper(); ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null); var evaluationParticipateTypeID = Request.Form["EvaluationParticipateTypeDropdown"].ParseStrTo(); var evaluationTypeID = Request.Form["EvaluationTypeDropdown"].ParseStrTo(); var isStudent = Request.Form["IsStudentDropdown"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["IsStudentDropdown"].ParseStrTo(); var isEnabled = Request.Form["IsEnabledDropdown"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["IsEnabledDropdown"].ParseStrTo(); var dt = EvaluationTableServices.Value.GetEvaluationTableViewList(configuretView, evaluationParticipateTypeID, evaluationTypeID, isStudent, isEnabled) .Select(x => new { x.Code, x.Name, x.ParticipateTypeCode, x.ParticipateTypeName, x.IsStudentName, x.EvaluationTypeCode, x.EvaluationTypeName, x.TeachingModeIDListName, x.Weight, x.TargetCount, x.ProjectCount, x.IsEnabledName, x.Remark, x.CreateUserName, x.ModifyUserName, ModifyTime = x.ModifyTime == null ? null : x.ModifyTime.Value.ToString("yyyy-MM-dd HH:mm:ss") }).ToTable(); string[] liststring = { "编号", "评价表名", "参评代码", "参评类型", "学生用", "评价类型编号", "评价类型", "授课方式", "权重", "指标个数", "项目个数", "是否启用", "备注", "创建人", "修改人", "修改时间" }; neh.Export(dt, liststring, "评价表名信息" + DateTime.Now.ToString("yyyyMMdd")); return Json(new ReturnMessage() { IsSuccess = true, Message = "导出成功。" }); } } }