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 EvaluationTargetController : Controller { public Lazy EvaluationTargetServices { 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 evaluationTableID = pararms.getExtraGuid("EvaluationTableDropdown"); var evaluationNormID = pararms.getExtraGuid("EvaluationNormDropdown"); return base.Json(EvaluationTargetServices.Value.GetEvaluationTargetViewGrid(configuretView, evaluationParticipateTypeID, evaluationTypeID, evaluationTableID, evaluationNormID, (int)pararms.page, (int)pararms.rows)); } /// /// 复制新增 /// /// /// public ActionResult CopyAdd(Guid evaluationTargetID) { EvaluationTargetView evaluationTargetView = new EvaluationTargetView(); evaluationTargetView = EvaluationTargetServices.Value.GetEvaluationTargetView(evaluationTargetID); return View("Edit", evaluationTargetView); } /// /// 复制新增 /// /// /// [HttpPost] public ActionResult CopyAdd(EvaluationTargetView evaluationTargetView) { evaluationTargetView.EvaluationTargetID = Guid.Empty; return this.Edit(evaluationTargetView); } /// /// 编辑(新增、修改) /// /// /// [HttpGet] public ActionResult Edit(Guid? evaluationTargetID) { EvaluationTargetView evaluationTargetView = new EvaluationTargetView(); if (evaluationTargetID.HasValue && evaluationTargetID != Guid.Empty) { evaluationTargetView = EvaluationTargetServices.Value.GetEvaluationTargetView(evaluationTargetID); } return View(evaluationTargetView); } /// /// 编辑(新增、修改) /// /// /// [HttpPost] public ActionResult Edit(EvaluationTargetView evaluationTargetView) { try { EvaluationTargetServices.Value.EvaluationTargetEdit(evaluationTargetView); return Json(new ReturnMessage() { IsSuccess = true, Message = "保存成功。" }); } catch (Exception ex) { return Json(new ReturnMessage() { IsSuccess = false, Message = "保存失败,原因:" + ex.Message }); } } /// /// 删除 /// /// /// [HttpPost] public ActionResult Delete(string evaluationTargetIDs) { try { List list = evaluationTargetIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => (Guid?)new Guid(x)).ToList(); EvaluationTargetServices.Value.EvaluationTargetDelete(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 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 evaluationTableID = Request.Form["EvaluationTableDropdown"].ParseStrTo(); var evaluationNormID = Request.Form["EvaluationNormDropdown"].ParseStrTo(); var dt = EvaluationTargetServices.Value.GetEvaluationTargetViewList(configuretView, evaluationParticipateTypeID, evaluationTypeID, evaluationTableID, evaluationNormID) .Select(x => new { x.OrderNo, x.Code, x.Name, x.EvaluationTableCode, x.EvaluationTableName, x.ParticipateTypeCode, x.ParticipateTypeName, x.IsStudentName, x.EvaluationTypeCode, x.EvaluationTypeName, x.TeachingModeIDListName, x.EvaluationNormName, x.NormTypeName, x.Weight, x.ProjectCount, 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 = "导出成功。" }); } } }