123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200 |
- 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 EvaluationProjectController : Controller
- {
- public Lazy<IEvaluationProjectServices> EvaluationProjectServices { get; set; }
- /// <summary>
- /// 评价项目页面
- /// </summary>
- /// <returns></returns>
- public ActionResult List()
- {
- return View();
- }
- /// <summary>
- /// 评价项目列表查询
- /// </summary>
- /// <param name="pararms"></param>
- /// <returns></returns>
- [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 evaluationTargetID = pararms.getExtraGuid("EvaluationTargetDropdown");
- return base.Json(EvaluationProjectServices.Value.GetEvaluationProjectViewGrid(configuretView, evaluationParticipateTypeID, evaluationTypeID, evaluationTableID, evaluationTargetID, (int)pararms.page, (int)pararms.rows));
- }
- /// <summary>
- /// 复制新增
- /// </summary>
- /// <param name="evaluationProjectID"></param>
- /// <returns></returns>
- public ActionResult CopyAdd(Guid evaluationProjectID)
- {
- EvaluationProjectView evaluationProjectView = new EvaluationProjectView();
- evaluationProjectView = EvaluationProjectServices.Value.GetEvaluationProjectView(evaluationProjectID);
- return View("Edit", evaluationProjectView);
- }
- /// <summary>
- /// 复制新增
- /// </summary>
- /// <param name="evaluationProjectView"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult CopyAdd(EvaluationProjectView evaluationProjectView)
- {
- evaluationProjectView.EvaluationProjectID = Guid.Empty;
- return this.Edit(evaluationProjectView);
- }
- /// <summary>
- /// 编辑(新增、修改)
- /// </summary>
- /// <param name="evaluationProjectID"></param>
- /// <returns></returns>
- [HttpGet]
- public ActionResult Edit(Guid? evaluationProjectID)
- {
- EvaluationProjectView evaluationProjectView = new EvaluationProjectView();
- if (evaluationProjectID.HasValue && evaluationProjectID != Guid.Empty)
- {
- evaluationProjectView = EvaluationProjectServices.Value.GetEvaluationProjectView(evaluationProjectID);
- }
- return View(evaluationProjectView);
- }
- /// <summary>
- /// 编辑(新增、修改)
- /// </summary>
- /// <param name="evaluationProjectView"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult Edit(EvaluationProjectView evaluationProjectView)
- {
- try
- {
- EvaluationProjectServices.Value.EvaluationProjectEdit(evaluationProjectView);
- return Json(new ReturnMessage()
- {
- IsSuccess = true,
- Message = "保存成功。"
- });
- }
- catch (Exception ex)
- {
- return Json(new ReturnMessage()
- {
- IsSuccess = false,
- Message = "保存失败,原因:" + ex.Message
- });
- }
- }
- /// <summary>
- /// 删除
- /// </summary>
- /// <param name="evaluationProjectIDs"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult Delete(string evaluationProjectIDs)
- {
- try
- {
- List<Guid?> list = evaluationProjectIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => (Guid?)new Guid(x)).ToList();
- EvaluationProjectServices.Value.EvaluationProjectDelete(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 });
- }
- }
- /// <summary>
- /// Excel导出
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- public ActionResult Excel()
- {
- NpoiExcelHelper neh = new NpoiExcelHelper();
- ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
- var evaluationParticipateTypeID = Request.Form["EvaluationParticipateTypeDropdown"].ParseStrTo<Guid>();
- var evaluationTypeID = Request.Form["EvaluationTypeDropdown"].ParseStrTo<Guid>();
- var evaluationTableID = Request.Form["EvaluationTableDropdown"].ParseStrTo<Guid>();
- var evaluationTargetID = Request.Form["EvaluationTargetDropdown"].ParseStrTo<Guid>();
- var dt = EvaluationProjectServices.Value.GetEvaluationProjectViewList(configuretView, evaluationParticipateTypeID, evaluationTypeID, evaluationTableID, evaluationTargetID)
- .Select(x => new
- {
- x.OrderNo,
- x.Code,
- x.Name,
- x.EvaluationTargetOrderNo,
- x.EvaluationTargetCode,
- x.EvaluationTargetName,
- x.EvaluationTableCode,
- x.EvaluationTableName,
- x.ParticipateTypeCode,
- x.ParticipateTypeName,
- x.IsStudentName,
- x.EvaluationTypeCode,
- x.EvaluationTypeName,
- x.TeachingModeIDListName,
- x.EvaluationNormName,
- x.NormTypeName,
- x.Weight,
- 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 = "导出成功。"
- });
- }
- }
- }
|