using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Bowin.Web.Controls.Mvc;
using Bowin.Common.Utility;
using Bowin.Common.Data;
using EMIS.Web.Controls;
using EMIS.ViewModel;
using EMIS.ViewModel.StudentManage.StudentStatistics;
using EMIS.CommonLogic.StudentManage.StudentStatistics;
namespace EMIS.Web.Controllers.StudentManage.StudentStatistics
{
[Authorization]
public class InSchoolSettingController : Controller
{
public IInSchoolSettingServices InSchoolSettingServices { get; set; }
///
/// 在校设定页面
///
///
public ActionResult List()
{
return View();
}
///
/// 在校设定列表查询
///
///
///
[HttpPost]
public ActionResult List(QueryParamsModel pararms)
{
ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
var inSchoolStatusID = pararms.getExtraInt("DictionaryInSchoolStatus") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryInSchoolStatus");
var isSelected = pararms.getExtraInt("DictionaryIsSelected") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryIsSelected");
var isDisplayID = pararms.getExtraInt("DictionaryIsDisplay") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryIsDisplay");
return base.Json(InSchoolSettingServices.GetInSchoolSettingViewGrid(configuretView, inSchoolStatusID, isSelected, isDisplayID, (int)pararms.page, (int)pararms.rows));
}
///
/// 设置(新增、修改、删除)
///
///
[HttpPost]
public ActionResult Edit()
{
try
{
var inSchoolSettingViewList = DataGrid.GetTableData("dgInSchoolSettingList");
InSchoolSettingServices.InSchoolSettingEdit(inSchoolSettingViewList);
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);
var inSchoolStatusID = Request.Form["DictionaryInSchoolStatus"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryInSchoolStatus"].ParseStrTo();
var isSelected = Request.Form["DictionaryIsSelected"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryIsSelected"].ParseStrTo();
var isDisplayID = Request.Form["DictionaryIsDisplay"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryIsDisplay"].ParseStrTo();
var dt = InSchoolSettingServices.GetInSchoolSettingViewList(configuretView, inSchoolStatusID, isSelected, isDisplayID)
.Select(x => new
{
x.InSchoolStatusID,
x.InSchoolStatusName,
x.IsSelectedName,
x.IsDisplayName,
x.CreateUserName,
x.ModifyUserName,
x.ModifyTime
}).ToTable();
string[] liststring = {
"类型代码", "在校状态", "是否选中", "是否显示", "创建人", "修改人", "修改时间"
};
neh.Export(dt, liststring, "在校设定信息" + DateTime.Now.ToString("yyyyMMdd"));
return Json(new ReturnMessage()
{
IsSuccess = true,
Message = "导出成功。"
});
}
}
}