public string SetDailySchedule(string doctorID, DayOfWeek dayOfWeek, int am) {
            string setting = null;

            switch (dayOfWeek) {
                case DayOfWeek.Sunday:
                    setting = "Sun";
                    break;
                case DayOfWeek.Monday:
                    setting = "Mon";
                    break;
                case DayOfWeek.Tuesday:
                    setting = "Tue";
                    break;
                case DayOfWeek.Wednesday:
                    setting = "Wed";
                    break;
                case DayOfWeek.Thursday:
                    setting = "Thu";
                    break;
                case DayOfWeek.Friday:
                    setting = "Fri";
                    break;
                case DayOfWeek.Saturday:
                    setting = "Sat";
                    break;
                default:
                    return "Invalid Weekday! @Data";
            }

            if (am > 0) {
                setting += ":A";
            }
            else {
                setting += ":P";
            }

            DrPEDatabaseEntities DEntities = new DrPEDatabaseEntities();

            Doctor doctor = (from d in DEntities.Doctors
                             where d.DoctorID == doctorID
                             select d).FirstOrDefault();
            if (doctor == null) {
                return "Invalid DoctorID!";
            }

            Schedule schedule = (from s in DEntities.Schedules
                                 where s.DoctorID == doctorID
                                 select s).FirstOrDefault();

            if (schedule == null) {
                schedule = new Schedule();
                schedule.DoctorID = doctor.DoctorID;
                schedule.Weekday = setting;
                schedule.LastCheck = DateTime.Now;
                DEntities.Schedules.AddObject(schedule);
            }
            else {
                schedule.Weekday = setting;
                schedule.LastCheck = DateTime.Now;
            }

            try {
                DEntities.SaveChanges();
            }
            catch {
                return "Set Daily Schedule Failed! @Data";
            }

            return null;
        }
 /// <summary>
 /// 用于向 Schedules EntitySet 添加新对象的方法,已弃用。请考虑改用关联的 ObjectSet&lt;T&gt; 属性的 .Add 方法。
 /// </summary>
 public void AddToSchedules(Schedule schedule)
 {
     base.AddObject("Schedules", schedule);
 }
        public string SetExceptionSchedule(string doctorID, DateTime? date) {

            DrPEDatabaseEntities DEntities = new DrPEDatabaseEntities();

            Doctor doctor = (from d in DEntities.Doctors
                             where d.DoctorID == doctorID
                             select d).FirstOrDefault();
            if (doctor == null) {
                return "Invalid DoctorID! @Data";
            }

            if (date == null) {
                return "Paremeter Date is Null! @Data";
            }

            DateTime newDate = (DateTime)date;
            DateTime dDate = newDate.Date;
            if (newDate.CompareTo(dDate.AddHours(12)) >= 0) {
                dDate = dDate.AddHours(12);
            }

            Schedule schedule = (from s in DEntities.Schedules
                                 where s.DoctorID == doctorID
                                 select s).FirstOrDefault();

            if (schedule == null) {
                schedule = new Schedule();
                schedule.DoctorID = doctor.DoctorID;
                schedule.Exception = dDate;
                schedule.LastCheck = DateTime.Now;
                DEntities.Schedules.AddObject(schedule);
            }
            else {
                if (schedule.Addition != null) {
                    if (((DateTime)schedule.Addition) == dDate) {
                        return "Conflict with Additonal Date! @Data";
                    }
                }

                schedule.Exception = dDate;
                schedule.LastCheck = DateTime.Now;
            }

            try {
                DEntities.SaveChanges();
            }
            catch {
                return "Set Exceptional Schedule Failed! @Data";
            }

            return null;
        }
 /// <summary>
 /// 创建新的 Schedule 对象。
 /// </summary>
 /// <param name="doctorID">DoctorID 属性的初始值。</param>
 public static Schedule CreateSchedule(global::System.String doctorID)
 {
     Schedule schedule = new Schedule();
     schedule.DoctorID = doctorID;
     return schedule;
 }