public ActionResult SysSubject(int?id) { ManagerSelect(); if (id == null) { return(View(new ViewModel.ViewSubject())); } var subject = (from sub in db.Dic_Subjects join uvs in db.User_vs_Subjects on sub.sub_id equals uvs.uvs_sub_id into T1 from t1 in T1.DefaultIfEmpty() join u in db.User_Infos on t1.uvs_user_id equals u.user_id into T2 from t2 in T2.DefaultIfEmpty() where sub.sub_id == id select new ViewModel.ViewSubject { id = sub.sub_id, name = sub.sub_name, manager = t1.uvs_user_id, introduce = sub.sub_introduce } ).FirstOrDefault(); if (subject == null) { return(View(new ViewModel.ViewSubject())); } return(View(subject)); }
public ActionResult RollcallList(string courseTime) { if (!User.Identity.IsAuthenticated) { return(RedirectToRoute(new { controller = "Login", action = "Index" })); } int t_id = PageValidate.FilterParam(User.Identity.Name); //从教师ID中查找可点名科目 DateTime minDt = DateTime.Now.AddMinutes(-10); var rc = (from c in db.Course_Infos join cvt in db.Course_vs_Times on c.course_id equals cvt.cvt_course_id join r in db.Sys_ClassRooms on cvt.cvt_room_id equals r.room_id into T1 from t1 in T1.DefaultIfEmpty() join s in db.Dic_Schools on t1.room_school_id equals s.school_id into T2 from t2 in T2.DefaultIfEmpty() where (c.c_teacher_id == t_id || c.c_assistant_id == t_id) && DbFunctions.DiffDays(DateTime.Now, cvt.cvt_time) == 0 && (cvt.cvt_time >= minDt || DbFunctions.AddMinutes(cvt.cvt_time, cvt.cvt_duration) > DateTime.Now) select new RollCallList { id = cvt.cvt_id, name = c.course_name, time = cvt.cvt_time } ); return(View(rc.ToList())); }
public ActionResult SysSubjectList() { List <SelectOption> options; //设置教师下拉列表数据 options = DropDownList.ManagerSelect(); ViewBag.Managers = DropDownList.SetDropDownList(options); var list = (from sub in db.Dic_Subjects join uvs in db.User_vs_Subjects on sub.sub_id equals uvs.uvs_sub_id into T1 from t1 in T1.DefaultIfEmpty() join u in db.User_Infos on t1.uvs_user_id equals u.user_id into T2 from t2 in T2.DefaultIfEmpty() where sub.delete_flag == 0 select new ViewModel.ViewSubject { id = sub.sub_id, name = sub.sub_name, manager_name = t2.user_name } ).ToList(); return(View(list)); }
public ActionResult Index(BasePagerModel pager) { if (!User.Identity.IsAuthenticated) { return(RedirectToRoute(new { controller = "Login", action = "LogOut" })); } int uid = PageValidate.FilterParam(User.Identity.Name); if (!RoleCheck.CheckHasAuthority(uid, db, "用户管理")) { return(RedirectToRoute(new { controller = "Error", action = "Index", err = "没有权限。" })); } if (pager == null) { pager = new BasePagerModel(); } ViewData["search"] = pager; var list = (from user in db.User_Info join uvr in db.User_vs_Role on user.user_id equals uvr.uvr_user_id into T1 from t1 in T1.DefaultIfEmpty() join role in db.Dic_Role on t1.uvr_role_id equals role.role_id into T2 from t2 in T2.DefaultIfEmpty() join ue in db.User_Extend on user.user_id equals ue.user_id into T3 from t3 in T3.DefaultIfEmpty() join dept in db.Dic_Department on t3.user_dept_id equals dept.dept_id into T4 from t4 in T4.DefaultIfEmpty() join post in db.Dic_Post on t3.user_post_id equals post.post_id into T5 from t5 in T5.DefaultIfEmpty() orderby user.user_id ascending select new UserListModel { id = user.user_id, name = user.user_name, roleName = t2.role_name == null?"":t2.role_name, stateTxt = user.user_state == 1 ? "正常" : (user.user_state == 2 ? "锁定" : (user.user_state == 0 ? "未启用" : "未知")), realName = user.real_name, times = user.user_login_times, deptName = t4.dept_name == null?"":t4.dept_name, postName = t5.post_name == null?"":t5.post_name, picture = t3.user_picture == null?"default.jpg":t3.user_picture, loginTimes = user.user_login_times }).Skip((pager.PageIndex - 1) * pager.PageSize).Take(pager.PageSize).ToList(); foreach (var item in list) { item.realName = Common.DEncrypt.AESEncrypt.Decrypt(item.realName); } return(View(list)); }
List <TeacherCourse> getTeacherCourse(TeacherSearch model) { var courses = (from c in db.Course_Infos join a in db.User_Infos on c.c_assistant_id equals a.user_id into T1 from t1 in T1.DefaultIfEmpty() join s in db.Dic_Subjects on c.c_sub_id equals s.sub_id join se in db.Course_Seasons on c.c_cs_id equals se.c_season_id join room in db.Sys_ClassRooms on c.c_room equals room.room_id into T2 from t2 in T2.DefaultIfEmpty() join school in db.Sys_Schools on t2.room_school_id equals school.sys_school_id into T3 from t3 in T3.DefaultIfEmpty() where (c.c_teacher_id == model.id || c.c_assistant_id == model.id) && (se.c_is_used == model.isAll ? se.c_is_used : true) orderby new { se.c_is_used, se.c_season_id, c.c_sub_id } select new TeacherCourse { name = c.course_name, assistantName = t1.user_name, subjectName = s.sub_name, timeInfo = c.c_time_info == null ? "" : c.c_time_info, stunum = db.Student_vs_Courses.Where(x => x.svc_course_id == c.course_id).Count(), roomName = t2.room_name == null ? "" : t2.room_name, schoolName = t3.sys_school_name == null ? "" : t3.sys_school_name, c_is_used = se.c_is_used, season = se.c_season_id, subject = c.c_sub_id }).ToList(); if (courses.Count() == 0) { return(null); } foreach (var course in courses) { DateTime min = DateTime.Now.AddMinutes(-10); DateTime max = DateTime.Now.AddMinutes(120); var cvt = db.Course_vs_Times.Where(x => x.cvt_course_id == course.id && x.cvt_time >= min && x.cvt_time <= max).FirstOrDefault(); if (cvt != null) { course.cvt = cvt.cvt_id; } else { course.cvt = 0; } } return(courses); }
List <ApplyListModel> getResponseDetail(int userId, params int[] state) { if (!User.Identity.IsAuthenticated) { return(new List <ApplyListModel>()); } int uid = PageValidate.FilterParam(User.Identity.Name); ApplyManager dal = new ApplyManager(db); var query = from bill in db.Reimbursement join pr in db.Process_Respond on new { code = bill.reimbursement_code, id = uid } equals new{ code = pr.pr_reimbursement_code, id = pr.pr_user_id } into T1 from respond in T1.DefaultIfEmpty() join res in db.Dic_Respond_State on respond.pr_state equals res.drs_state_id into T2 from resSt in T2.DefaultIfEmpty() join user in db.User_Info on bill.r_add_user_id equals user.user_id join s in db.Dic_Respond_State on bill.r_bill_state equals s.drs_state_id join f in db.Funds on bill.r_funds_id equals f.f_id where state.Contains(bill.r_bill_state) orderby bill.r_add_date descending select new ApplyListModel { amount = bill.r_bill_amount, reimbursementCode = bill.reimbursement_code, state = bill.r_bill_state, strState = s.drs_state_name, time = bill.r_add_date, fundsCode = f.f_code, fundsName = f.f_name, userName = user.real_name, info = bill.reimbursement_info, userId = bill.r_add_user_id, manager = respond.pr_user_id, myRespond = resSt.drs_state_name }; if (userId > 0) { query = query.Where(x => x.manager == userId); } var list = query.ToList(); if (list != null) { foreach (var item in list) { item.attachmentsCount = dal.getAttachments(item.reimbursementCode, 0).Count(); item.contents = dal.getContents(item.reimbursementCode, 0).ToList(); item.userName = AESEncrypt.Decrypt(item.userName); } } return(list); }
// GET: Student/Details/5 public ActionResult Details(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ViewModel.StudentDetail detail = new ViewModel.StudentDetail(); ViewModel.StudentsModel student_Info = (from stus in db.Student_Infos join school in db.Dic_Schools on stus.stu_school_id equals school.school_id into T1 from t1 in T1.DefaultIfEmpty() join grade in db.Dic_Grades on stus.stu_grade_id equals grade.grade_id into T2 from t2 in T2.DefaultIfEmpty() where stus.stu_id == id select new ViewModel.StudentsModel { address = stus.stu_home_address, birthday = stus.stu_birthday, cardType = stus.stu_card_type, email = stus.stu_email, grade = stus.stu_grade_id, id = stus.stu_id, IdCard = stus.stu_idCard, name = stus.stu_name, phone = stus.stu_phone, photo = stus.stu_photo_path, school = stus.stu_school_id, sex = stus.stu_sex, school_name = t1.school_name == null ? "" : t1.school_name, grade_name = t2.grade_name == null ? "" : t2.grade_name }).FirstOrDefault(); if (student_Info == null) { ViewBag.msg = "没有找到学生信息。"; return(View(student_Info)); } detail.student_Info = student_Info; var stu_courses = from svc in db.Student_vs_Courses join course in db.Course_Infos on svc.svc_course_id equals course.course_id join sub in db.Dic_Subjects on course.c_sub_id equals sub.sub_id join season in db.Course_Seasons on course.c_cs_id equals season.c_season_id where svc.svc_stu_id == id orderby svc.svc_add_time select new ViewModel.StudnentCourse { student = id, course = svc.svc_course_id, course_name = course.course_name, season = season.c_season_name, state = svc.svc_is_end ? "完结" : "进行中", subject = sub.sub_name, time = course.c_time_info }; detail.stu_courses = stu_courses.ToList(); return(View(detail)); }
List <CourseModel> SearchCourse(PageInfo pageInfo) { CreateSelect(); var courses = (from c in db.Course_Infos join r in db.Sys_ClassRooms on c.c_room equals r.room_id into T1 from t1 in T1.DefaultIfEmpty() join s in db.Sys_Schools on t1.room_school_id equals s.sys_school_id into T2 from t2 in T2.DefaultIfEmpty() join ty in db.Dic_Course_Types on c.c_type_id equals ty.ct_id into T3 from t3 in T3.DefaultIfEmpty() join tea in db.User_Infos on c.c_teacher_id equals tea.user_id into T4 from t4 in T4.DefaultIfEmpty() join ass in db.User_Infos on c.c_assistant_id equals ass.user_id into T5 from t5 in T5.DefaultIfEmpty() join season in db.Course_Seasons on c.c_cs_id equals season.c_season_id into T6 from t6 in T6.DefaultIfEmpty() join sub in db.Dic_Subjects on c.c_sub_id equals sub.sub_id into T7 from t7 in T7.DefaultIfEmpty() where t1.room_school_id == (pageInfo.school == 0 ? t1.room_school_id : pageInfo.school) orderby new { c.c_cs_id, c.c_sub_id, c.course_name } select new CourseModel { id = c.course_id, assistantName = t5.user_name, cost = c.course_cost, introduce = c.course_introduce, max = c.course_max_num, name = c.course_name, room = c.c_room, roomName = t1.room_id == 0 ? "" : t2.sys_school_name + t1.room_name, season = c.c_cs_id, seasonName = t6.c_season_name, subject = c.c_sub_id, subjectName = t7.sub_name, teacher = c.c_teacher_id, teacherName = t4.user_name, type = c.c_type_id, typeName = t3.ct_name, timeInfo = c.c_time_info }); //.Skip(pagesize*(pageindex-1)).Take(pagesize).ToList(); if (pageInfo.room != 0) { courses = courses.Where(x => x.room == pageInfo.room); } if (pageInfo.season != 0) { courses = courses.Where(x => x.season == pageInfo.season); } if (pageInfo.subject != 0) { courses = courses.Where(x => x.subject == pageInfo.subject); } if (pageInfo.teacher != 0) { courses = courses.Where(x => x.teacher == pageInfo.teacher); } if (pageInfo.type != 0) { courses = courses.Where(x => x.type == pageInfo.type); } if (!string.IsNullOrEmpty(pageInfo.keyword)) { courses = courses.Where(x => x.name.Contains(pageInfo.keyword)); } pageInfo.count = courses.Count(); if (pageInfo.pagesize == 0) { pageInfo.pagesize = 10; } if (pageInfo.pageindex == 0) { pageInfo.pageindex = 1; } pageInfo.pages = (int)Math.Ceiling((decimal)pageInfo.count / pageInfo.pagesize); ViewData["search"] = pageInfo; var list = courses.Skip(pageInfo.pagesize * (pageInfo.pageindex - 1)).Take(pageInfo.pagesize).ToList(); foreach (var course in list) { var time = (from cvt in db.Course_vs_Times where cvt.cvt_course_id == course.id orderby cvt.cvt_time ascending select cvt.cvt_time ).FirstOrDefault(); course.beginDate = time; } return(list); }
// GET: Course/Edit/5 public ActionResult Edit(int?id) { CreateSelect(); if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CourseModel course = (from c in db.Course_Infos join r in db.Sys_ClassRooms on c.c_room equals r.room_id into T1 from t1 in T1.DefaultIfEmpty() join s in db.Sys_Schools on t1.room_school_id equals s.sys_school_id into T2 from t2 in T2.DefaultIfEmpty() where c.course_id == id select new CourseModel { id = c.course_id, assistant = c.c_assistant_id, cost = c.course_cost, introduce = c.course_introduce, max = c.course_max_num, name = c.course_name, room = t1.room_id, season = (int)c.c_cs_id, subject = c.c_sub_id, teacher = c.c_teacher_id, type = c.c_type_id, school = t2.sys_school_id }).FirstOrDefault(); if (course == null) { return(HttpNotFound()); } var group = from cvt in db.Course_vs_Times where cvt.cvt_course_id == id group cvt by new { cvt.cvt_course_id, cvt.cvt_group } into g select new { Key = g.Key, Count = g.Count() }; if (group != null && group.Count() > 0) { course.ListTimes = new List <ListTime>(); foreach (var g in group) { var top = (from cvt in db.Course_vs_Times where cvt.cvt_course_id == g.Key.cvt_course_id && cvt.cvt_group == g.Key.cvt_group orderby cvt.cvt_time ascending select new ListTime { day = (int)cvt.cvt_dayofweek, lessonTime = cvt.cvt_time.ToString(), lastlong = cvt.cvt_duration, count = g.Count, cgroup = (int)cvt.cvt_group }).FirstOrDefault(); if (top != null) { var list = from cvt in db.Course_vs_Times join r in db.Sys_ClassRooms on cvt.cvt_room_id equals r.room_id into T1 from t1 in T1.DefaultIfEmpty() join s in db.Sys_Schools on t1.room_school_id equals s.sys_school_id into T2 from t2 in T2.DefaultIfEmpty() join st in db.Dic_Course_States on cvt.cvt_state equals st.cstate_id into T3 from t3 in T3.DefaultIfEmpty() where cvt.cvt_course_id == g.Key.cvt_course_id && cvt.cvt_group == g.Key.cvt_group orderby cvt.cvt_time ascending select new ListDetailTime { id = cvt.cvt_id, time = cvt.cvt_time, timeStr = cvt.cvt_time.ToString(), info = cvt.cvt_info, state = cvt.cvt_state, isextra = cvt.cvt_is_extra, room = t1.room_id, school = t2.sys_school_id, stateName = t3.cstate_name }; top.times = list.ToList(); if (course.beginDate.Ticks == 0) { course.beginDate = list.First().time; } else if (course.beginDate > list.First().time) { course.beginDate = list.First().time; } } course.ListTimes.Add(top); } } else { return(View(course)); } var csts = from cst in db.Course_SuspendTimes join c in db.Course_Infos on cst.cst_course_id equals c.course_id where c.course_id == id select cst.cst_suspend_time; course.SuspendDays = csts.ToArray(); return(View(course)); }
// GET: Teacher/Edit/5 public ActionResult Edit(int?id) { setSelect(); if (!User.Identity.IsAuthenticated) { return(RedirectToRoute(new { controller = "Login", action = "LogOut" })); } if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } int userid = PageValidate.FilterParam(User.Identity.Name); if (id == null) { return(View()); } if (!RoleCheck.CheckHasAuthority(userid, db, "用户管理") && id != userid) { return(RedirectToRoute(new { controller = "Error", action = "Index", err = "没有权限。" })); } TeacherEditModel model = (from user in db.User_Infos where user.user_id == id join u1 in db.User_Infos on user.user_add_user equals u1.user_id into T1 from t1 in T1.DefaultIfEmpty() join u2 in db.User_Infos on user.user_update_user equals u2.user_id into T2 from t2 in T2.DefaultIfEmpty() join uvr in db.User_vs_Roles on user.user_id equals uvr.uvr_user_id into R from r in R.DefaultIfEmpty() select new TeacherEditModel { user_add_time = user.user_add_time, user_add_user = t1.user_name, user_email = user.user_email, user_home_address = user.user_home_address, user_id = user.user_id, user_info = user.user_info, user_login_times = user.user_login_times, user_name = user.user_name, user_phone = user.user_phone, user_update_time = user.user_update_time, user_update_user = t2.user_name, user_photo_path = user.user_photo_path, role_id = r.uvr_role_id, real_name = user.real_name, gender = user.user_gender }).FirstOrDefault(); if (model == null) { return(HttpNotFound()); } string token = TokenProccessor.getInstance().makeToken(); model.token = token; Session["token"] = token; return(View(model)); }