public static JsonModelNum GetCourseInfoHelper(int PageIndex, int PageSize, int SectionId, string Key, string CourseTypeID) { JsonModelNum jsm = new JsonModelNum(); int intSuccess = (int)errNum.Success; try { List <Course> Course_List = Constant.Course_List; List <CourseRel> CourseRel_List = Constant.CourseRel_List; DictionType_Enum dictiontype = DictionType_Enum.Course_Type; List <Sys_Dictionary> Sys_Dictionary_List = Constant.Sys_Dictionary_List; string dictiontypevalue = Convert.ToString((int)dictiontype); var courrel = (from CourseRel_ in CourseRel_List where CourseRel_.StudySection_Id == SectionId && CourseRel_.CourseType_Id == CourseTypeID join Sys_Dictionary_ in Sys_Dictionary_List.Where(i => i.Type == dictiontypevalue) on CourseRel_.CourseType_Id equals Sys_Dictionary_.Key where Sys_Dictionary_.SectionId == SectionId select new { CourseRel_.CourseType_Id, CourseRel_.Course_Id, Sys_Dictionary_.Value, Sys_Dictionary_.IsEnable, CourseRelID = CourseRel_.Id }).ToList(); var query = (from Course_ in Course_List where Course_.Name.Contains(Key) || Course_.UniqueNo.Contains(Key) join cr in courrel on Course_.UniqueNo equals cr.Course_Id orderby Course_.IsEnable select new { Course_Id = Course_.Id, //课程名称 Course_Name = Course_.Name, //课程编号 Course_No = Course_.UniqueNo, //课程分类id CourseRel_Id = cr == null ? "" : cr.CourseType_Id, CourseRel_Name = (cr == null ? "未分类" : cr.Value), CourseRelID = cr == null ? 0 : cr.CourseRelID, Course_.IsEnable, DepartMentID = Course_.DepartMentID, DepartmentName = Course_.DepartmentName, SubDepartmentID = Course_.SubDepartmentID, SubDepartmentName = Course_.SubDepartmentName, CourseProperty = Course_.CourseProperty, }).ToList(); var query_last = (from an in query select an).Skip((PageIndex - 1) * PageSize).Take(PageSize).ToList(); //jsm = JsonModel.get_jsonmodel(intSuccess, "success", query_last); //返回所有表格数据 jsm = JsonModelNum.GetJsonModel_o(intSuccess, "success", query_last); jsm.PageIndex = PageIndex; jsm.PageSize = PageSize; jsm.PageCount = (int)Math.Ceiling((double)query.Count() / PageSize); jsm.RowCount = query.Count(); } catch (Exception ex) { LogHelper.Error(ex); } return(jsm); }
public static JsonModelNum GetCourseInfoHelper(int PageIndex, int PageSize, int SectionId, string Key, string CourseTypeID) { JsonModelNum jsm = new JsonModelNum(); DictionType_Enum dictiontype = DictionType_Enum.Course_Type; int intSuccess = (int)errNum.Success; try { List <Course> Course_List = Constant.Course_List; List <CourseRoom> CourseRoom_List = Constant.CourseRoom_List.Distinct(new CourseRoomCompare()).ToList(); List <CourseRel> CourseRel_List = Constant.CourseRel_List; List <Sys_Dictionary> Sys_Dictionary_List = Constant.Sys_Dictionary_List; string dictiontypevalue = Convert.ToString((int)dictiontype); var courrel = (from CourseRel_ in CourseRel_List where CourseRel_.StudySection_Id == SectionId join Sys_Dictionary_ in Sys_Dictionary_List.Where(i => i.Type == dictiontypevalue) on CourseRel_.CourseType_Id equals Sys_Dictionary_.Key where Sys_Dictionary_.SectionId == SectionId select new { CourseRel_.CourseType_Id, CourseRel_.Course_Id, Sys_Dictionary_.Value, Sys_Dictionary_.IsEnable, CourseRelID = CourseRel_.Id, }).ToList(); if (CourseTypeID != "-1" && CourseTypeID != "null") //课程分类不是全部和未分类 { courrel = (from c in courrel where c.CourseType_Id == CourseTypeID select c).ToList(); } var query = (from Course_ in Course_List join room in CourseRoom_List on Course_.UniqueNo equals room.Coures_Id where room.StudySection_Id == SectionId join cr_ in courrel on Course_.UniqueNo equals cr_.Course_Id into crlist from cr in crlist.DefaultIfEmpty() orderby Course_.IsEnable select new { Course_Id = Course_.Id, //课程名称 Course_Name = Course_.Name, //课程编号 Course_No = Course_.UniqueNo, //课程分类id CourseRel_Id = cr == null ? "" : cr.CourseType_Id, CourseRel_Name = (cr == null ? "未分类" : cr.Value), PkType = Course_.PkType, Course_.TaskProperty, CourseRelID = cr == null ? 0 : cr.CourseRelID, Course_.IsEnable, DepartMentID = Course_.DepartMentID, DepartmentName = Course_.DepartmentName, SubDepartmentID = Course_.SubDepartmentID, SubDepartmentName = Course_.SubDepartmentName, CourseProperty = Course_.CourseProperty, }).ToList(); if (CourseTypeID != "-1") //不是全部 { if (CourseTypeID == "null") //未分类 { query = (from q in query where q.CourseRel_Id == "" select q).ToList(); } else //其他类别 { query = (from q in query where q.CourseRel_Id != "" select q).ToList(); } } if (Key != "") { query = (from qu in query where qu.Course_Name.Contains(Key) || qu.Course_No.Contains(Key) select qu).ToList(); } var query_last = (from an in query select an).Skip((PageIndex - 1) * PageSize).Take(PageSize).ToList(); //返回所有表格数据 jsm = JsonModelNum.GetJsonModel_o(intSuccess, "success", query_last); jsm.PageIndex = PageIndex; jsm.PageSize = PageSize; jsm.PageCount = (int)Math.Ceiling((double)query.Count() / PageSize); jsm.RowCount = query.Count(); } catch (Exception ex) { LogHelper.Error(ex); } return(jsm); }
public static JsonModel GetCourseInfo_SelectHelper(int SectionId) { JsonModel jsm = new JsonModel(); int intSuccess = (int)errNum.Success; try { List <Course> Course_List = Constant.Course_List; List <CourseRoom> CourseRoom_List = Constant.CourseRoom_List.Distinct(new CourseRoomCompare()).ToList(); List <CourseRel> CourseRel_List = Constant.CourseRel_List; DictionType_Enum dictiontype = DictionType_Enum.Course_Type; List <Sys_Dictionary> Sys_Dictionary_List = Constant.Sys_Dictionary_List; string dictiontypevalue = Convert.ToString((int)dictiontype); var courrel = (from CourseRel_ in CourseRel_List //where CourseRel_.StudySection_Id == SectionId join Sys_Dictionary_ in Sys_Dictionary_List.Where(i => i.Type == dictiontypevalue) on CourseRel_.CourseType_Id equals Sys_Dictionary_.Key select new { SectionId, CourseRel_.CourseType_Id, CourseRel_.Course_Id, Sys_Dictionary_.Value, Sys_Dictionary_.IsEnable, CourseRelID = CourseRel_.Id }).ToList(); if (SectionId > 0) { courrel = (from c in courrel where c.SectionId == SectionId select c).ToList(); } var query = (from Course_ in Course_List join room in CourseRoom_List on Course_.UniqueNo equals room.Coures_Id where room.StudySection_Id == SectionId join cr in courrel on Course_.UniqueNo equals cr.Course_Id orderby Course_.IsEnable select new { Course_Id = Course_.Id, //课程名称 Course_Name = Course_.Name, //课程编号 Course_No = Course_.UniqueNo, //课程分类id CourseRel_Id = cr == null ? "" : cr.CourseType_Id, CourseRel_Name = (cr == null ? "未分类" : cr.Value), PkType = Course_.PkType, TaskProperty = Course_.TaskProperty, CourseRelID = cr == null ? 0 : cr.CourseRelID, Course_.IsEnable, DepartMentID = Course_.DepartMentID, DepartmentName = Course_.DepartmentName, SubDepartmentID = Course_.SubDepartmentID, SubDepartmentName = Course_.SubDepartmentName, CourseProperty = Course_.CourseProperty, }).ToList(); var data = new { PkList = (from q in query select q.PkType).Distinct().ToList(), TKList = (from q in query select q.TaskProperty).Distinct().ToList(), CPList = (from q in query select q.CourseProperty).Distinct().ToList(), CNList = (from q in query select new { CourseID = q.Course_Id, CourseName = q.Course_Name }).Distinct().ToList(), DPList = (from q in query select new DepartmentSelect() { DepartMentID = q.DepartMentID, DepartmentName = q.DepartmentName }).Distinct(new DepartmentSelectComparer()).ToList(), SDPList = (from q in query select new DepartmentSelect() { DepartMentID = q.SubDepartmentID, DepartmentName = q.SubDepartmentName }).Distinct(new DepartmentSelectComparer()).ToList(), }; //返回所有表格数据 jsm = JsonModel.get_jsonmodel(intSuccess, "success", data); } catch (Exception ex) { LogHelper.Error(ex); } return(jsm); }
/// <summary> ///获取课程类型 /// </summary> public void GetCourse_Type(HttpContext context) { int intSuccess = (int)errNum.Success; HttpRequest Request = context.Request; //课程类型 DictionType_Enum dictiontype = DictionType_Enum.Course_Type; int SectionId = RequestHelper.int_transfer(Request, "SectionId"); try { bool HasSection = RequestHelper.bool_transfer(Request, "HasSection"); var list = (from dic in Constant.Sys_Dictionary_List join section in Constant.StudySection_List on dic.SectionId equals section.Id where dic.Type == Convert.ToString((int)dictiontype) && dic.SectionId == section.Id orderby section.EndTime descending select new CourseSection() { SectionId = dic.SectionId, Sort = dic.Sort, Type = dic.Type, Value = dic.Value, DisPlayName = section.DisPlayName, CreateTime = section.CreateTime, StartTime = section.StartTime, EndTime = section.EndTime, Id = dic.Id, Key = dic.Key, Pid = dic.Pid, Study_IsEnable = section.IsEnable, IsEnable = dic.IsEnable, State = "", ReguState = 0, }).ToList(); //带学年学期的课程 if (HasSection) { if (SectionId > 0) { list = (from li in list where li.SectionId == SectionId select li).ToList(); } } else { StudySection section = Constant.StudySection_List.FirstOrDefault(item => item.IsEnable == 0); if (section != null) { list = (from li in list where section.Id == li.SectionId select li).ToList(); } } ReguState regustate = ReguState.进行中; foreach (var li in list) { if (li.StartTime < DateTime.Now && li.EndTime >= DateTime.Now) { regustate = ReguState.进行中; } else if (li.StartTime > DateTime.Now) { regustate = ReguState.未开始; } else { regustate = ReguState.已结束; } li.State = Convert.ToString(regustate); li.ReguState = (int)regustate; } //返回所有表格数据 jsonModel = JsonModel.get_jsonmodel(intSuccess, "success", list); } catch (Exception ex) { LogHelper.Error(ex); } finally { //无论后端出现什么问题,都要给前端有个通知【为防止jsonModel 为空 ,全局字段 jsonModel 特意声明之后进行初始化】 context.Response.Write("{\"result\":" + Constant.jss.Serialize(jsonModel) + "}"); } }