using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Bowin.Common.Utility;
using Bowin.Common.Data;
using Bowin.Web.Controls.Mvc;
using EMIS.Web.Controls;
using EMIS.ViewModel;
using EMIS.CommonLogic.DegreeManage.DegreeSetting;
using EMIS.ViewModel.DegreeManage.DegreeSetting;
using Bowin.Common.Linq.Entity;
namespace EMIS.Web.Controllers.DegreeManage.DegreeSetting
{
[Authorization]
public class DegreeConditionPackageController : Controller
{
public IDegreeConditionPackageServices DegreeConditionPackageServices { get; set; }
public IDegreeConditionServices DegreeConditionServices { get; set; }
///
/// 学位公式页面
///
///
public ActionResult List()
{
return View();
}
///
/// 学位公式列表查询
///
///
///
[HttpPost]
public ActionResult List(QueryParamsModel pararms)
{
ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
//是否默认
var isDefault = pararms.getExtraInt("IsDefaultDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("IsDefaultDropDown");
return base.Json(DegreeConditionPackageServices.GetDegreeConditionPackageViewGrid(configuretView, isDefault, (int)pararms.page, (int)pararms.rows));
}
///
/// 复制新增
///
///
///
public ActionResult CopyAdd(Guid DegreeConditionPackageID)
{
DegreeConditionPackageView degreeConditionPackageView = new DegreeConditionPackageView();
degreeConditionPackageView = DegreeConditionPackageServices.GetDegreeConditionPackageView(DegreeConditionPackageID);
return View("Edit", degreeConditionPackageView);
}
///
/// 复制新增
///
///
///
[HttpPost]
public ActionResult CopyAdd(DegreeConditionPackageView degreeConditionPackageView)
{
degreeConditionPackageView.DegreeConditionPackageID = Guid.Empty;
return this.Edit(degreeConditionPackageView);
}
///
/// 编辑(新增、修改)
///
///
///
[HttpGet]
public ActionResult Edit(Guid? DegreeConditionPackageID)
{
ViewBag.Type = Request.Params["Type"];//临时性加参数控制、屏蔽列表进入无保存按钮权限
DegreeConditionPackageView degreeConditionPackageView = new DegreeConditionPackageView();
if (DegreeConditionPackageID.HasValue && DegreeConditionPackageID != Guid.Empty)
{
degreeConditionPackageView = DegreeConditionPackageServices.GetDegreeConditionPackageView(DegreeConditionPackageID);
}
else
{
degreeConditionPackageView.StudentTypeID = (int)CF_STUDENTTYPE.DefaultType;
degreeConditionPackageView.IsDefault = true;
}
return View(degreeConditionPackageView);
}
///
/// 编辑(新增、修改)
/// 注:判断是否默认状态(同一种学生类别,只有一种默认公式)
/// 暂时不考虑当公式被引用时,不可修改公式中条件的情况
///
///
///
[HttpPost]
public ActionResult Edit(DegreeConditionPackageView degreeConditionPackageView)
{
try
{
var degreeConditionViewList = DataGrid.GetTableData("dgDegreeConditionList");
DegreeConditionPackageServices.DegreeConditionPackageEdit(degreeConditionPackageView, degreeConditionViewList);
return Json(new ReturnMessage()
{
IsSuccess = true,
Message = "保存成功。"
});
}
catch (Exception ex)
{
return Json(new ReturnMessage()
{
IsSuccess = false,
Message = "保存失败,原因:" + ex.Message + "。"
});
}
}
///
/// 删除(当对应的学位公式被引用时,不可删除--学位公式、对应的学位条件)
///
///
///
[HttpPost]
public ActionResult Delete(string degreeConditionPackageIDs)
{
try
{
List list = degreeConditionPackageIDs.Split(',').Where(x => !string.IsNullOrEmpty(x))
.Select(x => (Guid?)new Guid(x)).ToList();
DegreeConditionPackageServices.DegreeConditionPackageDelete(list);
return base.Json("删除成功。");
}
catch (Exception ex)
{
return base.Json("删除失败,原因:" + ex.Message);
}
}
///
/// 学位公式对应的学位条件列表页面(根据对应的学位公式ID查询)
///
///
///
public ActionResult DegreeConditionViewList(Guid? DegreeConditionPackageID)
{
var degreeConditionPackageList = new List();
if (DegreeConditionPackageID.HasValue && DegreeConditionPackageID != Guid.Empty)
{
degreeConditionPackageList = DegreeConditionPackageServices
.GetDegreeConditionList(DegreeConditionPackageID);
}
return Json(new GridResultSet()
{
rows = degreeConditionPackageList,
total = degreeConditionPackageList.Count
});
}
///
/// 学位条件添加页面
///
///
public ActionResult DegreeConditionList()
{
return View();
}
///
/// 学位条件添加页面查询列表
///
///
///
[HttpPost]
public ActionResult DegreeConditionList(QueryParamsModel pararms)
{
ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
var degreeConditionPackageID = Request["DegreeConditionPackageID"].ParseStrTo();
//启用状态(默认为启用)
var isCurrent = (int)CF_GeneralPurpose.IsYes;
return base.Json(DegreeConditionPackageServices.GetDegreeConditionNoViewGrid(configuretView, degreeConditionPackageID,
isCurrent, (int)pararms.page, (int)pararms.rows));
}
///
/// Excel导出
///
///
[HttpPost]
public ActionResult Excel()
{
NpoiExcelHelper neh = new NpoiExcelHelper();
ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
//是否默认
int? isDefault = Request["IsDefaultDropDown"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request["IsDefaultDropDown"].ParseStrTo();
var dt = DegreeConditionPackageServices.GetDegreeConditionPackageViewList(configuretView, isDefault)
.Select(x => new
{
x.Title,
x.StudentTypeName,
x.IsDefaultName
}).ToTable();
string[] liststring = {
"公式名称", "学生类别", "是否默认"
};
neh.Export(dt, liststring, "学位公式信息" + DateTime.Now.ToString("yyyyMMdd"));
return Json(new ReturnMessage()
{
IsSuccess = true,
Message = "导出成功。"
});
}
}
}