using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using EMIS.CommonLogic.RetakeManage;
using EMIS.ViewModel.RetakeManage;
using EMIS.ViewModel;
using EMIS.Web.Controls;
using Bowin.Common.Utility;
using Bowin.Common.Data;
namespace EMIS.Web.Controllers.RetakeManage
{
[Authorization]
public class RetakeOpenControlController : Controller
{
public IRetakeOpenControlServices RetakeOpenControlServices { get; set; }
///
/// 重修控制页面
///
///
public ActionResult List()
{
return View();
}
///
/// 重修控制列表查询
///
///
///
[HttpPost]
public ActionResult List(QueryParamsModel pararms)
{
ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
Guid? schoolyearID = pararms.getExtraGuid("ddlSchoolYear");
return base.Json(RetakeOpenControlServices.GetRetakeOpenControlViewList(configuretView, schoolyearID, (int)pararms.page, (int)pararms.rows));
}
///
/// 编辑
///
///
///
public ActionResult Edit(Guid? RetakeOpenControlID)
{
RetakeOpenControlView retakeOpenControlView = new RetakeOpenControlView();
if (RetakeOpenControlID.HasValue)
{
retakeOpenControlView = RetakeOpenControlServices.GetRetakeOpenControlView(RetakeOpenControlID);
}
else
{
retakeOpenControlView.StartDate = DateTime.Now;
retakeOpenControlView.EndDate = DateTime.Now.AddDays(+1);
}
return View(retakeOpenControlView);
}
///
/// 编辑(新增、修改)
///
///
///
[HttpPost]
public ActionResult Edit(RetakeOpenControlView retakeOpenControlView)
{
try
{
RetakeOpenControlServices.RetakeOpenControlEdit(retakeOpenControlView);
return Json(new ReturnMessage()
{
IsSuccess = true,
Message = "保存成功。"
});
}
catch (Exception ex)
{
return Json(new ReturnMessage()
{
IsSuccess = false,
Message = "保存失败,原因:" + ex.Message
});
}
}
///
/// 删除
///
///
///
[HttpPost]
public ActionResult Delete(string retakeOpenControlIDs)
{
try
{
List list = retakeOpenControlIDs.Split(',').Where(x => !string.IsNullOrEmpty(x))
.Select(x => (Guid?)new Guid(x)).ToList();
RetakeOpenControlServices.RetakeOpenControlDelete(list);
return base.Json(new ReturnMessage()
{
IsSuccess = true,
Message = "删除成功。"
});
}
catch (Exception ex)
{
return base.Json(new ReturnMessage()
{
IsSuccess = false,
Message = "删除失败,原因:" + ex.Message
});
}
}
///
/// Excel导出
///
///
[HttpPost]
public ActionResult Excel()
{
NpoiExcelHelper neh = new NpoiExcelHelper();
ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
var schoolyearID = Request.Form["ddlSchoolYear"].ParseStrTo();
var dt = RetakeOpenControlServices.GetRetakeOpenControlViewList(configuretView, schoolyearID)
.Select(x => new
{
x.SchoolyearCode,
x.StartDate,
x.EndDate
}).ToTable();
string[] liststring = {
"重修学年学期", "开始时间", "结束时间"
};
neh.Export(dt, liststring, "重修控制信息" + DateTime.Now.ToString("yyyyMMdd"));
return Json(new ReturnMessage()
{
IsSuccess = true,
Message = "导出成功。"
});
}
}
}