123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.Mvc;
- using EMIS.ViewModel;
- using EMIS.Web.Controls;
- using Bowin.Web.Controls.Mvc;
- using EMIS.CommonLogic.MinorGraduation.MinorGraduationSetting;
- using EMIS.ViewModel.MinorGraduation.MinorGraduationSetting;
- using Bowin.Common.Linq.Entity;
- using Bowin.Common.Utility;
- using Bowin.Common.Data;
- namespace EMIS.Web.Controllers.MinorGraduation.MinorGraduationSetting
- {
- [Authorization]
- public class MinorGraduationConditionPackageController : Controller
- {
- //
- // GET: /MinorGraduationConditionPackage/
- public IMinorGraduationConditionPackageServices minorGraduationConditionPackageServices { get; set; }
- public IMinorGraduationConditionServices minorGraduationConditionServices { 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 isDefault = pararms.getExtraInt("IsDefaultDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("IsDefaultDropDown");
- return base.Json(minorGraduationConditionPackageServices.GetMinorGraduationConditionPackageViewGrid(configuretView, isDefault, (int)pararms.page, (int)pararms.rows));
- }
- /// <summary>
- /// 复制新增
- /// </summary>
- /// <param name="GraduationConditionPackageID"></param>
- /// <returns></returns>
- public ActionResult CopyAdd(Guid minorGraduationConditionPackageID)
- {
- MinorGraduationConditionPackageView minorGraduationConditionPackageView = new MinorGraduationConditionPackageView();
- minorGraduationConditionPackageView = minorGraduationConditionPackageServices.GetMinorGraduationConditionPackageView(minorGraduationConditionPackageID);
- return View("Edit", minorGraduationConditionPackageView);
- }
- /// <summary>
- /// 复制新增
- /// </summary>
- /// <param name="graduationConditionPackageView"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult CopyAdd(MinorGraduationConditionPackageView minorGraduationConditionPackageView)
- {
- minorGraduationConditionPackageView.MinorGraduationConditionPackageID = Guid.Empty;
- return this.Edit(minorGraduationConditionPackageView);
- }
- /// <summary>
- /// 编辑(新增、修改)
- /// </summary>
- /// <param name="GraduationConditionPackageID"></param>
- /// <returns></returns>
- [HttpGet]
- public ActionResult Edit(Guid? minorGraduationConditionPackageID)
- {
- ViewBag.Type = Request.Params["Type"];
- MinorGraduationConditionPackageView minorGraduationConditionPackageView = new MinorGraduationConditionPackageView();
- if (minorGraduationConditionPackageID.HasValue && minorGraduationConditionPackageID != Guid.Empty)
- {
- minorGraduationConditionPackageView = minorGraduationConditionPackageServices.GetMinorGraduationConditionPackageView(minorGraduationConditionPackageID);
- }
- else
- {
- minorGraduationConditionPackageView.StudentTypeID = (int)CF_STUDENTTYPE.DefaultType;
- minorGraduationConditionPackageView.IsDefault = true;
- }
- return View(minorGraduationConditionPackageView);
- }
- /// <summary>
- /// 编辑(新增、修改)
- /// 注:判断是否默认状态(同一种学生类别,只有一种默认公式)
- /// 暂时不考虑当公式被引用时,不可修改公式中条件的情况
- /// </summary>
- /// <param name="graduationConditionPackageView"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult Edit(MinorGraduationConditionPackageView minorGraduationConditionPackageView)
- {
- try
- {
- var minorGraduationConditionViewList = DataGrid.GetTableData<MinorGraduationConditionView>("dgMinorGraduationConditionList");
- minorGraduationConditionPackageServices.MinorGraduationConditionPackageEdit(minorGraduationConditionPackageView, minorGraduationConditionViewList);
- return Json(new ReturnMessage()
- {
- IsSuccess = true,
- Message = "保存成功。"
- });
- }
- catch (Exception ex)
- {
- return Json(new ReturnMessage()
- {
- IsSuccess = false,
- Message = "保存失败,原因:" + ex.Message + "。"
- });
- }
- }
- /// <summary>
- /// 删除(当对应的毕业公式被引用时,不可删除--毕业公式、对应的毕业条件)
- /// </summary>
- /// <param name="graduationConditionPackageIDs"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult Delete(string minorGraduationConditionPackageIDs)
- {
- try
- {
- List<Guid?> list = minorGraduationConditionPackageIDs.Split(',').Where(x => !string.IsNullOrEmpty(x))
- .Select(x => (Guid?)new Guid(x)).ToList();
- minorGraduationConditionPackageServices.MinorGraduationConditionPackageDelete(list);
- return base.Json("删除成功。");
- }
- catch (Exception ex)
- {
- return base.Json("删除失败,原因:" + ex.Message);
- }
- }
- /// <summary>
- /// 毕业条件列表(根据对应的毕业公式ID查询)
- /// </summary>
- /// <param name="GraduationConditionPackageID"></param>
- /// <returns></returns>
- public ActionResult MinorGraduationConditionViewList(Guid? minorGraduationConditionPackageID)
- {
- var minorGraduationConditionPackageList = new List<MinorGraduationConditionView>();
- if (minorGraduationConditionPackageID.HasValue)
- {
- minorGraduationConditionPackageList = minorGraduationConditionPackageServices
- .GetMinorGraduationConditionViewList(minorGraduationConditionPackageID);
- }
- return Json(new GridResultSet<MinorGraduationConditionView>()
- {
- rows = minorGraduationConditionPackageList,
- total = minorGraduationConditionPackageList.Count
- });
- }
- /// <summary>
- /// 毕业条件添加页面
- /// </summary>
- /// <returns></returns>
- public ActionResult MinorGraduationConditionList()
- {
- return View();
- }
- /// <summary>
- /// 毕业条件添加页面查询列表
- /// </summary>
- /// <param name="pararms"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult MinorGraduationConditionList(QueryParamsModel pararms)
- {
- ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
- //启用状态(默认为启用)
- var isCurrent = (int)CF_GeneralPurpose.IsYes;
- return base.Json(minorGraduationConditionServices.GetMinorGraduationConditionViewGrid(configuretView, isCurrent, (int)pararms.page, (int)pararms.rows));
- }
- /// <summary>
- /// Excel导出
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- public ActionResult Excel()
- {
- NpoiExcelHelper neh = new NpoiExcelHelper();
- ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
- //是否默认
- int? isDefault = Request["IsDefaultDropDown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request["IsDefaultDropDown"].ParseStrTo<int>();
- var minorGraduationConditionPackageIDString = Request.Form["SelectedID"];
- var minorGraduationConditionPackageIDList = minorGraduationConditionPackageIDString.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => (Guid?)new Guid(x)).ToList();
- var dt = minorGraduationConditionPackageServices.GetMinorGraduationConditionPackageViewList(configuretView, isDefault, minorGraduationConditionPackageIDList)
- .Select(x => new
- {
- x.Title,
- x.StudentTypeName,
- x.IsDefaultName
- }).ToTable();
- string[] liststring = { "公式名称", "学生类别", "是否默认" };
- neh.Export(dt, liststring, "辅修毕业公式信息" + DateTime.Now.ToString("yyyyMMdd"));
- return Json(new ReturnMessage()
- {
- IsSuccess = true,
- Message = "导出成功。"
- });
- }
- }
- }
|