예제 #1
0
 public static async Task<PatientEncounter> getPatientEncounter(Appointment app)
 {
     PatientEncounter pee = null;
     try
     {
          pee = (await patientEncounter.Where(pe => pe.AppointmentId.Equals(app.Id)).ToListAsync()).First();
     }
     catch (MobileServiceInvalidOperationException e)
     {
         Debug.WriteLine(e.Message);
     }
     return pee;
 }
예제 #2
0
        public async void UpdateAppointment(Appointment a)
        {
            
           
           // await appointment.UpdateAsync(a);

            Exception exception = null;
            try
            {
                //update at the remote table
                await appointment.UpdateAsync(a);
            }
            catch (MobileServicePreconditionFailedException<Appointment> writeException)
            {
                exception = writeException;
            }
            catch (Exception ex)
            {
                exception = ex;
            }
            if (exception != null)
            {
                if (exception is MobileServicePreconditionFailedException<Appointment>)
                {
                    //conflict detected, the item has changed since the last query
                    await ResolveConflict(a, ((MobileServicePreconditionFailedException<Appointment>)exception).Item);
                }
                else
                   await new MessageDialog(exception.Message).ShowAsync();
            }
         
        }
예제 #3
0
        private async Task ResolveConflict(Appointment localItem, Appointment serverItem)
        {
            // Ask user to choose between the local text value or leaving the 
            // server's updated text value
            MessageDialog md = new MessageDialog(String.Format("The item has already been updated on the server.\n\n" +
                                                                   "Server value: {0} \n" +
                                                                   "Local value: {1}\n\n" +
                                                                   "Press OK to update the server with the local value.\n\n" +
                                                                   "Press CANCEL to keep the server value.", serverItem.Complaint, localItem.Complaint),
                                                                   "CONFLICT DETECTED ");

            bool? result = null;
            md.Commands.Add(
               new UICommand("OK", new UICommandInvokedHandler((cmd) => result = true)));
            md.Commands.Add(
               new UICommand("Cancel", new UICommandInvokedHandler((cmd) => result = false)));
            await md.ShowAsync();

            // OK : After examining the updated text from the server, overwrite it
            //      with the changes made in this client.
            if (result ==true)
            {
                // Update the version of the item to the latest version
                // to resolve the conflict. Otherwise the exception
                // will be thrown again for the attempted update.
                localItem.Version = serverItem.Version;
                // Recursively updating just in case another conflict 
                // occurs while the user is deciding.
                 this.UpdateAppointment(localItem);
                 Scheduling.Changed = !Scheduling.Changed;
            }
            // CANCEL : After examining the updated text from the server, leave 
            // the server item intact and refresh this client's query discarding 
            // the proposed changes.
           
        }
예제 #4
0
        public static async void InsertNewAppointment(Appointment a)
        {
            appointment.SystemProperties |= MobileServiceSystemProperties.Version;
            string str= String.Empty;
            try
            {
                await appointment.InsertAsync(a);
            }
            catch (Exception e)
            {
                str = e.Message;
                //MessageBox.Show(e.Message, "Update Failed", MessageBoxButton.OK);
            }
          //  await new MessageDialog(str).ShowAsync();

        }
예제 #5
0
 public static async void DeleteAppointment(Appointment a)
 {
     await appointment.DeleteAsync(a);
 }
예제 #6
0
        public async void fillCalendar()
        {
            Window.Current.CoreWindow.PointerCursor = new Windows.UI.Core.CoreCursor(Windows.UI.Core.CoreCursorType.Wait, 2);

            Windows.Globalization.Calendar calendar = new Windows.Globalization.Calendar();

            List<NameValueItem2> dList = new List<NameValueItem2>();
            try
            {
                if ((!SelectedMonth.Equals(calendar.MonthAsSoloString()) || !SelectedYear.Equals(calendar.Year.ToString())) && flip == 0)
                    stay = true;
            }
            catch
            {

            }

            int noOfDaysInTheSelectedMonth = 0;
            int shift = 0;
            string firstDay = String.Empty;

            if (flip == 0)
            {
                if (!stay)
                {
                    SelectedMonth = calendar.MonthAsSoloString();

                    SelectedYear = calendar.Year.ToString();
                }
                // firstDay = new DateTime(Convert.ToInt32(SelectedYear), DateTime.ParseExact(SelectedMonth, "MMMM", CultureInfo.CurrentCulture).Month, 1).ToString("dddd");
            }

            if (flip == -1)
            {
                int temp = DateTime.ParseExact(SelectedMonth, "MMMM", CultureInfo.CurrentCulture).Month;
                if (temp == 1)
                {
                    temp = 12;
                }
                else
                {
                    temp--;
                }
                SelectedMonth = CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(temp);
                if (temp != 12)
                {
                    //SelectedYear = calendar.Year.ToString();
                }
                else
                {
                    int tempYear = Convert.ToInt32(SelectedYear);
                    tempYear--;
                    SelectedYear = tempYear.ToString();

                }


            }

            if (flip == 1)
            {
                {
                    int temp = DateTime.ParseExact(SelectedMonth, "MMMM", CultureInfo.CurrentCulture).Month;
                    if (temp == 12)
                    {
                        temp = 1;
                    }
                    else
                    {
                        temp++;
                    }
                    SelectedMonth = CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(temp);
                    if (temp != 1)
                    {
                    }
                    else
                    {
                        int tempYear = Convert.ToInt32(SelectedYear);
                        tempYear++;
                        SelectedYear = tempYear.ToString();

                    }


                }
            }


            noOfDaysInTheSelectedMonth = DateTime.DaysInMonth(Convert.ToInt32(SelectedYear), DateTime.ParseExact(SelectedMonth, "MMMM", CultureInfo.CurrentCulture).Month);
            firstDay = new DateTime(Convert.ToInt32(SelectedYear), DateTime.ParseExact(SelectedMonth, "MMMM", CultureInfo.CurrentCulture).Month, 1).ToString("dddd");

            switch (firstDay)
            {
                case "Sunday": shift = 0;
                    break;
                case "Monday": shift = 1;
                    break;
                case "Tuesday": shift = 2;
                    break;
                case "Wednesday": shift = 3;
                    break;
                case "Thursday": shift = 4;
                    break;
                case "Friday": shift = 5;
                    break;
                case "Saturday": shift = 6;
                    break;
            }

            while (shift > 0)
            {
                dList.Add(new NameValueItem2());
                shift--;
            }
            appList = await Appointment.ReadAppointmentsList();
            appList = appList.Where(ap => ap.PatientID == SelectedPatient.PatientID).ToList();
            try
            {
                peList = (await PatientEncounter.ReadPatientEncountersList()).Where(pe => (getAppointment(pe.AppointmentId)).PatientID == SelectedPatient.PatientID).ToList();
            }
            catch
            {

            }
            List<PatientHistory> pList = await patientViewModel.patientsInfoTable.Where(
            ph => (ph.PatientId == SelectedPatient.PatientID
            &&
            ph.InfoDate > (new DateTime(Convert.ToInt32(SelectedYear), DateTime.ParseExact(SelectedMonth, "MMMM", CultureInfo.CurrentCulture).Month, 1))
            &&
            ph.InfoDate < (new DateTime(Convert.ToInt32(SelectedYear), DateTime.ParseExact(SelectedMonth, "MMMM", CultureInfo.CurrentCulture).Month, noOfDaysInTheSelectedMonth))
            )).ToListAsync();
            //Where(p => p.FName == ComboPatient).Select(patient => patient.PatientID).ToListAsync()).First();
            for (int i = 1; i <= noOfDaysInTheSelectedMonth; i++)
            {
                DateTime loopDate = new DateTime(Convert.ToInt32(SelectedYear), DateTime.ParseExact(SelectedMonth, "MMMM", CultureInfo.CurrentCulture).Month, i);

                PatientHistory temp;
                try
                {
                    temp = pList.Where(ph => ph.InfoDate.ToString("MMMM dd, yyyy") == loopDate.ToString("MMMM dd, yyyy")).ToList().First();
                }
                catch
                {
                    temp = new PatientHistory();
                }
                Appointment app;

                try
                {
                    app = appList.Where(ap => ap.Date.Date.Equals(loopDate.Date.Date)).ToList().First();
                }
                catch
                {
                    app = new Appointment();
                }
                PatientEncounter pee;

                try
                {
                    pee = peList.Where(pe => (getAppointment(pe.AppointmentId)).Date.Date.Equals(loopDate.Date.Date)).ToList().First();
                }
                catch
                {
                    pee = new PatientEncounter();
                }


                dList.Add(new NameValueItem2 { Value = i.ToString(), date = new DateTime(Convert.ToInt32(SelectedYear), DateTime.ParseExact(SelectedMonth, "MMMM", CultureInfo.CurrentCulture).Month, i), pHistory = temp, Color = ((!String.IsNullOrEmpty(temp.PatientId)) ? "Pink" : (pee.AppointmentId != null) ? "LightBlue" : (!String.IsNullOrEmpty(app.PatientID) ? "#BFB5DF" : "White")), appointment = app, patientEncounter = pee, Width1 = ((!String.IsNullOrEmpty(temp.PatientId)) || (String.IsNullOrEmpty(temp.PatientId) && String.IsNullOrEmpty(app.PatientID)) ? 98 : 0), Width2 = (!String.IsNullOrEmpty((app.PatientID)) && String.IsNullOrEmpty(temp.PatientId) && pee.AppointmentId == null ? 98 : 0), Width3 = (pee.AppointmentId != null ? 98 : 0) });


            }

            MonthGridView.ItemsSource = dList;
            flip = 0;

            Window.Current.CoreWindow.PointerCursor = new Windows.UI.Core.CoreCursor(Windows.UI.Core.CoreCursorType.Arrow, 2);

        }
예제 #7
0
        public async void fillWeeklyCalendar()
        {
            Window.Current.CoreWindow.PointerCursor = new Windows.UI.Core.CoreCursor(Windows.UI.Core.CoreCursorType.Wait, 2);
            myGrid.Opacity = 0.5;
            appIncrease++;

            //if (flip2 == 0)
            //{
                whList = (await WorkHours.ReadListAsync()).Where(w => w.EmployeeId == SelectedDoctor.UserId).ToList();
                appList = (await Appointment.ReadAppointmentsList()).Where(a => a.UserID == SelectedDoctor.UserId).ToList();
                invList = (await Invitation.ReadInvitationsList()).Where(i => i.ToUserId == SelectedDoctor.UserId).ToList();
            //}
            if (SelectedWeek != 0 && flip2 == 0)
            {
                stay = true;

            }
            if (!stay)
            {
                LeftMonth = String.Empty;
                LeftYear = String.Empty;
                RightMonth = String.Empty;
                RightYear = String.Empty;
            }
            //   whList = (await WorkHours.ReadListAsync()).Where(w => w.EmployeeId == Connection.User.UserId).ToList();

           calendar = new Windows.Globalization.Calendar();

            //ObservableCollection
            List<NameValueItem3> dList = new List<NameValueItem3>();
            //dList.Clear();
            // List<WeekDay> weekList = new List<WeekDay>(7);

            if (flip2 == 0)
            {
                if (String.IsNullOrEmpty(SelectedMonth))
                    SelectedMonth = calendar.MonthAsSoloString();
                if (String.IsNullOrEmpty(SelectedYear))
                    SelectedYear = calendar.Year.ToString();



                if (!stay)
                    SelectedWeek = 1;

            }
            if (flip2 == -1)
            {


                if (SelectedWeek == 1)
                {
                    SelectedWeek = 4;

                    if ((DateTime.ParseExact(SelectedMonth, "MMMM", CultureInfo.CurrentCulture).Month) == 1)
                    {
                        SelectedMonth = CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(12);
                        SelectedYear = ((Convert.ToInt32(SelectedYear)) - 1).ToString();
                    }
                    else
                    {
                        SelectedMonth = CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(DateTime.ParseExact(SelectedMonth, "MMMM", CultureInfo.CurrentCulture).Month - 1);
                    }

                }
                else
                {
                    SelectedWeek--;
                }




            }

            if (flip2 == 1)
            {



                if (SelectedWeek == 4)
                {
                    SelectedWeek = 1;

                    if ((DateTime.ParseExact(SelectedMonth, "MMMM", CultureInfo.CurrentCulture).Month) == 12)
                    {
                        SelectedMonth = CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(1);
                        SelectedYear = ((Convert.ToInt32(SelectedYear)) + 1).ToString();
                    }
                    else
                    {
                        SelectedMonth = CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(DateTime.ParseExact(SelectedMonth, "MMMM", CultureInfo.CurrentCulture).Month + 1);
                    }

                }
                else
                {
                    SelectedWeek++;
                }
            }
            int noOfDaysInTheSelectedMonth = 0;
            int shift = 0;
            string firstDay = String.Empty;


            if (!stay)
                weekList.Clear();

            if (SelectedWeek == 1)
            {
                //int noOfDaysInTheSelectedMonth = 0;
                //int shift = 0;
                //string firstDay = String.Empty;

                if (!stay)
                {
                    noOfDaysInTheSelectedMonth = DateTime.DaysInMonth(Convert.ToInt32(SelectedYear), DateTime.ParseExact(SelectedMonth, "MMMM", CultureInfo.CurrentCulture).Month);
                    firstDay = new DateTime(Convert.ToInt32(SelectedYear), DateTime.ParseExact(SelectedMonth, "MMMM", CultureInfo.CurrentCulture).Month, 1).ToString("dddd");

                    switch (firstDay)
                    {
                        case "Sunday": shift = 0;
                            break;
                        case "Monday": shift = 1;
                            break;
                        case "Tuesday": shift = 2;
                            break;
                        case "Wednesday": shift = 3;
                            break;
                        case "Thursday": shift = 4;
                            break;
                        case "Friday": shift = 5;
                            break;
                        case "Saturday": shift = 6;
                            break;
                    }

                    int NumberOfPreviousMonthDays;
                    string previuosMonth;
                    string previousMonthYear;

                    if (shift != 0)
                    {

                        if (DateTime.ParseExact(SelectedMonth, "MMMM", CultureInfo.CurrentCulture).Month != 1)
                        {
                            NumberOfPreviousMonthDays = DateTime.DaysInMonth(Convert.ToInt32(SelectedYear), DateTime.ParseExact(SelectedMonth, "MMMM", CultureInfo.CurrentCulture).Month - 1);
                            previuosMonth = CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(DateTime.ParseExact(SelectedMonth, "MMMM", CultureInfo.CurrentCulture).Month - 1);//
                            previousMonthYear = SelectedYear;
                        }
                        else
                        {
                            NumberOfPreviousMonthDays = DateTime.DaysInMonth(Convert.ToInt32(SelectedYear) - 1, 12);
                            previuosMonth = CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(12);// CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(DateTime.ParseExact(SelectedMonth, "MMMM", CultureInfo.CurrentCulture).Month - 1);//
                            previousMonthYear = (Convert.ToInt32(SelectedYear) - 1).ToString();

                        }

                        for (int i = shift - 1; i >= 0; i--)
                        {
                            weekList.Add(new WeekDay { Year = previousMonthYear, Month = previuosMonth, Day = NumberOfPreviousMonthDays - i });
                        }

                        for (int i = 1; i <= 7 - shift; i++)
                        {
                            weekList.Add(new WeekDay { Year = SelectedYear, Month = SelectedMonth, Day = i });
                            if (i == 7 - shift)
                            {
                                ReachedDayInWeeklyCalendar = weekList.Last();
                                StartDayInWeeklyCalendar = weekList.First();

                            }
                        }

                        LeftMonth = previuosMonth;
                        LeftYear = previousMonthYear;

                        RightMonth = SelectedMonth;
                        //  MonthNameTextBlock3.Text =SelectedMonth  ;
                        RightYear = selectedYear;
                    }
                    if (shift == 0)
                    {
                        for (int i = 1; i <= 7; i++)
                        {

                            weekList.Add(new WeekDay { Year = SelectedYear, Month = SelectedMonth, Day = i });
                            if (i == 7)
                            {
                                ReachedDayInWeeklyCalendar = weekList.Last();
                                StartDayInWeeklyCalendar = weekList.First();
                            }
                        }

                        LeftMonth = SelectedMonth;
                        LeftYear = SelectedYear;

                        RightMonth = String.Empty;
                        RightYear = String.Empty;
                    }



                }
            }
            else if (SelectedWeek == 2 || SelectedWeek == 3 || SelectedWeek == 4)
            {
                if (!stay)
                {
                    if (!backward)
                    {
                        for (int i = ReachedDayInWeeklyCalendar.Day + 1; i <= (ReachedDayInWeeklyCalendar.Day + 7); i++)
                        {
                            weekList.Add(new WeekDay { Year = SelectedYear, Month = SelectedMonth, Day = i });
                            if (i == ReachedDayInWeeklyCalendar.Day + 7)
                            {
                                ReachedDayInWeeklyCalendar = weekList.Last();
                                StartDayInWeeklyCalendar = weekList.First();
                                break;
                            }
                        }



                    }

                    else //backward true
                    {

                        if (StartDayInWeeklyCalendar.Day - 1 != 0)
                        {
                            for (int i = StartDayInWeeklyCalendar.Day - 7; i <= (StartDayInWeeklyCalendar.Day - 1); i++)
                            {

                                weekList.Add(new WeekDay { Year = SelectedYear, Month = SelectedMonth, Day = i });
                                if (i == StartDayInWeeklyCalendar.Day - 1)
                                {
                                    ReachedDayInWeeklyCalendar = weekList.Last();
                                    StartDayInWeeklyCalendar = weekList.First();
                                    break;
                                }


                            }
                        }
                        else
                        {
                            if (DateTime.ParseExact(SelectedMonth, "MMMM", CultureInfo.CurrentCulture).Month != 1)
                            {
                                noOfDaysInTheSelectedMonth = DateTime.DaysInMonth(Convert.ToInt32(SelectedYear), DateTime.ParseExact(SelectedMonth, "MMMM", CultureInfo.CurrentCulture).Month);
                                //SelectedMonth = CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(DateTime.ParseExact(SelectedMonth, "MMMM", CultureInfo.CurrentCulture).Month - 1);//
                                //SelectedYear = SelectedYear;
                            }
                            else
                            {
                                noOfDaysInTheSelectedMonth = DateTime.DaysInMonth(Convert.ToInt32(SelectedYear) - 1, 12);
                                //SelectedMonth = CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(12);// CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(DateTime.ParseExact(SelectedMonth, "MMMM", CultureInfo.CurrentCulture).Month - 1);//
                                //SelectedYear = (Convert.ToInt32(SelectedYear) - 1).ToString();

                            }

                            for (int i = noOfDaysInTheSelectedMonth - 6; i <= (noOfDaysInTheSelectedMonth - 0); i++)
                            {

                                weekList.Add(new WeekDay { Year = SelectedYear, Month = SelectedMonth, Day = i });
                                if (i == (noOfDaysInTheSelectedMonth - 0))
                                {
                                    ReachedDayInWeeklyCalendar = weekList.Last();
                                    StartDayInWeeklyCalendar = weekList.First();
                                    break;
                                }


                            }



                        }



                    }


                    LeftMonth = SelectedMonth;
                    LeftYear = SelectedYear;
                    RightMonth = String.Empty;
                    RightYear = String.Empty;

                }

            }




            for (int i = 0; i < 192; i++)
            {
                OutLookEvent[] myOEvent2 = null;
                OutLookEvent myOEvent = null;
                WorkHours wh = null;

                Appointment app1 = null;
                Appointment app2 = null;
                Appointment app3 = null;
                Appointment app4 = null;
                Invitation inv1 = null;
                Invitation inv2 = null;
                Invitation inv3 = null;
                Invitation inv4 = null;

                if (i % 8 == 0)
                {
                    dList.Add(new NameValueItem3() { timeItem = true, time = new TimeSpan(i / 8, 0, 0), Width = 1, timeStr = (new TimeSpan(i / 8, 0, 0)).ToString().Substring(0, (new TimeSpan(i / 8, 0, 0)).ToString().LastIndexOf(":")) + "_", Color1 = "#BFB5DF", Width1 = 45 }); //( new TimeSpan(i / 8, 0, 0)).ToString()
                }

                else
                {

                    DateTime loopDate = new DateTime(Convert.ToInt32(weekList.ElementAt((i % 8) - 1).Year),
                           DateTime.ParseExact(weekList.ElementAt((i % 8) - 1).Month, "MMMM", CultureInfo.CurrentCulture).Month,
                           weekList.ElementAt((i % 8) - 1).Day);

                    //try
                    //{
                    //    //  myOEvent = eventList.Where(e => (e.start_time.ToString("MMMM dd, yyyy")).Equals(loopDate.ToString("MMMM dd, yyyy"))).ToArray().First();
                    //    //   myOEvent = eventList.Where(e => (e.start_time.ToString("MMMM dd, yyyy")).Equals(loopDate.ToString("MMMM dd, yyyy")) && (e.start_time.TimeOfDay.Equals(new TimeSpan(i / 8, 0, 0)) || e.end_time.TimeOfDay >= (new TimeSpan(i / 8, 0, 0)))).ToArray().First();
                    //    //   myOEvent = eventList.Where(e => (e.start_time.ToString("MMMM dd, yyyy")).Equals(loopDate.ToString("MMMM dd, yyyy")) && (new TimeSpan(e.end_time.TimeOfDay.Hours,0,0) >= (new TimeSpan(i / 8, 0, 0)) || e.isAllDay == true)).ToArray().First();
                    //    // myOEvent = eventList.Where(e => (e.start_time.ToString("MMMM dd, yyyy")).Equals(loopDate.ToString("MMMM dd, yyyy")) && (((new TimeSpan(e.end_time.TimeOfDay.Hours, 0, 0) > (new TimeSpan(i / 8, 0, 0))) && (new TimeSpan(e.start_time.TimeOfDay.Hours, 0, 0) <= (new TimeSpan(i / 8, 0, 0)))) || e.isAllDay == true || ((new TimeSpan(e.start_time.TimeOfDay.Hours, 0, 0) <= (new TimeSpan(i / 8, 0, 0)))&&(TimeSpan)(e.end_time - e.start_time) <= new TimeSpan(1, 0, 0)))).ToArray().First();
                    //    myOEvent = eventList.Where(e => (e.start_time.ToString("MMMM dd, yyyy")).Equals(loopDate.ToString("MMMM dd, yyyy")) && (((new TimeSpan(e.end_time.TimeOfDay.Hours, 0, 0) > (new TimeSpan(i / 8, 0, 0))) && (new TimeSpan(e.start_time.TimeOfDay.Hours, 0, 0) <= (new TimeSpan(i / 8, 0, 0)))) || e.isAllDay == true || ((new TimeSpan(e.start_time.TimeOfDay.Hours, 0, 0) == (new TimeSpan(i / 8, 0, 0))) && ((TimeSpan)(e.end_time - e.start_time)).Hours <= 1))).ToArray().First();
                    //    myOEvent2 = eventList.Where(e => (e.start_time.ToString("MMMM dd, yyyy")).Equals(loopDate.ToString("MMMM dd, yyyy")) && (((new TimeSpan(e.end_time.TimeOfDay.Hours, 0, 0) > (new TimeSpan(i / 8, 0, 0))) && (new TimeSpan(e.start_time.TimeOfDay.Hours, 0, 0) <= (new TimeSpan(i / 8, 0, 0)))) || e.isAllDay == true || ((new TimeSpan(e.start_time.TimeOfDay.Hours, 0, 0) == (new TimeSpan(i / 8, 0, 0))) && ((TimeSpan)(e.end_time - e.start_time)).Hours <= 1))).ToArray();
                    //}
                    //catch
                    //{

                    //}

                    try
                    {
                        wh = whList.Where(w => ((w.From.ToString("MMMM dd, yyyy").Equals(loopDate.ToString("MMMM dd, yyyy")) && w.From.TimeOfDay.Hours <= (i / 8) && w.To.ToString("MMMM dd, yyyy").Equals(loopDate.ToString("MMMM dd, yyyy")) && w.To.TimeOfDay.Hours >= (i / 8)) || (w.From.ToString("MMMM dd, yyyy").Equals(loopDate.ToString("MMMM dd, yyyy")) && w.From.TimeOfDay.Hours <= i / 8 && w.To.Date.Equals(loopDate.AddDays(1))) || (w.From.Date.Equals(loopDate.AddDays(-1).Date) && w.To.Date.Equals(loopDate.Date) && w.To.TimeOfDay.Hours >= (i / 8)) || (w.TimeOffFrom.Date.Equals(loopDate.Date) && w.TimeOffFrom.TimeOfDay.Hours <= (i / 8) && w.TimeOffTo.TimeOfDay.Hours >= (i / 8)))).ToArray().First();
                        if (!String.IsNullOrEmpty(wh.TimeOffReason))
                            wh = null;
                    }
                    catch
                    {

                    }

                    try
                    {
                        app1 = appList.Where(a => (a.Date.Date.Equals(loopDate.Date) && (a.TimeFrom.Hours == (i / 8)) && (a.TimeFrom.Minutes == 0) && (a.TimeTo.Minutes == 15))).ToList().First();
                    }
                    catch
                    {
                        app1 = new Appointment();
                        // app1.Complaint = "hiii2";

                    }

                    try
                    {
                        app2 = appList.Where(a => (a.Date.Date.Equals(loopDate.Date) && (a.TimeFrom.Hours == (i / 8)) && (a.TimeFrom.Minutes == 15) && (a.TimeTo.Minutes == 30))).ToList().First();
                    }
                    catch
                    {
                        app2 = new Appointment();

                    }

                    try
                    {
                        app3 = appList.Where(a => (a.Date.Date.Equals(loopDate.Date) && (a.TimeFrom.Hours == (i / 8)) && (a.TimeFrom.Minutes == 30) && (a.TimeTo.Minutes == 45))).ToList().First();
                    }
                    catch
                    {
                        app3 = new Appointment();

                    }

                    try
                    {
                        app4 = appList.Where(a => (a.Date.Date.Equals(loopDate.Date) && (a.TimeFrom.Hours == (i / 8)) && (a.TimeFrom.Minutes == 45) && (a.TimeTo.Minutes == 0))).ToList().First();
                    }
                    catch
                    {
                        app4 = new Appointment();


                    }

                    try
                    {
                        inv1 = invList.Where(a => (a.Date.Date.Equals(loopDate.Date) && (a.TimeFrom.Hours == (i / 8)) && (a.TimeFrom.Minutes == 0) && (a.TimeTo.Minutes == 15))).ToList().First();
                    }
                    catch
                    {

                        inv1 = new Invitation();

                    }

                    try
                    {
                        inv2 = invList.Where(a => (a.Date.Date.Equals(loopDate.Date) && (a.TimeFrom.Hours == (i / 8)) && (a.TimeFrom.Minutes == 15) && (a.TimeTo.Minutes == 30))).ToList().First();
                    }
                    catch
                    {

                        inv2 = new Invitation();

                    }

                    try
                    {
                        inv3 = invList.Where(a => (a.Date.Date.Equals(loopDate.Date) && (a.TimeFrom.Hours == (i / 8)) && (a.TimeFrom.Minutes == 30) && (a.TimeTo.Minutes == 45))).ToList().First();
                    }
                    catch
                    {

                        inv3 = new Invitation();

                    }

                    try
                    {
                        inv4 = invList.Where(a => (a.Date.Date.Equals(loopDate.Date) && (a.TimeFrom.Hours == (i / 8)) && (a.TimeFrom.Minutes == 45) && (a.TimeTo.Minutes == 0))).ToList().First();
                    }
                    catch
                    {

                        inv4 = new Invitation();

                    }


                    dList.Add(new NameValueItem3()
                    {
                        timeItem = false,
                        time = new TimeSpan(i / 8, 0, 0),
                        timeStr = null,
                        Width = 3,
                        weekDay = weekList.ElementAt((i % 8) - 1),
                        Color1 = (myOEvent != null ? "Wheat" : "#BFB5DF"),
                        myOutLookEvent = myOEvent,
                        myOutLookEvent2 = myOEvent2,
                        workHours = wh,
                        Border = (myOEvent != null || wh != null ? new Thickness(1) : new Thickness(0)),
                        //Color2 = (wh == null ? "AliceBlue" : (wh.From.TimeOfDay.Hours == 7 ? "#99FF99" : (wh.From.TimeOfDay.Hours == 15 ? "#99CCFF" : (wh.From.TimeOfDay.Hours == 23 ? "Wheat" : "AliceBlue")))),
                        Color2 = (wh == null ? "#BFB5DF" : (wh.From.TimeOfDay.Hours == 7 ? "#A3F1A7" : (wh.From.TimeOfDay.Hours == 15 ? "#A3F1A7" : (wh.From.TimeOfDay.Hours == 23 ? "#A3F1A7" : "#BFB5DF")))),

                        Width1 = (myOEvent == null && wh != null ? 0 : (myOEvent != null && wh != null) ? 67 : 135),
                        Width2 = (wh != null && myOEvent == null ? 135 : (wh != null && myOEvent != null) ? 67 : 0),
                        Appointment1 = app1,
                        Appointment2 = app2,
                        Appointment3 = app3,
                        Appointment4 = app4,
                        Invitation1 = inv1,
                        Invitation2 = inv2,
                        Invitation3 = inv3,
                        Invitation4 = inv4,

                        EnableTextBlockes = Visibility.Visible,
                        EnableTextBlockes2 = Visibility.Visible,
                        EnableTextBlockes3 = Visibility.Visible,
                        EnableTextBlockes4 = Visibility.Visible,



                        EnableTextBoxes = Visibility.Collapsed,
                        EnableTextBoxes2 = Visibility.Collapsed,
                        EnableTextBoxes3 = Visibility.Collapsed,
                        EnableTextBoxes4 = Visibility.Collapsed,



                        EnableButton = Visibility.Collapsed,
                        EnableButton2 = Visibility.Collapsed,
                        EnableButton3 = Visibility.Collapsed,
                        EnableButton4 = Visibility.Collapsed,


                        EnableDelButton = Visibility.Collapsed,
                        EnableDelButton2 = Visibility.Collapsed,
                        EnableDelButton3 = Visibility.Collapsed,
                        EnableDelButton4 = Visibility.Collapsed,


                    });
                    if (i > 0 || i < 8)
                    {
                        //  if(myOEvent.isAllDay)
                        switch (i)
                        {
                            case 1: Sunday.Text = (new DateTime(Convert.ToInt32(weekList.ElementAt((i % 8) - 1).Year),
                                DateTime.ParseExact(weekList.ElementAt((i % 8) - 1).Month, "MMMM", CultureInfo.CurrentCulture).Month,
                                weekList.ElementAt((i % 8) - 1).Day)
                                ).DayOfWeek.ToString() + " " + weekList.ElementAt((i % 8) - 1).Day;
                                //try
                                //{
                                //    Sunday2.Text = (myOEvent.isAllDay ? myOEvent.Name : null);
                                //}
                                //catch
                                //{
                                //    Sunday2.Text = String.Empty;
                                //}
                                break;
                            case 2: Monday.Text = (new DateTime(Convert.ToInt32(weekList.ElementAt((i % 8) - 1).Year),
                                 DateTime.ParseExact(weekList.ElementAt((i % 8) - 1).Month, "MMMM", CultureInfo.CurrentCulture).Month,
                                 weekList.ElementAt((i % 8) - 1).Day)
                                 ).DayOfWeek.ToString() + " " + weekList.ElementAt((i % 8) - 1).Day;
                                //try
                                //{
                                //    Monday2.Text = (myOEvent.isAllDay ? myOEvent.Name : null);
                                //}
                                //catch
                                //{
                                //    Monday2.Text = String.Empty;
                                //}
                                break;
                            case 3: Tuesday.Text = (new DateTime(Convert.ToInt32(weekList.ElementAt((i % 8) - 1).Year),
                                DateTime.ParseExact(weekList.ElementAt((i % 8) - 1).Month, "MMMM", CultureInfo.CurrentCulture).Month,
                                weekList.ElementAt((i % 8) - 1).Day)
                                ).DayOfWeek.ToString() + " " + weekList.ElementAt((i % 8) - 1).Day;
                                //try
                                //{
                                //    Tuesday2.Text = (myOEvent.isAllDay ? myOEvent.Name : null);
                                //}
                                //catch
                                //{
                                //    Tuesday2.Text = String.Empty;
                                //}
                                break;
                            case 4: Wednesday.Text = (new DateTime(Convert.ToInt32(weekList.ElementAt((i % 8) - 1).Year),
                                DateTime.ParseExact(weekList.ElementAt((i % 8) - 1).Month, "MMMM", CultureInfo.CurrentCulture).Month,
                                weekList.ElementAt((i % 8) - 1).Day)
                                ).DayOfWeek.ToString() + " " + weekList.ElementAt((i % 8) - 1).Day;
                                //try
                                //{
                                //    Wednesday2.Text = (myOEvent.isAllDay ? myOEvent.Name : null);
                                //}
                                //catch
                                //{
                                //    Wednesday2.Text = String.Empty;
                                //}
                                break;
                            case 5: Thursday.Text = (new DateTime(Convert.ToInt32(weekList.ElementAt((i % 8) - 1).Year),
                                DateTime.ParseExact(weekList.ElementAt((i % 8) - 1).Month, "MMMM", CultureInfo.CurrentCulture).Month,
                                weekList.ElementAt((i % 8) - 1).Day)
                                ).DayOfWeek.ToString() + " " + weekList.ElementAt((i % 8) - 1).Day;
                                //try
                                //{
                                //    Thursday2.Text = (myOEvent.isAllDay ? myOEvent.Name : null);
                                //}
                                //catch
                                //{
                                //    Thursday2.Text = String.Empty;
                                //}
                                break;
                            case 6: Friday.Text = (new DateTime(Convert.ToInt32(weekList.ElementAt((i % 8) - 1).Year),
                                DateTime.ParseExact(weekList.ElementAt((i % 8) - 1).Month, "MMMM", CultureInfo.CurrentCulture).Month,
                                weekList.ElementAt((i % 8) - 1).Day)
                                ).DayOfWeek.ToString() + " " + weekList.ElementAt((i % 8) - 1).Day;
                                //try
                                //{
                                //    Friday2.Text = (myOEvent.isAllDay ? myOEvent.Name : null);
                                //}
                                //catch
                                //{
                                //    Friday2.Text = String.Empty;
                                //}
                                break;
                            case 7:


                                Saturday.Text = (new DateTime(Convert.ToInt32(weekList.ElementAt((i % 8) - 1).Year),
                                DateTime.ParseExact(weekList.ElementAt((i % 8) - 1).Month, "MMMM", CultureInfo.CurrentCulture).Month,
                                weekList.ElementAt((i % 8) - 1).Day)
                                ).DayOfWeek.ToString() + " " + weekList.ElementAt((i % 8) - 1).Day;
                                //try
                                //{
                                //    Saturday2.Text = (myOEvent.isAllDay ? myOEvent.Name : null);
                                //}
                                //catch
                                //{
                                //    Saturday2.Text = String.Empty;
                                //}
                                break;


                        }
                        // weekList.ElementAt((i-1)%8)
                    }
                }
            }

            flip2 = 0;
            backward = false;
            WeekGridView.ItemsSource = dList;
            //weekList.Clear();
            stay = false;
            //Dispatcher.RunAsync(CoreDispatcherPriority.Low, () =>
            //{
            //    WeekGridView.ScrollIntoView(dList.ElementAt(147));
            //});


            myGrid.Opacity = 1;
            Window.Current.CoreWindow.PointerCursor = new Windows.UI.Core.CoreCursor(Windows.UI.Core.CoreCursorType.Arrow, 2);


        }
예제 #8
0
        public Scheduling()
        {


            oldChanged = Changed;
            this.InitializeComponent();
            this.logIn.Text = Connection.UserName;
            try
            {
                Uri uri = new Uri(Connection.ImageUri, UriKind.Absolute);
                ImageSource imgSource = new BitmapImage(uri);
                myImage.Source = imgSource;

            }
            catch (Exception e)
            {
                new MessageDialog(e.Message).ShowAsync();
            }
            DoctorsComboBox.DataContext = this;

            this.PropertyChanged += (sender, e) =>
            {
                if (String.Equals(e.PropertyName, "SelectedDoctor"))
                {
                    fillWeeklyCalendar();
                }
            };




            this.PropertyChanged += (sender, e) =>
            {
                if (String.Equals(e.PropertyName, "SelectedNVI"))
                {
                    try
                    {
                        OldSelectedNVI.EnableTextBlockes = Visibility.Visible;
                        OldSelectedNVI.EnableTextBoxes = Visibility.Collapsed;
                        OldSelectedNVI.EnableButton = Visibility.Collapsed;
                        OldSelectedNVI.EnableDelButton = Visibility.Collapsed;

                        OldSelectedNVI.EnableTextBlockes2 = Visibility.Visible;
                        OldSelectedNVI.EnableTextBoxes2 = Visibility.Collapsed;
                        OldSelectedNVI.EnableButton2 = Visibility.Collapsed;
                        OldSelectedNVI.EnableDelButton2 = Visibility.Collapsed;

                        OldSelectedNVI.EnableTextBlockes3 = Visibility.Visible;
                        OldSelectedNVI.EnableTextBoxes3 = Visibility.Collapsed;
                        OldSelectedNVI.EnableButton3 = Visibility.Collapsed;
                        OldSelectedNVI.EnableDelButton3 = Visibility.Collapsed;

                        OldSelectedNVI.EnableTextBlockes4 = Visibility.Visible;
                        OldSelectedNVI.EnableTextBoxes4 = Visibility.Collapsed;
                        OldSelectedNVI.EnableButton4 = Visibility.Collapsed;
                        OldSelectedNVI.EnableDelButton4 = Visibility.Collapsed;

                        ShowAddAppointment = Visibility.Collapsed;
                    }
                    catch
                    {

                    }
                    if (!SelectedNVI.Equals(OldSelectedNVI))
                        countClick = 0;
                    OldSelectedNVI = SelectedNVI;
                }
            };


            MonthNameTextBlock2.DataContext = this;
            YearNameTextBlock2.DataContext = this;
            MonthNameTextBlock3.DataContext = this;
            YearNameTextBlock3.DataContext = this;
            CurrentDate = DateTime.Now;
            VerticalPatientsView.DataContext = this;
            Output2.DataContext = this;

            AddAppointmentView.DataContext = this;
            DataContext = this;
            app = (new Appointment());

            SetupCommands();
            fillDoctors();
            fillGridView();

        }
예제 #9
0
        private void app4TextBox_GotFocus(object sender, RoutedEventArgs e)
        {
            SelectedAppointment = SelectedNVI.Appointment4;

            if (SelectedNVI.Appointment4.UserID == null)
            {
                Appointment app = new Appointment();

                try
                {
                    app.PatientID = SelectedPatient.PatientID;
                }
                catch (NullReferenceException ee)
                {
                    new MessageDialog("please select a patient first").ShowAsync();
                    OldSelectedNVI.EnableTextBlockes = Visibility.Visible;
                    OldSelectedNVI.EnableTextBoxes = Visibility.Collapsed;
                    OldSelectedNVI.EnableButton = Visibility.Collapsed;
                    OldSelectedNVI.EnableDelButton = Visibility.Collapsed;

                    OldSelectedNVI.EnableTextBlockes2 = Visibility.Visible;
                    OldSelectedNVI.EnableTextBoxes2 = Visibility.Collapsed;
                    OldSelectedNVI.EnableButton2 = Visibility.Collapsed;
                    OldSelectedNVI.EnableDelButton2 = Visibility.Collapsed;

                    OldSelectedNVI.EnableTextBlockes3 = Visibility.Visible;
                    OldSelectedNVI.EnableTextBoxes3 = Visibility.Collapsed;
                    OldSelectedNVI.EnableButton3 = Visibility.Collapsed;
                    OldSelectedNVI.EnableDelButton3 = Visibility.Collapsed;



                    OldSelectedNVI.EnableTextBlockes4 = Visibility.Visible;
                    OldSelectedNVI.EnableTextBoxes4 = Visibility.Collapsed;
                    OldSelectedNVI.EnableButton4 = Visibility.Collapsed;
                    OldSelectedNVI.EnableDelButton4 = Visibility.Collapsed;

                    BindAppointment = null;
                    ShowAddAppointment = Visibility.Collapsed;
                    DeleteAppointmentVisibility = Visibility.Collapsed;
                    SelectedAppointment = null;
                    return;
                }
                app.Complaint = SelectedNVI.Appointment4.Complaint;
                app.Date = (new DateTime(Convert.ToInt32(SelectedNVI.weekDay.Year),
                                DateTime.ParseExact(SelectedNVI.weekDay.Month, "MMMM", CultureInfo.CurrentCulture).Month,
                                SelectedNVI.weekDay.Day)
                                );
                app.PatientID = SelectedPatient.PatientID;
                app.TimeFrom = new TimeSpan(SelectedNVI.time.Hours, 45, 0);
                app.TimeTo = new TimeSpan(SelectedNVI.time.Hours, 0, 0);
                app.UserID = SelectedDoctor.UserId;
                app.AppoitmentID = String.Empty;

                BindAppointment = app;
            }
            else
            {
                BindAppointment = SelectedNVI.Appointment4;
                DeleteAppointmentVisibility = Visibility.Visible;
            }
           // new MessageDialog((++count).ToString()).ShowAsync();
            ShowAddAppointment = Visibility.Visible;
        }
예제 #10
0
        private async void Button_Click_3(object sender, RoutedEventArgs e)//45-0
        {
            Appointment app = new Appointment();
            app.Complaint = "_" + SelectedNVI.Invitation4.Complaint;
            app.Date = (new DateTime(Convert.ToInt32(SelectedNVI.weekDay.Year),
                            DateTime.ParseExact(SelectedNVI.weekDay.Month, "MMMM", CultureInfo.CurrentCulture).Month,
                            SelectedNVI.weekDay.Day)
                            );
            app.PatientID = SelectedNVI.Invitation4.PatientID;
            app.TimeFrom = new TimeSpan(SelectedNVI.time.Hours, 45, 0);
            app.TimeTo = new TimeSpan(SelectedNVI.time.Hours, 0, 0);
            app.UserID = SelectedNVI.Invitation4.ToUserId;
            app.AppoitmentID = String.Empty;
            Appointment.InsertNewAppointment(app);

            Invitation temp = await Invitation.getInvitation(SelectedNVI.Invitation4);
            Invitation.DeleteInvitation(temp);

            // whList = (await WorkHours.ReadListAsync()).Where(w => w.EmployeeId == SelectedDoctor.UserId).ToList();
            //appList = (await Appointment.ReadAppointmentsList()).Where(a => a.UserID == SelectedDoctor.UserId).ToList();
            //invList = (await Invitation.ReadInvitationsList()).Where(i => i.ToUserId == SelectedDoctor.UserId).ToList();
            fillWeeklyCalendar();

        }