//王一情 public string GetCourseTask(int userid, int userlevel) { T_Base_Teacher teacher = new T_Base_Teacher(); DALT_Base_Teacher dal_Teacher = new DALT_Base_Teacher(); teacher = dal_Teacher.GetModel(userid); DALT_Event_CourseTask dal = new DALT_Event_CourseTask(); List <T_Event_CourseTask> list = new List <T_Event_CourseTask>(); if (userlevel != 10 && userlevel != 11) { list = dal.GetStuCourseList(userid); } else { list = dal.GetTeaCourseList("WPeople=" + "'" + teacher.Name + "'"); } string res = ""; foreach (T_Event_CourseTask item in list) { T_Task_Course course = new T_Task_Course(); DALT_Task_Course dal_course = new DALT_Task_Course(); course = dal_course.GetModel(item.CourseId); string st_date = ((DateTime)item.StartWeek).ToString("yyyy-MM-dd"); string st = st_date + " " + item.StartTime; string ed = st_date + " " + item.EndTime; res += "{\"id\":\"" + item.Id + "\",\"title\":\"" + course.Name + "\",\"type\":\"" + item.Type + "\",\"des\":\"" + item.Description + "\",\"start\":\"" + st + "\",\"end\":\"" + ed + "\"}"; res += ","; } return(res); }
//王一情,并且把那个GetCourseTask放到了其他地方 public int AddCourseTask(int type, string des, DateTime start, DateTime end, int taskalert, DateTime start_date, int week_type, int week_number, int userid, int choose_course) { T_Base_Teacher teacher = new T_Base_Teacher(); DALT_Base_Teacher dal_teacher = new DALT_Base_Teacher(); //王一情 teacher = dal_teacher.GetModel(userid); T_Event_CourseTask model = new T_Event_CourseTask(); model.Type = type; model.IsAlert = taskalert; model.CourseId = choose_course; model.Description = des; model.EndTime = end.ToLongTimeString().ToString(); model.StartTime = start.ToLongTimeString().ToString(); model.StartWeek = start_date; model.State = 0; model.WeekNum = week_number; model.WeekType = week_type; model.WPeople = teacher.Name; DALT_Event_CourseTask dal = new DALT_Event_CourseTask(); //循环添加课程日程 int result = 0; if (model.WeekNum == 1) { result = dal.Add(model); } //如果有循环的话 else if (model.WeekNum > 1) { for (int i = 1; i <= model.WeekNum; i++) { //如果不分单双周 if (model.WeekType == 0) { result = dal.Add(model); model.StartWeek = start_date.AddDays(7 * i); } //如果单周 else if (model.WeekType == 1) { result = dal.Add(model); model.StartWeek = start_date.AddDays(14 * i); } //如果双周 else if (model.WeekType == 2) { model.StartWeek = start_date.AddDays(14 * (i - 1) + 7); result = dal.Add(model); } } } if (result > 0) { return(2); } return(0); }