using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Linq.Expressions;
using Bowin.Common.Data;
using Bowin.Common.Exceptions;
using Bowin.Common.Utility;
using Bowin.Common.JSON;
using Bowin.Web.Controls.Mvc;
using EMIS.Web.Controls;
using EMIS.Utility;
using EMIS.Entities;
using EMIS.ViewModel;
using EMIS.ViewModel.ChargeManage.ChargeSituation;
using EMIS.ViewModel.UniversityManage.SpecialtyClassManage;
using EMIS.CommonLogic.CalendarManage;
using EMIS.CommonLogic.UniversityManage.SpecialtyClassManage;
using EMIS.CommonLogic.ChargeManage.ChargeSituation;
using EMIS.CommonLogic.UniversityManage.AdministrativeOrgan;
namespace EMIS.Web.Controllers.ChargeManage.ChargeSituation
{
[Authorization]
public class ChargeStandardController : Controller
{
public IChargeStandardServices ChargeStandardServices { get; set; }
public ICollegeServices collegeServices { get; set; }
public ISchoolYearServices SchoolYearServices { get; set; }
public IGrademajorServices iGrademajorServices { get; set; }
///
/// 收费标准页面
///
///
public ActionResult List()
{
return View();
}
///
/// 列表查询
///
///
///
[HttpPost]
public ActionResult List(QueryParamsModel pararms)
{
ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
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 educationID = pararms.getExtraInt("DictionaryEducation") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryEducation");
var learningFormID = pararms.getExtraInt("DictionaryLearningform") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryLearningform");
var LearnSystem = pararms.getExtraString("DictionaryLearnSystem");
var chargeYearID = pararms.getExtraInt("ChargeYearDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ChargeYearDropDown");
var chargeProjectID = pararms.getExtraGuid("ChargeProjectComboGrid");
//在校状态
var inSchoolStatus = pararms.getExtraInt("DictionaryInschoolStatus") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryInschoolStatus");
return base.Json(ChargeStandardServices.GetChargeStandardViewGrid(configuretView, collegeID, yearID, chargeYearID,
standardID, educationID, learningFormID, chargeProjectID, LearnSystem, inSchoolStatus, (int)pararms.page, (int)pararms.rows));
}
///
/// 编辑
///
///
[HttpGet]
public ActionResult Edit(Guid? chargeStandardID)
{
ChargeStandardView chargeStandardView = new ChargeStandardView();
if (chargeStandardID != null && chargeStandardID.HasValue)
{
chargeStandardView = ChargeStandardServices.GetChargeStandardView(chargeStandardID);
}
return View(chargeStandardView);
}
///
/// 编辑页面
///
///
///
[HttpPost]
public ActionResult Edit(ChargeStandardView chargeStandardView)
{
try
{
ChargeStandardServices.ChargeStandardEdit(chargeStandardView);
return Json(new ReturnMessage()
{
IsSuccess = true,
Message = "保存成功。"
});
}
catch (Exception ex)
{
return Json(new ReturnMessage()
{
IsSuccess = false,
Message = "保存失败,原因:" + ex.Message + "。"
});
}
}
///
/// 删除(当选择删除的信息中存在对应的应收名单时,无法删除)
///
///
///
[HttpPost]
public ActionResult Delete(string chargeStandardIDs)
{
try
{
List list = new List();
for (int i = 0; i < chargeStandardIDs.Split(',').Length; i++)
{
string id = chargeStandardIDs.Split(',')[i];
if (!string.IsNullOrEmpty(id))
{
Guid chargeStandardID = new Guid(id);
list.Add(chargeStandardID);
}
}
ChargeStandardServices.ChargeStandardDelete(list);
return base.Json("删除成功。");
}
catch (Exception ex)
{
string mge = ex.Message;
System.Data.SqlClient.SqlException num = ExceptionHelper.GetSqlException(ex);
if (num != null)
{
if (num.Number == 547)
mge = "请先删除与其关联的数据,如:应收名单等";
}
return base.Json("删除失败,原因:" + mge + "。");
}
}
///
/// 刷新名单(生成对应的收费标准应收名单)
///
///
///
[HttpPost]
public ActionResult CreatChargeList(string chargeStandardIDs, int? inschoolStatus)
{
try
{
List chargeStandardIDList = new List();
for (int i = 0; i < chargeStandardIDs.Split(',').Length; i++)
{
string id = chargeStandardIDs.Split(',')[i];
if (!string.IsNullOrEmpty(id))
{
Guid chargeStandardID = new Guid(id);
chargeStandardIDList.Add(chargeStandardID);
}
}
string result = ChargeStandardServices.CreatStudentChargeList(chargeStandardIDList, inschoolStatus);
return Json(new ReturnMessage()
{
IsSuccess = true,
Message = "刷新成功" + result + "。"
});
}
catch (Exception ex)
{
string mge = ex.Message;
return Json(new ReturnMessage()
{
IsSuccess = false,
Message = "刷新失败,原因:" + ex.Message + "。"
});
}
}
///
/// 收费标准年级专业新增
///
///
///
[HttpGet]
public ActionResult Addlist()
{
ChargeStandardView chargeStandardView = new ChargeStandardView();
chargeStandardView.InSchoolStatus = (int)CF_INOrOutSchoolStatus.Yes;
chargeStandardView.ChargeYear = BaseExtensions.GetCurrentYearID();
return View(chargeStandardView);
}
///
/// 收费标准年级专业新增
///
///
///
///
///
///
[HttpPost]
public ActionResult Addlist(ChargeStandardView chargeStandardView)
{
try
{
var gradeMajorIDs = Request["gradeMajorIDs"].JsonToObject>();
string result = ChargeStandardServices.ChargeStandardAdd(gradeMajorIDs, chargeStandardView);
return Json(new ReturnMessage()
{
IsSuccess = true,
Message = "保存成功" + result + "。"
});
}
catch (Exception ex)
{
string mge = ex.Message;
return Json(new ReturnMessage()
{
IsSuccess = false,
Message = "保存失败,原因:" + ex.Message + "。"
});
}
}
///
/// 收费标准新增年级专业列表
///
///
///
[HttpPost]
public ActionResult GradeMajorList(QueryParamsModel pararms)
{
//注:List页面取ID,Excel取Name
ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
var collegeID = pararms.getExtraGuid("CollegeDropdown");
var yearID = pararms.getExtraInt("DictionarySchoolyear") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionarySchoolyear");
var standardID = pararms.getExtraInt("DictionaryStandard") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryStandard");
var educationID = pararms.getExtraInt("DictionaryEducation") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryEducation");
var learningFormID = pararms.getExtraInt("DictionaryLearningform") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryLearningform");
var LearnSystem = pararms.getExtraString("DictionaryLearnSystem");
var gradeMajorID = pararms.getExtraGuid("GradeMajorComboGrid"); //暂时不做年级专业下拉查询
var inschoolstatus = pararms.getExtraInt("InSchoolStatus") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("InSchoolStatus");
var chargeYearID = pararms.getExtraInt("ChargeYear") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ChargeYear");
//注:收费项目取Value值
var chargeProjectID = pararms.getExtraGuid("ChargeProjectID");
return base.Json(ChargeStandardServices.GetGradeMajorViewGrid(configuretView, gradeMajorID, collegeID, yearID, standardID,
educationID, learningFormID, LearnSystem, inschoolstatus, chargeYearID, chargeProjectID, (int)pararms.page, (int)pararms.rows));
}
///
/// 查询年级专业下各班级学生名单
///
///
[HttpGet]
public ActionResult StudentList()
{
return View();
}
///
/// 查询年级专业下各班级学生名单
///
///
///
[HttpPost]
public ActionResult StudentList(QueryParamsModel pararms)
{
ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
var grademajorID = Request["grademajorID"].ParseStrTo();
int? inschoolStatus = Request["inschoolStatus"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request["inschoolStatus"].ParseStrTo();
return Json(ChargeStandardServices.GetGradeMajorStudentViewGrid(grademajorID, inschoolStatus, (int)pararms.page, (int)pararms.rows));
}
///
/// 应收名单列表
///
///
[HttpGet]
public ActionResult StudentChargeList()
{
return View();
}
///
/// 应收名单查询列表
///
///
///
[HttpPost]
public ActionResult StudentChargeList(QueryParamsModel pararms)
{
var grademajorID = Request["grademajorID"].ParseStrTo();
int? chargeYearID = Request["chargeYearID"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request["chargeYearID"].ParseStrTo();
var chargeProjectID = Request["chargeProjectID"].ParseStrTo();
//在校状态暂时无效
int? inschoolStatus = Request["inschoolStatus"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request["inschoolStatus"].ParseStrTo();
return Json(ChargeStandardServices.GetGradeMajorStudentChargeViewGrid(grademajorID, chargeYearID, chargeProjectID, inschoolStatus, (int)pararms.page, (int)pararms.rows));
}
///
/// 验证(业务主键:年级专业ID、缴费学年、收费项目ID)
///
///
///
///
///
///
[HttpPost]
public ActionResult Verification(Guid? chargeStandardID, Guid? grademajorID, int? chargeYearID, Guid? chargeProjectID)
{
return Json(ChargeStandardServices.GetVerification(chargeStandardID, grademajorID, chargeYearID, chargeProjectID));
}
///
/// Excel导出
///
///
[HttpPost]
public ActionResult Excel()
{
NpoiExcelHelper neh = new NpoiExcelHelper();
ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
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 educationID = Request.Form["DictionaryEducation"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryEducation"].ParseStrTo();
var learningFormID = Request.Form["DictionaryLearningform"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryLearningform"].ParseStrTo();
var LearnSystem = Request.Form["DictionaryLearnSystem"].ToString();
var inSchoolStatus = Request.Form["DictionaryInschoolStatus"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryInschoolStatus"].ParseStrTo();
var chargeYearID = Request.Form["ChargeYearDropDown"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["ChargeYearDropDown"].ParseStrTo();
var chargeProjectID = Request.Form["ChargeProjectComboGrid"].ParseStrTo();
var dt = ChargeStandardServices.GetChargeStandardList(configuretView, collegeID, yearID, standardID, learningFormID,
chargeYearID, chargeProjectID, LearnSystem, educationID, inSchoolStatus).Select(x => new
{
x.GradeMajorCode,
x.GrademajorStr,
x.GradeStr,
x.StandardID,
x.StandardCode,
x.MajorStr,
x.EducationName,
x.LearningformStr,
x.LearnSystem,
x.CollegeCode,
x.CollegeStr,
x.ChargeYear,
x.ChargeProjectStr,
x.Amount,
x.StudentCount,
x.StudentChargeCount
}).ToTable();
string[] liststring = { "年级专业代码", "年级专业名称", "年级", "专业ID(Value)",
"专业代码", "专业名称", RSL.Get("EducationID"), "学习形式",
"学制", RSL.Get("CollegeCode"), RSL.Get("CollegeName"),
"缴费学年", "收费项目", "应收金额(¥)", "学生人数", "生成人数"
};
neh.Export(dt, liststring, "收费标准信息" + DateTime.Now.ToString("yyyyMMdd"));
return Json(new ReturnMessage()
{
IsSuccess = true,
Message = "导出成功。"
});
}
///
/// 学生信息明细Excel导出
///
///
[HttpPost]
public ActionResult GrademajorStudentExcel()
{
NpoiExcelHelper neh = new NpoiExcelHelper();
var grademajorID = Request["grademajorID"].ParseStrTo();
int? inschoolstatus = Request["inschoolStatus"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request["inschoolStatus"].ParseStrTo();
var dt = ChargeStandardServices.GetGradeMajorStudentViewGrid(grademajorID, inschoolstatus).Select(x => new
{
x.LoginID,
x.UserName,
x.SexName,
x.ClassMajorName,
x.InSchoolStatusName,
x.StudentStatusName
}).ToTable();
string[] liststring = { "学号", "姓名", "性别", "班级名称 ", "在校状态", "学籍状态" };
neh.Export(dt, liststring, "学生信息明细" + DateTime.Now.ToString("yyyyMMdd"));
return Json(new ReturnMessage()
{
IsSuccess = true,
Message = "导出成功。"
});
}
///
/// 应收名单明细Excel导出
///
///
[HttpPost]
public ActionResult GrademajorStudentChargeExcel()
{
NpoiExcelHelper neh = new NpoiExcelHelper();
var grademajorID = Request["grademajorID"].ParseStrTo();
int? chargeYearID = Request["chargeYearID"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request["chargeYearID"].ParseStrTo();
var chargeProjectID = Request["chargeProjectID"].ParseStrTo();
//在校状态暂时无效
int? inschoolStatus = Request["inschoolStatus"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request["inschoolStatus"].ParseStrTo();
var dt = ChargeStandardServices.GetGradeMajorStudentChargeViewGrid(grademajorID, chargeYearID, chargeProjectID, inschoolStatus).Select(x => new
{
x.StudentNo,
x.UserName,
x.SexName,
x.ClassName,
x.ChargeYear,
x.ChargeProjectStr,
x.Amount,
x.InSchoolStatusName,
x.Remark
}).ToTable();
string[] liststring = { "学号", "姓名", "性别", "班级名称 ", "缴费学年 ",
"收费项目", "应收金额", "在校状态", "备注" };
neh.Export(dt, liststring, "应收名单明细" + DateTime.Now.ToString("yyyyMMdd"));
return Json(new ReturnMessage()
{
IsSuccess = true,
Message = "导出成功。"
});
}
}
}