123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.Mvc;
- using EMIS.CommonLogic.SelectCourse;
- using EMIS.ViewModel;
- using EMIS.Web.Controls;
- using Bowin.Web.Controls.Mvc;
- using EMIS.ViewModel.SelectCourse;
- using Bowin.Common.Exceptions;
- using Bowin.Common.Utility;
- using Bowin.Common.Data;
- namespace EMIS.Web.Controllers.SelectCourseManage
- {
- [Authorization]
- public class FreeSelectionCouseControlController : Controller
- {
- public IOpenControlSettingServices openControlSettingServices { 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 schoolYearID = pararms.getExtraGuid("SchoolyearDropdown");
- var Years = pararms.getExtraInt("SchoolyearDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("SchoolyearDictionaryDropDown");
- return this.Json(openControlSettingServices.GetFreeSelectionCouseControlViewGrid(configuretView, schoolYearID, Years, (int)pararms.page, (int)pararms.rows));
- }
- /// <summary>
- /// 编辑
- /// </summary>
- /// <returns></returns>
- public ActionResult Edit(Guid? FreeSelectionCourseGradeYearSettingID)
- {
- FreeSelectionCouseControlView optionalCourseSettingView = new FreeSelectionCouseControlView();
- if (FreeSelectionCourseGradeYearSettingID.HasValue && FreeSelectionCourseGradeYearSettingID != Guid.Empty)
- optionalCourseSettingView = openControlSettingServices.GetFreeSelectionCouseControlSettingViewInfo(FreeSelectionCourseGradeYearSettingID);
- ViewBag.RecordStatus = optionalCourseSettingView.RecordStatus;
- return View(optionalCourseSettingView);
- }
- /// <summary>
- /// 保存修改
- /// </summary>
- /// <param name="optionalCourseSettingView"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult Edit(FreeSelectionCouseControlView optionalCourseSettingView)
- {
- try
- {
- openControlSettingServices.FreeSelectionCouseControlSave(optionalCourseSettingView);
- return Json(new ReturnMessage()
- {
- IsSuccess = true,
- Message = "保存成功!"
- });
- }
- catch (Exception ex)
- {
- return Json(new ReturnMessage()
- {
- IsSuccess = false,
- Message = "保存失败:" + ex.Message
- });
- }
- }
- /// <summary>
- /// 删除
- /// </summary>
- /// <param name="optionalCourseIDs"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult Delete(string freeSelectionCourseGradeYearSettingIDs)
- {
- try
- {
- List<Guid?> list = new List<Guid?>();
- for (int i = 0; i < freeSelectionCourseGradeYearSettingIDs.Split(',').Length; i++)
- {
- if (!string.IsNullOrEmpty(freeSelectionCourseGradeYearSettingIDs.Split(',')[i]))
- {
- Guid optionalCourseSettingID = new Guid(freeSelectionCourseGradeYearSettingIDs.Split(',')[i]);
- list.Add(optionalCourseSettingID);
- }
- }
- openControlSettingServices.FreeSelectionCouseControlDelete(list);
- return this.Json("删除成功!");
- }
- catch (Exception ex)
- {
- string mge = ex.Message;
- System.Data.SqlClient.SqlException num = ExceptionHelper.GetSqlException(ex);
- if (num != null)
- {
- if (num.Number == 547)
- mge = "请先删除所有关联的数据!";
- }
- return this.Json("删除失败,原因:" + mge);
- }
- }
- [HttpPost]
- public ActionResult Excel()
- {
- NpoiExcelHelper neh = new NpoiExcelHelper();
- ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
- //避开全选值
- if (configuretView.Attribute == DropdownList.SELECT_ALL.ToString()) configuretView.Attribute = "";
- var schoolYearID = Request.Form["SchoolYear"].ParseStrTo<Guid>();
-
- var Years = Request.Form["DictionaryGrade"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryGrade"].ParseStrTo<int>();
- var dt = openControlSettingServices.GetFreeSelectionCouseControlList(configuretView, schoolYearID, Years)
- .Select(x => new
- {
- x.SchoolyearCode,
- x.GradeYear,
- x.StartTime,
- x.EndTime,
- x.MaxSelectCount,
- x.MinSelectCount,
- x.MaxCredit,
- x.MinCredit
- }).ToTable();
- string[] liststring = { "学年学期",
- "年级", "开始时间",
- "结束时间",
- "门数上限", "门数下限",
- "学分上限","学分下限"};
- neh.Export(dt, liststring, "任选设定");
- return RedirectToAction("MsgShow", "Common", new
- {
- msg = "导出成功!",
- url = Url.Content("~/FreeSelectionCouseControl/List").AddMenuParameter()
- });
- }
- }
- }
|