using Learun.Util;
using System.Data;
using Learun.Application.TwoDevelopment.EducationalAdministration;
using System.Web.Mvc;
using System.Collections.Generic;
using System.Linq;
namespace Learun.Application.Web.Areas.EducationalAdministration.Controllers
{
///
/// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园
/// Copyright (c) 2013-2018 北京泉江科技有限公司
/// 创 建:超级管理员
/// 日 期:2019-05-15 10:33
/// 描 述:选修课课程
///
public class StuSelectLessonListOfElectivePreController : MvcControllerBase
{
private StuSelectLessonListOfElectivePreIBLL stuSelectLessonListOfElectivePreIBLL = new StuSelectLessonListOfElectivePreBLL();
private OpenLessonPlanOfElectiveIBLL openLessonPlanOfElectiveIBLL = new OpenLessonPlanOfElectiveBLL();
#region 视图功能
///
/// 主页面
///
///
[HttpGet]
public ActionResult Index()
{
return View();
}
[HttpGet]
public ActionResult QueryStuSelectResult()
{
return View();
}
///
/// 教务-审核表单页
///
///
[HttpGet]
public ActionResult AuditForm()
{
return View();
}
///
/// 教务-审核页面
///
///
[HttpGet]
public ActionResult AuditIndex()
{
return View();
}
///
/// 教务-报名结果页面
///
///
[HttpGet]
public ActionResult FinishIndex()
{
return View();
}
#endregion
#region 获取数据
///
/// 获取页面显示列表数据
///
/// 查询参数
///
[HttpGet]
[AjaxOnly]
public ActionResult GetPageList(string pagination, string queryJson)
{
Pagination paginationobj = pagination.ToObject();
var data = stuSelectLessonListOfElectivePreIBLL.GetPageList(paginationobj, queryJson);
var jsonData = new
{
rows = data,
total = paginationobj.total,
page = paginationobj.page,
records = paginationobj.records
};
return Success(jsonData);
}
[HttpGet]
[AjaxOnly]
public ActionResult GetQueryStuSelectResultList(string pagination, string queryJson)
{
Pagination paginationobj = pagination.ToObject();
var data = stuSelectLessonListOfElectivePreIBLL.GetQueryStuSelectResultList(paginationobj, queryJson);
var jsonData = new
{
rows = data,
total = paginationobj.total,
page = paginationobj.page,
records = paginationobj.records
};
return Success(jsonData);
}
///
/// 获取表单数据
///
///
[HttpGet]
[AjaxOnly]
public ActionResult GetFormData(string keyValue)
{
var StuSelectLessonListOfElectivePreData = stuSelectLessonListOfElectivePreIBLL.GetStuSelectLessonListOfElectivePreEntity(keyValue);
var jsonData = new
{
StuSelectLessonListOfElectivePre = StuSelectLessonListOfElectivePreData,
};
return Success(jsonData);
}
#endregion
#region 提交数据
///
/// 删除实体数据
/// 主键
///
///
[HttpPost]
[AjaxOnly]
public ActionResult DeleteForm(string keyValue)
{
stuSelectLessonListOfElectivePreIBLL.DeleteEntity(keyValue);
return Success("删除成功!");
}
[HttpPost]
[AjaxOnly]
public ActionResult Pass(string keyValue, string OLPEId)
{
var stulist = keyValue.Split(',');
var olpentity = openLessonPlanOfElectiveIBLL.GetOpenLessonPlanOfElectiveEntity(OLPEId);
if (olpentity != null)
{
var bb = stuSelectLessonListOfElectivePreIBLL.GetStuSelectLessonListOfElectivePreListByOLPEId(olpentity.Id);
var bbb = bb.Where(x => x.Status == 2).Count();
if (bbb + stulist.Length > olpentity.StuNumMax)
{
return Fail("当前选课人数已超出限制,请减少审批量!");
}
//if (olpentity.StuNum + stulist.Length > olpentity.StuNumMax)
//{
// return Fail("当前选课人数已超出限制,请减少审批量!");
//}
else
{
stuSelectLessonListOfElectivePreIBLL.Pass(stulist, olpentity);
}
}
else
{
return Fail("当前选课数据不存在!");
}
return Success("操作成功!");
}
[HttpPost]
[AjaxOnly]
public ActionResult UnPass(string keyValue, string OLPEId)
{
var stulist = keyValue.Split(',');
var olpentity = openLessonPlanOfElectiveIBLL.GetOpenLessonPlanOfElectiveEntity(OLPEId);
if (olpentity != null)
{
stuSelectLessonListOfElectivePreIBLL.UnPass(stulist, olpentity);
}
else
{
return Fail("当前选课数据不存在!");
}
return Success("操作成功!");
}
///
/// 保存实体数据(新增、修改)
/// 主键
///
///
[HttpPost]
[ValidateAntiForgeryToken]
[AjaxOnly]
public ActionResult SaveForm(string keyValue, string strEntity)
{
var sslleEntity = stuSelectLessonListOfElectivePreIBLL.GetStuSelectLessonListOfElectivePreEntity(keyValue);
if (sslleEntity == null)
{
return Fail("当前选课数据不存在!");
}
var olpeEntity = openLessonPlanOfElectiveIBLL.GetOpenLessonPlanOfElectiveEntity(sslleEntity.OLPEId);
if (olpeEntity == null)
{
return Fail("当前选课的课程不存在!");
}
StuSelectLessonListOfElectivePreEntity entity = strEntity.ToObject();
var aa = entity.Status;
if (aa == 1)//是
{
//判断选课的课程的报名人数是否已满
//if (olpeEntity.StuNum >= olpeEntity.StuNumMax)
//{
// return Fail("当前选课的课程人数已满!");
//}
var bb = stuSelectLessonListOfElectivePreIBLL.GetStuSelectLessonListOfElectivePreListByOLPEId(olpeEntity.Id);
var bbb = bb.Where(x => x.Status == 2).Count();
if (bbb >= olpeEntity.StuNumMax)
{
return Fail("当前选课的课程人数已满!");
}
//选课的课程报名人数加1
//olpeEntity.StuNum = olpeEntity.StuNum + 1;
//openLessonPlanOfElectiveIBLL.SaveEntity(olpeEntity.Id, olpeEntity);
//报名成功
sslleEntity.Status = 2;
sslleEntity.Remark = entity.Remark;
}
else
{
//报名失败
sslleEntity.Status = 3;
sslleEntity.Remark = entity.Remark;
}
stuSelectLessonListOfElectivePreIBLL.SaveEntity(keyValue, sslleEntity);
return Success("保存成功!");
}
#endregion
}
}