using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using EMIS.ViewModel;
using EMIS.Web.Controls;
using Bowin.Web.Controls.Mvc;
using EMIS.CommonLogic.MinorGraduation.MinorGraduationManage;
using Bowin.Common.Exceptions;
using Bowin.Common.Utility;
using Bowin.Common.Data;
using EMIS.ViewModel.MinorGraduation.MinorGraduationManage;
using EMIS.CommonLogic.MinorGraduation.MinorGraduationSetting;
namespace EMIS.Web.Controllers.MinorGraduation.MinorGraduationManage
{
[Authorization]
public class MinorGraduationApplyController : Controller
{
//
// GET: /MinorGraduationApply/
public IMinorGraduationApplyServices minorGraduationApplyServices { get; set; }
public IMinorGraduationConditionPackageServices minorGraduationConditionPackageServices { get; set; }
public ActionResult List()
{
return View();
}
[HttpPost]
public ActionResult List(QueryParamsModel pararms)
{
ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
var gradSchoolyearID = pararms.getExtraGuid("GradSchoolyearDropdown");
var collegeID = pararms.getExtraGuid("CollegeDropdown");
var yearID = pararms.getExtraInt("SchoolyearDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("SchoolyearDictionaryDropDown");
var standardID = pararms.getExtraInt("StandardDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("StandardDictionaryDropDown");
//毕业类型
var graduationTypeID = pararms.getExtraInt("DictionaryGraduationType") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryGraduationType");
//在校状态
var inSchoolStatus = pararms.getExtraInt("DictionaryInschoolStatus") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryInschoolStatus");
//毕业结论
var graduationResult = pararms.getExtraInt("DictionaryGraduationResult") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryGraduationResult");
//审核状态
var approvalStatus = pararms.getExtraInt("DictionaryApprovalStatus") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryApprovalStatus");
return base.Json(minorGraduationApplyServices.GetMinorGraduationApplyViewGrid(configuretView, gradSchoolyearID, collegeID, yearID,
standardID, graduationTypeID, inSchoolStatus, graduationResult, approvalStatus, (int)pararms.page, (int)pararms.rows));
}
///
/// 生成
///
///
[HttpGet]
public ActionResult Generate()
{
return View();
}
///
/// 生成
///
///
///
[HttpPost]
public ActionResult Generate(QueryParamsModel pararms)
{
try
{
ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
var yearID = Request.Form["YearDropDown"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["YearDropDown"].ParseStrTo();
minorGraduationApplyServices.MinorGraduationApplyGenerate(yearID);
return Json(new ReturnMessage()
{
IsSuccess = true,
Message = "生成成功。"
});
}
catch (Exception ex)
{
return Json(new ReturnMessage()
{
IsSuccess = false,
Message = "生成失败,原因:" + ex.Message
});
}
}
[HttpPost]
public ActionResult Delete(string minorGraduationApplyIDs)
{
try
{
List list = minorGraduationApplyIDs.Split(',').Where(x => !string.IsNullOrEmpty(x))
.Select(x => (Guid?)new Guid(x)).ToList();
minorGraduationApplyServices.MinorGraduationApplyDelete(list);
return base.Json("删除成功。");
}
catch (Exception ex)
{
return base.Json("删除失败,原因:" + ex.Message);
}
}
[HttpGet]
public ActionResult Submit()
{
MinorGraduationApplyView minorGraduationApplyView = new MinorGraduationApplyView();
//查询对应的默认毕业公式
var minorGraduationConditionPackageView = minorGraduationConditionPackageServices
.GetDefaultMinorGraduationConditionPackageView();
if (minorGraduationConditionPackageView != null)
{
minorGraduationApplyView.MinorGraduationConditionPackageID = minorGraduationConditionPackageView.MinorGraduationConditionPackageID;
minorGraduationApplyView.StudentTypeID = minorGraduationConditionPackageView.StudentTypeID;
}
return View(minorGraduationApplyView);
}
[HttpPost]
public ActionResult Submit(string minorGraduationApplyIDs, MinorGraduationApplyView minorGraduationApplyView)
{
try
{
List list = minorGraduationApplyIDs.Split(',').Where(x => !string.IsNullOrEmpty(x))
.Select(x => (Guid?)new Guid(x)).ToList();
var user = HttpContext.User as EMIS.Utility.FormValidate.CustomPrincipal;
var result = minorGraduationApplyServices.MinorGraduationApplySubmit(list, user.UserID, minorGraduationApplyView);
return Json(new ReturnMessage()
{
IsSuccess = true,
Message = "提交成功" + result + "。"
});
}
catch (Exception ex)
{
return Json(new ReturnMessage()
{
IsSuccess = false,
Message = "提交失败,原因:" + ex.Message + "。"
});
}
}
[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 gradSchoolyearID = Request.Form["GradSchoolyearDropdown"].ParseStrTo();
var collegeID = Request.Form["CollegeDropdown"].ParseStrTo();
var yearID = Request.Form["SchoolyearDictionaryDropDown"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["SchoolyearDictionaryDropDown"].ParseStrTo();
var standardID = Request.Form["StandardDictionaryDropDown"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["StandardDictionaryDropDown"].ParseStrTo();
//毕业类型
var graduationTypeID = Request.Form["DictionaryGraduationType"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryGraduationType"].ParseStrTo();
//在校状态
var inSchoolStatus = Request.Form["DictionaryInschoolStatus"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryInschoolStatus"].ParseStrTo();
//毕业结论
var graduationResult = Request.Form["DictionaryGraduationResult"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryGraduationResult"].ParseStrTo();
//审核状态
var approvalStatus = Request.Form["DictionaryApprovalStatus"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryApprovalStatus"].ParseStrTo();
var minorGraduationApplyIDString = Request.Form["SelectedID"];
var minorGraduationApplyIDList = minorGraduationApplyIDString.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => (Guid?)new Guid(x)).ToList();
var dt = minorGraduationApplyServices.GetMinorGraduationApplyViewList(configuretView, gradSchoolyearID, collegeID, yearID,
standardID, graduationTypeID, inSchoolStatus, graduationResult, approvalStatus, minorGraduationApplyIDList)
.Select(x => new
{
x.GraduatingSemesterCode,
x.StudentNo,
x.UserName,
x.SexName,
x.GraduationTypeName,
x.ClassminorName,
x.InSchoolStatusName,
x.CollegeName,
x.MinorGraduationResultName,
x.ApprovalResult,
x.Remark,
x.ApprovalStatusName
}).ToTable();
string[] liststring = {
"毕业学期", "学号", "姓名", "性别", "毕业类型", "辅修班级", "在校状态", "院系所", "毕业结论", "预审说明", "备注", "审核状态"
};
neh.Export(dt, liststring, "辅修毕业申请信息" + DateTime.Now.ToString("yyyyMMdd"));
return Json(new ReturnMessage()
{
IsSuccess = true,
Message = "导出成功。"
});
}
}
}