using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using EMIS.ViewModel;
using EMIS.CommonLogic.DegreeManage.DegreeSetting;
using EMIS.Web.Controls;
using Bowin.Web.Controls.Mvc;
using EMIS.ViewModel.DegreeManage.DegreeSetting;
using Bowin.Common.Utility;
using Bowin.Common.Data;
namespace EMIS.Web.Controllers.DegreeManage.DegreeSetting
{
[Authorization]
public class DegreeOpenControlController : Controller
{
public IDegreeOpenControlServices DegreeOpenControlServices { get; set; }
///
/// 学位控制页面
///
///
public ActionResult List()
{
return View();
}
///
/// 学位控制列表查询
///
///
///
[HttpPost]
public ActionResult List(QueryParamsModel pararms)
{
ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
var gradSchoolyearID = pararms.getExtraGuid("GradSchoolyearDropdown");
var degreeBatchID = pararms.getExtraInt("DictionaryDegreeBatch") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryDegreeBatch");
return base.Json(DegreeOpenControlServices.GetDegreeOpenControlViewGrid(configuretView, gradSchoolyearID, degreeBatchID, (int)pararms.page, (int)pararms.rows));
}
///
/// 复制新增
///
///
///
public ActionResult CopyAdd(Guid degreeOpenControlID)
{
DegreeOpenControlView degreeOpenControlView = new DegreeOpenControlView();
degreeOpenControlView = DegreeOpenControlServices.GetDegreeOpenControlView(degreeOpenControlID);
return View("Edit", degreeOpenControlView);
}
///
/// 复制新增
///
///
///
[HttpPost]
public ActionResult CopyAdd(DegreeOpenControlView degreeOpenControlView)
{
degreeOpenControlView.DegreeOpenControlID = Guid.Empty;
return this.Edit(degreeOpenControlView);
}
///
/// 编辑(新增、修改)
///
///
///
[HttpGet]
public ActionResult Edit(Guid? degreeOpenControlID)
{
DegreeOpenControlView degreeOpenControlView = new DegreeOpenControlView();
if (degreeOpenControlID.HasValue)
{
degreeOpenControlView = DegreeOpenControlServices.GetDegreeOpenControlView(degreeOpenControlID);
}
else
{
degreeOpenControlView.StartDate = DateTime.Now;
degreeOpenControlView.EndDate = DateTime.Now.AddMonths(+1);
}
return View(degreeOpenControlView);
}
///
/// 编辑(新增、修改)
///
///
///
[HttpPost]
public ActionResult Edit(DegreeOpenControlView degreeOpenControlView)
{
try
{
DegreeOpenControlServices.DegreeOpenControlViewEdit(degreeOpenControlView);
return Json(new ReturnMessage()
{
IsSuccess = true,
Message = "保存成功。"
});
}
catch (Exception ex)
{
return Json(new ReturnMessage()
{
IsSuccess = false,
Message = "保存失败:" + ex.Message
});
}
}
///
/// 删除
///
///
///
[HttpPost]
public ActionResult Delete(string degreeOpenControlIDs)
{
try
{
List list = degreeOpenControlIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => (Guid?)new Guid(x)).ToList();
DegreeOpenControlServices.DegreeOpenControlDelete(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 gradSchoolyearID = Request.Form["GradSchoolyearDropdown"] == DropdownList.SELECT_ALL.ToString() ? null : Request.Form["GradSchoolyearDropdown"].ParseStrTo();
var degreeBatchID = Request.Form["DictionaryDegreeBatch"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryDegreeBatch"].ParseStrTo();
var dt = DegreeOpenControlServices.GetDegreeOpenControlViewList(configuretView, gradSchoolyearID, degreeBatchID)
.Select(x => new
{
x.GraduatingSemesterCode,
x.DegreeBatchName,
x.StartDate,
x.EndDate
}).ToTable();
string[] liststring = {
"毕业学期", "学位批次", "开始时间", "结束时间"
};
neh.Export(dt, liststring, "学位控制信息" + DateTime.Now.ToString("yyyyMMdd"));
return Json(new ReturnMessage()
{
IsSuccess = true,
Message = "导出成功。"
});
}
}
}