public static void ShareCalendar(ClassCalendar calendar, ISqlCalendar sql) { int Year = calendar.Year; int Month = calendar.Month; int calendarId = calendar.CalendarId; //List of Active doctors List <ClassDoctor> DoctorList = ListOfActiveDoctors(sql.DoctorList()); //List of calendar days List <ClassCalendarDay> dayList = sql.ListOfCalendarDays(calendarId); string querry = ""; foreach (ClassDoctor dct in DoctorList) { //Create calendar doctor int calendarDoctorId = sql.CreateCalendarDoctor(dct.Doctor_id, calendarId); //Querry for terms for doctor querry += QuerryTermsForDoctor(Year, Month, calendarDoctorId, calendarId, dct, dayList, sql); } if (querry.Length == 0) { return; } querry = Login.ClassHelpers.RemoveLastCharOfString(querry); //Add new terms sql.CreateTerms(querry); //Update calendar status sql.UpdateCalendarStatus(sql.SelectStatusId(EnumStatus.SharedForDoctors), calendarId); }
public static List <ClassCalendar> AlreadyCreatedCalendarsForDoctor() { string querry = "Use [db_Clinic] SELECT [Calendar_id],[Year],[Month],[Status_id] FROM [db_Clinic].[dbo].[tbl_Calendar] WHERE [Status_id] = 2"; SqlDataReader dr = ClassQuerry.ExecuteQuerry(querry); List <ClassCalendar> CalendarList = new List <ClassCalendar>(); while (dr.Read()) { ClassCalendar calendar = new ClassCalendar(); calendar.CalendarId = dr.GetInt32("Calendar_id"); calendar.Year = dr.GetInt32("Year"); calendar.Month = dr.GetInt32("Month"); calendar.Status = new ClassStatus(); calendar.Status.StatusId = dr.GetInt32("Status_id"); CalendarList.Add(calendar); } ClassQuerry.CloseConnection(); return(CalendarList); }