stringsql="select a.ClassPlanId,c.TeacherName,c.TeacherHead,d.RoomName,b.StartTime,b.EndTime,a.PlanType,(case a.PlanType when 1 then (select CourseName from rb_course where CourseId=e.CouseId) when 2 then (select func_course_rate(CourseGradeId) from rb_scroll_appointment where ClassPlanId=a.ClassPlanId group by ClassPlanId) END) as CourseName,(case a.PlanType when 1 then (select (Count(0)+1) from rb_class_plan where `status`=0 and ClassId=a.ClassId and TO_Days(ClassDate)<TO_Days(a.ClassDate)) when 2 then (select CourseGradeNo from rb_scroll_appointment where ClassPlanId=a.ClassPlanId group by ClassPlanId) end) as Progress from rb_class_plan a left join rb_class_time b on a.ClassPlanId=b.ClassPlanId left join rb_teacher c on a.TeacherId=c.TId left join rb_class_room d on a.ClassRoomId = d.RoomId left join rb_class e on a.ClassId=e.ClassId where TO_Days(a.ClassDate)=TO_Days(now()) and c.TId is not null and a.`status`=0 and b.EndTime>=DATE_FORMAT(now(),'%H:%i') and a.Group_Id=@gid and a.ClassRoomId=@roomId;";
stringsql="select * from (select a.ClassPlanId,c.TeacherName,b.ClassTimeId,c.TeacherHead,a.TeacherId,d.RoomName,b.StartTime,b.EndTime,a.PlanType,(case a.PlanType when 1 then (select CourseName from rb_course where CourseId=e.CouseId) when 2 then (select func_course_rate(CourseGradeId) from rb_scroll_appointment where ClassPlanId=a.ClassPlanId group by ClassPlanId) END) as CourseName,(case a.PlanType when 1 then (select (Count(0)+1) from rb_class_plan where `status`=0 and ClassId=a.ClassId and TO_Days(ClassDate)<TO_Days(a.ClassDate)) when 2 then (select CourseGradeNo from rb_scroll_appointment where ClassPlanId=a.ClassPlanId group by ClassPlanId) end) as Progress,(case a.PlanType when 1 then (select CourseRate from rb_course where CourseId=e.CouseId) when 2 then (select CourseGradeId from rb_scroll_appointment where ClassPlanId=a.ClassPlanId group by ClassPlanId) END) as CourseRate from rb_class_plan a left join rb_class_time b on a.ClassPlanId=b.ClassPlanId left join rb_teacher c on a.TeacherId=c.TId left join rb_class_room d on a.ClassRoomId = d.RoomId left join rb_class e on a.ClassId=e.ClassId where TO_Days(a.ClassDate)=TO_Days(now()) and c.TId=@tid and a.`status`=0 and b.EndTime>=DATE_FORMAT(now(),'%H:%i') and a.Group_Id=@gid and a.ClassRoomId=@roomId union all select ReserveClassId as ClassPlanId,b.TeacherName,ReserveClassId as ClassTimeId,b.TeacherHead,a.TeacherId,c.RoomName,a.ClassTime as StartTime,a.EndTime,3 as PlanType,a.ClassContent as CourseName,1 as Progress,1 as CourseRate from rb_reserve_class a left join rb_teacher b on a.TeacherId=b.TId left join rb_class_room c on a.ClassRoomId=c.RoomId where TO_Days(a.ClassDate)=TO_Days(now()) and b.TId=@tid and a.EndTime>=DATE_FORMAT(now(),'%H:%i') and a.`Status`=0 and a.Group_Id=@gid and a.ClassRoomId=@roomId) as aa order by aa.StartTime";
stringsql="select c.ClassTimeId,b.GuestName,b.Id,b.Sex from rb_class_plan a left join rb_order_guest b on a.ClassId=b.ClassId left join rb_class_time c on a.ClassPlanId=c.ClassPlanId left join rb_class_check d on c.ClassTimeId=d.ClassTimeId and b.Id=d.OrderGuestId where c.ClassTimeId=@classTimeId and d.ClassCheckId is null and b.GuestState in(1,3,4,6,8,9)";
stringsql="select a.ClassTimeId,e.GuestName,e.Id,e.Sex from rb_class_time a left join rb_scroll_appointment b on a.ClassPlanId=b.ClassPlanId left join rb_student_orderguest c on b.StuId=c.Student_Id left join rb_class_check d on c.GuestId=d.OrderGuestId and a.ClassTimeId = d.ClassTimeId left join rb_order_guest e on c.GuestId=e.Id where a.ClassTimeId=@classTimeId and d.ClassCheckId is null group by b.StuId";