123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.Mvc;
- using Bowin.Web.Controls.Mvc;
- using Bowin.Common.Utility;
- using Bowin.Common.Data;
- using Bowin.Common.Exceptions;
- using EMIS.Web.Controls;
- using EMIS.ViewModel;
- using EMIS.ViewModel.StudentManage.StudentChange;
- using EMIS.CommonLogic.StudentManage.StudentChange;
- namespace EMIS.Web.Controllers.StudentManage.StudentChange
- {
- [Authorization]
- public class ChangeReportController : Controller
- {
- public IChangeReportServices ChangeReportServices { 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);
- return base.Json(ChangeReportServices.GetChangeReportViewGrid(configuretView, (int)pararms.page, (int)pararms.rows));
- }
- /// <summary>
- /// 复制新增
- /// </summary>
- /// <param name="changeReportID"></param>
- /// <returns></returns>
- public ActionResult CopyAdd(Guid changeReportID)
- {
- var changeReportView = new ChangeReportView();
- changeReportView = ChangeReportServices.GetChangeReportView(changeReportID);
- return View("Edit", changeReportView);
- }
- /// <summary>
- /// 复制新增
- /// </summary>
- /// <param name="changeReportView"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult CopyAdd(ChangeReportView changeReportView)
- {
- changeReportView.ChangeReportID = Guid.Empty;
- return this.Edit(changeReportView);
- }
- /// <summary>
- /// 编辑(新增、修改)
- /// </summary>
- /// <param name="changeReportID"></param>
- /// <returns></returns>
- [HttpGet]
- public ActionResult Edit(Guid? changeReportID)
- {
- var changeReportView = new ChangeReportView();
- if (changeReportID.HasValue && changeReportID != Guid.Empty)
- {
- changeReportView = ChangeReportServices.GetChangeReportView(changeReportID);
- }
- return View(changeReportView);
- }
- /// <summary>
- /// 编辑(新增、修改)
- /// </summary>
- /// <param name="changeReportView"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult Edit(ChangeReportView changeReportView)
- {
- try
- {
- ChangeReportServices.ChangeReportEdit(changeReportView);
- return Json(new ReturnMessage()
- {
- IsSuccess = true,
- Message = "保存成功。"
- });
- }
- catch (Exception ex)
- {
- return Json(new ReturnMessage()
- {
- IsSuccess = false,
- Message = "保存失败,原因:" + ex.Message
- });
- }
- }
- /// <summary>
- /// 删除
- /// </summary>
- /// <param name="changeReportIDs"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult Delete(string changeReportIDs)
- {
- try
- {
- List<Guid?> list = changeReportIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => (Guid?)new Guid(x)).ToList();
- ChangeReportServices.ChangeReportDelete(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 dt = ChangeReportServices.GetChangeReportViewList(configuretView)
- .Select(x => new
- {
- x.Code,
- x.Name,
- x.Url
- }).ToTable();
- string[] liststring = {
- "报表代码", "报表名称", "报表Url"
- };
- neh.Export(dt, liststring, "异动报表信息" + DateTime.Now.ToString("yyyyMMdd"));
- return Json(new ReturnMessage()
- {
- IsSuccess = true,
- Message = "导出成功。"
- });
- }
- }
- }
|