using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using EMIS.CommonLogic.GraduationManage.GraduationSetting;
using EMIS.ViewModel;
using EMIS.Web.Controls;
using EMIS.Entities;
using Bowin.Common.Utility;
using Bowin.Common.Data;
using EMIS.ViewModel.GraduationManage.GraduationSetting;
using Bowin.Web.Controls.Mvc;
namespace EMIS.Web.Controllers.GraduationManage.GraduationSetting
{
[Authorization]
public class GraduationConditionController : Controller
{
public IGraduationConditionServices GraduationConditionServices { get; set; }
///
/// 毕业条件页面
///
///
public ActionResult List()
{
return View();
}
///
/// 毕业条件列表查询
///
///
///
[HttpPost]
public ActionResult List(QueryParamsModel pararms)
{
ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
var isCurrent = pararms.getExtraInt("IsCurrentDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("IsCurrentDropDown");
return base.Json(GraduationConditionServices.GraduationConditionViewGrid(configuretView, isCurrent, (int)pararms.page, (int)pararms.rows));
}
///
/// 编辑
///
///
///
[HttpGet]
public ActionResult Edit(Guid? GraduationConditionID)
{
GraduationConditionView graduationStandardView = new GraduationConditionView();
if (GraduationConditionID.HasValue && GraduationConditionID != Guid.Empty)
{
graduationStandardView = GraduationConditionServices.GetGraduationConditionView(GraduationConditionID);
}
else
{
graduationStandardView.IsEnable = true;
}
return View(graduationStandardView);
}
///
/// 编辑
///
///
///
[HttpPost]
public ActionResult Edit(GraduationConditionView graduationConditionView)
{
try
{
GraduationConditionServices.GraduationConditionEdit(graduationConditionView);
return Json(new ReturnMessage()
{
IsSuccess = true,
Message = "保存成功。"
});
}
catch (Exception ex)
{
return Json(new ReturnMessage()
{
IsSuccess = false,
Message = "保存失败,原因:" + ex.Message + "。"
});
}
}
///
/// Excel导出
///
///
[HttpPost]
public ActionResult Excel()
{
NpoiExcelHelper neh = new NpoiExcelHelper();
ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
int? isCurrent = Request["IsCurrentDropDown"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request["IsCurrentDropDown"].ParseStrTo();
var dt = GraduationConditionServices.GetGraduationViewList(configuretView, isCurrent)
.Select(x => new
{
x.OrderNo,
x.Title,
x.IsEnableName
}).ToTable();
string[] liststring = {
"序号", "条件名称", "启用状态"
};
neh.Export(dt, liststring, "毕业条件信息" + DateTime.Now.ToString("yyyyMMdd"));
return Json(new ReturnMessage()
{
IsSuccess = true,
Message = "导出成功。"
});
}
}
}