using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using EMIS.ViewModel;
using EMIS.Web.Controls;
using EMIS.CommonLogic.ChargeManage.ChargeSituation;
using Bowin.Web.Controls.Mvc;
using Bowin.Common.Exceptions;
using Bowin.Common.Utility;
using Bowin.Common.Data;
using Bowin.Common.JSON;
using EMIS.ViewModel.ChargeManage.ChargeSituation;
using EMIS.CommonLogic.CalendarManage;
using EMIS.Utility;
namespace EMIS.Web.Controllers.ChargeManage.ChargeSituation
{
[Authorization]
public class StudentChargeController : Controller
{
public IStudentChargeServices StudentChargeServices { 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 chargeTagID = pararms.getExtraInt("DictionaryChargeTag") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryChargeTag");
//在校状态
var inSchoolStatus = pararms.getExtraInt("DictionaryInschoolStatus") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryInschoolStatus");
//是否圆梦计划
var isDream = pararms.getExtraInt("IsDreamDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("IsDreamDropDown");
return base.Json(StudentChargeServices.GetStudentChargeViewGrid(configuretView, collegeID, yearID, standardID, educationID,
learningformID, learnSystem, chargeYearID, chargeProjectID, chargeTagID, inSchoolStatus,
isDream, (int)pararms.page, (int)pararms.rows));
}
///
/// 编辑
///
///
///
[HttpGet]
public ActionResult Edit(Guid? studentChargeID)
{
StudentChargeView studentChargeView = new StudentChargeView();
if (studentChargeID.HasValue && studentChargeID != Guid.Empty)
{
studentChargeView = StudentChargeServices.GetStudentChargeView(studentChargeID);
}
else
{
studentChargeView.ChargeYear = BaseExtensions.GetCurrentYearID();
studentChargeView.ChargeTag = (int)EC_ChargeTag.Normal;
}
return View(studentChargeView);
}
///
/// 编辑(新增、修改)
/// 存在对应的收费标准时,才可新增
/// 业务主键不可修改(业务主键:用户ID、缴费学年、收费项目ID)
///
///
///
[HttpPost]
public ActionResult Edit(StudentChargeView sudentChargeView)
{
try
{
StudentChargeServices.StudentChaegeEdit(sudentChargeView);
return Json(new ReturnMessage()
{
IsSuccess = true,
Message = "保存成功。"
});
}
catch (Exception ex)
{
return Json(new ReturnMessage()
{
IsSuccess = false,
Message = "保存失败,原因:" + ex.Message + "。"
});
}
}
///
/// 查询对应的收费标准应收金额
///
///
///
///
///
[HttpPost]
public ActionResult StudentChargeStandard(Guid? userID, int? chargeYearID, Guid? chargeProjectID)
{
try
{
var result = "";
var chargeStandardView = StudentChargeServices.StudentChargeChargeStandard(userID, chargeYearID, chargeProjectID);
if (chargeStandardView != null)
{
result = chargeStandardView.Amount.ToString();
}
return Json(new ReturnMessage()
{
IsSuccess = true,
Message = result
});
}
catch (Exception ex)
{
return Json(new ReturnMessage()
{
IsSuccess = false,
Message = "数据有误,请核查,原因:" + ex.Message + "。"
});
}
}
///
/// 删除(当选择删除的信息中存在对应的学生缴费信息时,无法删除)
///
///
///
[HttpPost]
public ActionResult Delete(string studentChargeIDs)
{
try
{
List list = new List();
for (int i = 0; i < studentChargeIDs.Split(',').Length; i++)
{
string id = studentChargeIDs.Split(',')[i];
if (!string.IsNullOrEmpty(id))
{
Guid chargeStandardID = new Guid(id);
list.Add(chargeStandardID);
}
}
StudentChargeServices.StudentChargedDelete(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);
}
}
///
/// 费用调整
///
///
[HttpGet]
public ActionResult ChangeActualAmount()
{
return View();
}
///
/// 费用调整
///
///
///
[HttpPost]
public ActionResult ChangeActualAmount(string changeJsonStr)
{
try
{
changeJsonStr = Request.Form["hid_JsonStr"];
string actualAmount = Request.Form["ActualAmount"];
string chargeTag = Request.Form["ChargeTag"];
string remark = Request.Form["Remark"];
var sutdentChargeViewlist = changeJsonStr.JsonToObject>();
StudentChargeServices.UpdateActualAmount(sutdentChargeViewlist, Convert.ToDecimal(actualAmount),
Convert.ToInt32(chargeTag), remark);
return Json(new ReturnMessage()
{
IsSuccess = true,
Message = "保存成功。"
});
}
catch (Exception ex)
{
return Json(new ReturnMessage()
{
IsSuccess = false,
Message = "保存失败,原因:" + ex.Message + "。"
});
}
}
///
/// 缓交申请(同时对相应的缓交信息进行验证)
///
///
///
[HttpGet]
public ActionResult ChargeDelay(Guid? studentChargeID)
{
ChargeDelayView chargeDelayView = new ChargeDelayView();
if (studentChargeID.HasValue && studentChargeID != Guid.Empty)
{
chargeDelayView = StudentChargeServices.GetStudentChargeChargeDelayView(studentChargeID);
}
return View(chargeDelayView);
}
///
/// 缓交申请
///
///
///
[HttpPost]
public ActionResult ChargeDelay(ChargeDelayView chargeDelayView)
{
try
{
StudentChargeServices.ChargeDelay(chargeDelayView);
return Json(new ReturnMessage()
{
IsSuccess = true,
Message = "申请成功。"
});
}
catch (Exception ex)
{
return Json(new ReturnMessage()
{
IsSuccess = false,
Message = "申请失败,原因:" + ex.Message + "。"
});
}
}
///
/// 验证
///
///
///
///
[HttpPost]
public ActionResult Verification(Guid? studentChargeID, Guid? userID, int? chargeYearID, Guid? chargeProjectID)
{
return Json(StudentChargeServices.GetVerification(studentChargeID, userID, 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 chargeYearID = Request.Form["ChargeYearDropDown"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["ChargeYearDropDown"].ParseStrTo();
var chargeProjectID = Request.Form["ChargeProjectComboGrid"].ParseStrTo();
var chargeTagID = Request.Form["DictionaryChargeTag"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryChargeTag"].ParseStrTo();
//在校状态
var inSchoolStatus = Request.Form["DictionaryInschoolStatus"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryInschoolStatus"].ParseStrTo();
//是否圆梦计划
var isDream = Request.Form["IsDreamDropDown"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["IsDreamDropDown"].ParseStrTo();
var dt = StudentChargeServices.GetStudentChargeViewGrid(configuretView, collegeID, yearID, standardID, educationID,
learningFormID, learnSystem, chargeYearID, chargeProjectID, chargeTagID, inSchoolStatus, isDream)
.Select(x => new
{
x.StudentNo,
x.UserName,
x.SexName,
x.ClassNo,
x.ClassName,
x.GradeMajorCode,
x.GradeMajoyStr,
x.CollegeCode,
x.CollegeStr,
x.ChargeYear,
x.ChargeProjectStr,
x.Amount,
x.ChargeAmount,
x.ActualAmount,
x.ChargeTagName,
x.PaidAmount,
x.GradeStr,
x.StandardID,
x.StandardCode,
x.MajorStr,
x.EducationName,
x.LearningformName,
x.LearnSystem,
x.IsDreamProject,
x.InSchoolStatusName,
x.StudentStatusName,
x.Remark
}).ToTable();
string[] liststring = {
"学号", "姓名", "性别", "班级编号", "班级名称", "年级专业编号", "年级专业名称",
RSL.Get("CollegeCode"), RSL.Get("CollegeName"),
"缴费学年", "收费项目", "应收金额", "调整金额", "实收金额", "缴费标记", "已缴金额",
"年级", "专业ID(Value)", "专业代码", "专业名称", RSL.Get("EducationID"), "学习形式",
"学制", "是否圆梦计划", "在校状态", "学籍状态", "备注"
};
neh.Export(dt, liststring, "应收名单信息" + DateTime.Now.ToString("yyyyMMdd"));
return Json(new ReturnMessage()
{
IsSuccess = true,
Message = "导出成功。"
});
}
}
}