using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using EMIS.CommonLogic.MinorGraduation.MinorGraduationSetting;
using EMIS.ViewModel;
using EMIS.Web.Controls;
using Bowin.Common.Data;
using Bowin.Web.Controls.Mvc;
using EMIS.ViewModel.MinorGraduation.MinorGraduationSetting;
using Bowin.Common.Exceptions;
using Bowin.Common.Utility;
using EMIS.Utility;
namespace EMIS.Web.Controllers.MinorGraduation.MinorGraduationSetting
{
[Authorization]
public class MinorGraduationStandardController : Controller
{
//
// GET: /MinorGraduationStandard/
public IMinorGraduationStandardServices minorGraduationStandardServices { get; set; }
public ActionResult List()
{
return View();
}
[HttpPost]
public ActionResult List(QueryParamsModel pararms)
{
ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
var collegeID = pararms.getExtraGuid("CollegeDropdown");
var yearID = pararms.getExtraInt("SchoolyearDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("SchoolyearDictionaryDropDown");
var standardID = pararms.getExtraInt("StandardDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("StandardDictionaryDropDown");
return base.Json(minorGraduationStandardServices.GetMinorGraduationStandardViewGrid(configuretView, collegeID, yearID,
standardID, (int)pararms.page, (int)pararms.rows));
}
///
/// 生成
///
///
[HttpGet]
public ActionResult Generate()
{
return View();
}
///
/// 生成
///
///
///
[HttpPost]
public ActionResult Generate(QueryParamsModel pararms)
{
try
{
var collegeID = Request.Form["CollegeDropdown"].ParseStrTo();
var yearID = Request.Form["YearDropDown"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["YearDropDown"].ParseStrTo();
minorGraduationStandardServices.MinorGraduationStandardGenerate(yearID, collegeID);
return Json(new ReturnMessage()
{
IsSuccess = true,
Message = "生成成功。"
});
}
catch (Exception ex)
{
return Json(new ReturnMessage()
{
IsSuccess = false,
Message = "生成失败,原因:" + ex.Message + "。"
});
}
}
///
/// 编辑(新增、修改)
///
///
///
[HttpGet]
public ActionResult Edit(Guid? minorGraduationStandardID)
{
MinorGraduationStandardView minorGraduationStandardView = new MinorGraduationStandardView();
if (minorGraduationStandardID.HasValue && minorGraduationStandardID != Guid.Empty)
{
minorGraduationStandardView = minorGraduationStandardServices.GetMinorGraduationStandardView(minorGraduationStandardID);
}
return View(minorGraduationStandardView);
}
///
/// 编辑(新增、修改)
///
///
///
[HttpPost]
public ActionResult Edit(MinorGraduationStandardView minorGraduationStandardView)
{
try
{
minorGraduationStandardServices.MinorGraduationStandardEdit(minorGraduationStandardView);
return Json(new ReturnMessage()
{
IsSuccess = true,
Message = "保存成功。"
});
}
catch (Exception ex)
{
return Json(new ReturnMessage()
{
IsSuccess = false,
Message = "保存失败,原因:" + ex.Message + "。"
});
}
}
[HttpPost]
public ActionResult Delete(string minorGraduationStandardIDs)
{
try
{
List list = minorGraduationStandardIDs.Split(',').Where(x => !string.IsNullOrEmpty(x))
.Select(x => (Guid?)new Guid(x)).ToList();
minorGraduationStandardServices.MinorGraduationStandardDelete(list);
return base.Json("删除成功。");
}
catch (Exception ex)
{
return base.Json("删除失败,原因:" + ex.Message);
}
}
[HttpPost]
public ActionResult Excel()
{
NpoiExcelHelper neh = new NpoiExcelHelper();
ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
//var gradSchoolyearID = Request.Form["GradSchoolyearDropdown"] == DropdownList.SELECT_ALL.ToString() ? null : Request.Form["GradSchoolyearDropdown"].ParseStrTo();
var collegeID = Request.Form["CollegeDropdown"].ParseStrTo();
var yearID = Request.Form["SchoolyearDictionaryDropDown"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["SchoolyearDictionaryDropDown"].ParseStrTo();
var standardID = Request.Form["StandardDictionaryDropDown"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["StandardDictionaryDropDown"].ParseStrTo();
var minorGraduationStandardIDString = Request.Form["SelectedID"];
var minorGraduationStandardIDList = minorGraduationStandardIDString.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => (Guid?)new Guid(x)).ToList();
var dt = minorGraduationStandardServices.GetMinorGraduationStandardViewList(configuretView, collegeID, yearID,
standardID, minorGraduationStandardIDList)
.Select(x => new
{
x.YearID,
x.CollegeName,
x.StandardName,
x.GraduationCredit
}).ToTable();
string[] liststring = {
"年级", "院系所", "专业名称", "毕业学分"
};
neh.Export(dt, liststring, "辅修毕业标准信息" + DateTime.Now.ToString("yyyyMMdd"));
return Json(new ReturnMessage()
{
IsSuccess = true,
Message = "导出成功。"
});
}
}
}