using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using EMIS.CommonLogic.MinorManage.MinorSetting;
using EMIS.ViewModel;
using EMIS.Web.Controls;
using Bowin.Web.Controls.Mvc;
using EMIS.ViewModel.MinorManage.MinorSetting;
using Bowin.Common.Utility;
using Bowin.Common.Data;
namespace EMIS.Web.Controllers.MinorManage.MinorSetting
{
[Authorization]
public class MinorStandardSettingController : Controller
{
//
// GET: /MinorStandardSetting/
public IMinorStandardSettingServices minorStandardSettingServices { get; set; }
///
///
///
///
[HttpGet]
public ActionResult List()
{
return View();
}
///
/// 辅修专业设置列表
///
///
///
[HttpPost]
public ActionResult List(QueryParamsModel pararms)
{
ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
int? minorStandardID = pararms.getExtraInt("MinorStandardDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("MinorStandardDropDown");
int? standardID = pararms.getExtraInt("StandardDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("StandardDropDown");
return base.Json(minorStandardSettingServices.GetMinorControlViewGrid(configuretView, minorStandardID, standardID, (int)pararms.page, (int)pararms.rows));
}
///
/// 复制新增
///
///
///
//public ActionResult CopyAdd(Guid minorStandardSettingID)
//{
// MinorStandardSettingView minorStandardSettingView = new MinorStandardSettingView();
// minorStandardSettingView = minorStandardSettingServices.GetMinorStandardSettingView(minorStandardSettingID);
// return View("Edit", minorStandardSettingView);
//}
///
/// 复制新增
///
///
///
//[HttpPost]
//public ActionResult CopyAdd(MinorStandardSettingView minorStandardSettingView)
//{
// minorStandardSettingView.MinorStandardSettingID = Guid.Empty;
// return this.Edit(minorStandardSettingView);
//}
[HttpGet]
public ActionResult Edit(Guid? minorStandardSettingID)
{
MinorStandardSettingView minorStandardSettingView = new MinorStandardSettingView();
//if (minorStandardSettingID.HasValue)
//{
// minorStandardSettingView = minorStandardSettingServices.GetMinorStandardSettingView(minorStandardSettingID);
//}
return View(minorStandardSettingView);
}
///
/// 新增
///
///
///
[HttpPost]
public ActionResult Edit(MinorStandardSettingView minorStandardSettingView)
{
try
{
var minorStandardString = Request.Form["selectMinorStandardIDs"];
if (minorStandardString == "" || minorStandardString == null)
{
throw new Exception("请选择辅修专业信息");
}
var minorStandardIDList = minorStandardString.Split(',').Select(x => int.Parse(x)).ToList();
foreach (int id in minorStandardIDList)
{
minorStandardSettingView.MinorStandardID = id;
minorStandardSettingServices.MinorStandardSettingEdit(minorStandardSettingView);
}
return Json(new ReturnMessage()
{
IsSuccess = true,
Message = "保存成功。"
});
}
catch (Exception ex)
{
return Json(new ReturnMessage()
{
IsSuccess = false,
Message = "保存失败,原因:" + ex.Message
});
}
}
///
/// 删除
///
///
///
[HttpPost]
public ActionResult Delete(string minorStandardSettingIDs)
{
try
{
List list = minorStandardSettingIDs.Split(',').Where(x => !string.IsNullOrEmpty(x))
.Select(x => (Guid?)new Guid(x)).ToList();
minorStandardSettingServices.MinorStandardSettingDelete(list);
return base.Json("删除成功。");
}
catch (Exception ex)
{
return base.Json("删除失败,原因:" + ex.Message + "。");
}
}
///
/// 导出Excel
///
///
[HttpPost]
public ActionResult Excel()
{
NpoiExcelHelper neh = new NpoiExcelHelper();
ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
var minorStandardID = Request.Form["ddlYear"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["ddlYear"].ParseStrTo();
var standardID = Request.Form["cbgStandard"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["cbgStandard"].ParseStrTo();
var minorStandardSettingIDString = Request.Form["SelectedID"];
var minorStandardSettingIDList = minorStandardSettingIDString.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => (Guid?)new Guid(x)).ToList();
var dt = minorStandardSettingServices.GetMinorControlViewList(configuretView, minorStandardID, standardID, minorStandardSettingIDList).Select(x => new
{
x.StandardName,
x.MinorStandardName
}).ToTable();
string[] liststring = { "专业名称", "辅修专业名称" };
neh.Export(dt, liststring, "辅修专业设置");
return RedirectToAction("MsgShow", "Common", new
{
msg = "导出成功!",
url = Url.Action("List").AddMenuParameter()
});
}
[HttpPost]
public ActionResult GetStandardNotSelectID(QueryParamsModel pararms)
{
ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
int? selectstandardID = pararms.getExtraInt("StandardID") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("StandardID");
return base.Json(minorStandardSettingServices.GetStandardNotSelectID(selectstandardID, (int)pararms.page, (int)pararms.rows));
}
}
}