Commit 3a77287a authored by 黄奎's avatar 黄奎

页面修改

parent 7f40a18b
......@@ -131,6 +131,11 @@ namespace Edu.Module.Course
bool flag = false;
if (model.ClassId > 0)
{
var oldModel = GetClassModule(model.ClassId);
if (oldModel.Teacher_Id != model.Teacher_Id && model.Teacher_Id > 0 && oldModel.Teacher_Id > 0)
{
class_PlanRepository.UpdatePlanTeacherIdRepository(model.Teacher_Id, model.ClassId);
}
Dictionary<string, object> fileds = new Dictionary<string, object>()
{
{ nameof(RB_Class_ViewModel.ClassName),model.ClassName},
......@@ -157,7 +162,6 @@ namespace Edu.Module.Course
{ nameof(RB_Class_ViewModel.DefaultTimeJson),model.DefaultTimeJson},
{ nameof(RB_Class_ViewModel.DateJson),model.DateJson},
//{ nameof(RB_Class_ViewModel.CompleteProgress),model.CompleteProgress},
//{ nameof(RB_Class_ViewModel.OutRemark),model.OutRemark},
};
flag = classRepository.Update(fileds, new WhereHelper(nameof(RB_Class_ViewModel.ClassId), model.ClassId));
}
......@@ -245,16 +249,66 @@ namespace Edu.Module.Course
}
//班级上课计划列表
List<RB_Class_Plan_ViewModel> classPlanList = CreateClassPlanList(model, defaultPlanTimeList);
model.ClassPlanList = classPlanList;
if (model.ClassPlanList != null && model.ClassPlanList.Count > 0)
{
foreach (var item in model.ClassPlanList)
{
item.ClassPlanId = 0;
if (!class_PlanRepository.CheckExistsRepository(item))
{
//添加班级上课计划
var newClassPlanId = class_PlanRepository.Insert(item);
if (item.PlanTimeList != null && item.PlanTimeList.Count > 0)
{
foreach (var subItem in item.PlanTimeList)
{
subItem.ClassTimeId = 0;
subItem.ClassPlanId = newClassPlanId;
//添加班级上课计划的上课时间
class_TimeRepository.Insert(subItem);
}
}
}
}
}
#endregion
return flag;
}
/// <summary>
/// 生成班级上课计划表
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
private List<RB_Class_Plan_ViewModel> CreateClassPlanList(RB_Class_ViewModel model,List<RB_Class_Time_ViewModel> defaultPlanTimeList)
{
List<RB_Class_Plan_ViewModel> classPlanList = new List<RB_Class_Plan_ViewModel>();
//删除班级计划
double totalMinutes = 0;
foreach (var item in defaultPlanTimeList)
{
var startDate = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd") + " " + item.StartTime+":00");
var endDate = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd") + " " + item.EndTime + ":00");
TimeSpan span = endDate.Subtract(startDate);
if (span.TotalMinutes > 0)
{
totalMinutes += span.TotalMinutes;
}
}
//计算每天课时数
var dayClassHour = totalMinutes / 45.0;
if (dayClassHour > 0)
{
var totalDay = model.ClassHours / dayClassHour;
var srartDate = model.OpenTime;
switch (model.ClassStyle)
{
//按周排课
case Common.Enum.Course.ClassStyleEnum.Week:
if (model.WeekDayList != null && model.WeekDayList.Count > 0)
{
var srartDate = model.OpenTime;
for (var i = 0; i < 120; i++)
int i = 0;
while (classPlanList.Count < totalDay)
{
var newDate = srartDate.AddDays(i);
foreach (var item in model.WeekDayList)
......@@ -375,17 +429,15 @@ namespace Edu.Module.Course
break;
}
}
}
i++;
}
break;
//按月排课
case Common.Enum.Course.ClassStyleEnum.Month:
if (model.WeekDayList != null && model.WeekDayList.Count > 0)
int j = 0;
while (classPlanList.Count < totalDay)
{
var srartDate = model.OpenTime;
for (var i = 0; i < 120; i++)
{
var newDate = srartDate.AddDays(i);
var newDate = srartDate.AddDays(j);
foreach (var item in model.WeekDayList)
{
if (newDate.Day == Convert.ToInt32(item))
......@@ -403,12 +455,11 @@ namespace Edu.Module.Course
});
}
}
}
j++;
}
break;
//固定日期排课
case Common.Enum.Course.ClassStyleEnum.FixedDate:
{
foreach (var item in model.WeekDayList)
{
classPlanList.Add(new RB_Class_Plan_ViewModel()
......@@ -423,34 +474,10 @@ namespace Edu.Module.Course
TeacherId = model.Teacher_Id,
});
}
}
break;
}
model.ClassPlanList = classPlanList;
if (model.ClassPlanList != null && model.ClassPlanList.Count > 0)
{
foreach (var item in model.ClassPlanList)
{
item.ClassPlanId = 0;
if (!class_PlanRepository.CheckExistsRepository(item))
{
//添加班级上课计划
var newClassPlanId = class_PlanRepository.Insert(item);
if (item.PlanTimeList != null && item.PlanTimeList.Count > 0)
{
foreach (var subItem in item.PlanTimeList)
{
subItem.ClassTimeId = 0;
subItem.ClassPlanId = newClassPlanId;
//添加班级上课计划的上课时间
class_TimeRepository.Insert(subItem);
}
}
}
}
}
#endregion
return flag;
return classPlanList;
}
/// <summary>
......@@ -484,6 +511,10 @@ namespace Edu.Module.Course
{
extModel.WeekDayList= Common.Plugin.JsonHelper.DeserializeObject<List<string>>(extModel.DateJson);
}
if (extModel.ClassStyle == Common.Enum.Course.ClassStyleEnum.Month)
{
}
}
return extModel;
}
......
using Edu.Common.Enum;
using Edu.Model.Entity.Course;
using Edu.Model.ViewModel.Course;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
......@@ -73,6 +74,23 @@ WHERE 1=1
return base.Exists(list);
}
/// <summary>
/// 老师改变则修改后面的代课老师为新的教师编号
/// </summary>
/// <param name="TeacherId"></param>
/// <param name="classId"></param>
/// <returns></returns>
public bool UpdatePlanTeacherIdRepository(int TeacherId, int classId)
{
StringBuilder builder = new StringBuilder();
builder.AppendFormat(@"
UPDATE rb_class_plan
SET TeacherId={0}
WHERE ClassId={1} AND ClassDate>'{2}'
", TeacherId, classId, DateTime.Now.ToString("yyyy-MM-dd"));
return base.Execute(builder.ToString()) > 0;
}
/// <summary>
/// 根据班级编号删除班级上课计划
/// </summary>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment