Esempio n. 1
0
        public static async void InsertNewInvitation(Invitation i)
        {
            try
            {
                await invitation.InsertAsync(i);
            }
            catch (MobileServiceInvalidOperationException e)
            {
                Debug.WriteLine(e.Message);
            }

        }
Esempio n. 2
0
 public static async void UpdateInvitation(Invitation i)
 {
     await invitation.UpdateAsync(i);
 }
Esempio n. 3
0
 public static async void DeleteInvitation(Invitation i)
 {
     await invitation.DeleteAsync(i);
 }
Esempio n. 4
0
 public static async Task<Invitation> getInvitation(Invitation inv)
 {
    Invitation ii =  (await invitation.ToListAsync()).Where(i => i.Date.Equals(inv.Date) && i.ToUserId.Equals(inv.ToUserId) && i.PatientID.Equals(inv.PatientID) && i.Date.Equals(inv.Date) && i.TimeFrom.Equals(inv.TimeFrom)).ToList().First();
    return ii;
 }
Esempio n. 5
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);


        }
Esempio n. 6
0
        private void SetupCommands()
        {

            Add_Appointment = new DelegateCommand(async () =>
            {
                MessageDialog mm;

                if (string.IsNullOrWhiteSpace(BindAppointment.Complaint))
                {
                    //show message
                    mm = new MessageDialog("Please fill in all the fields");
                    await mm.ShowAsync();
                    return;
                }
                WorkHours wh = null;


                try
                {
                    wh = whList.Where(w => ((w.From.Date.Equals(BindAppointment.Date.Date) && w.From.TimeOfDay.Hours <= (BindAppointment.TimeFrom.Hours) && w.To.Date.Equals(BindAppointment.Date.Date) && w.To.TimeOfDay.Hours >= (BindAppointment.TimeTo.Hours)) || (w.From.Date.Equals(BindAppointment.Date.Date) && w.From.TimeOfDay.Hours <= (BindAppointment.TimeFrom.Hours) && w.To.Date.Equals(BindAppointment.Date.AddDays(1))) || (w.From.Date.Equals(BindAppointment.Date.Date.AddDays(-1).Date) && w.To.Date.Equals(BindAppointment.Date.Date) && w.To.TimeOfDay.Hours >= (BindAppointment.TimeFrom.Hours)))).ToArray().First();

                    //    wh = whList.Where(w => (w.From.Date.Equals(BindAppointment.Date.Date) &&  )).ToArray().First();
                    if (!String.IsNullOrEmpty(wh.TimeOffReason))
                        wh = null;
                }
                catch
                {

                }

                if (wh != null)
                {
                    try
                    {
                        BindAppointment.Complaint = (BindAppointment.Complaint.ElementAt(0) == '_' ? BindAppointment.Complaint : ("_" + BindAppointment.Complaint));
                    }
                    catch
                    {
                        BindAppointment.Complaint = "_";
                    }

                    if (SelectedDoctor.UserId.Equals(Connection.User.UserId))
                    {

                        if (String.IsNullOrEmpty(SelectedAppointment.UserID))
                        {

                            //String appointmentId = String.Empty;


                            //    var appointment = new Windows.ApplicationModel.Appointments.Appointment();

                            //    // StartTime
                            //    var date = BindAppointment.Date.Date;
                            //    var time = BindAppointment.TimeFrom;
                            //    var timeZoneOffset = TimeZoneInfo.Local.GetUtcOffset(DateTime.Now);
                            //    var startTime = new DateTimeOffset(date.Year, date.Month, date.Day, time.Hours, time.Minutes, 0, timeZoneOffset);
                            //    appointment.StartTime = startTime;

                            //    // Subject
                            //    Patient p =Scheduling.getPatient(BindAppointment.PatientID);
                            //    appointment.Subject = "Clinic: "+p.LName+", "+p.FName;
                            //    // Details
                            //    appointment.Details = BindAppointment.Complaint;
                            //    appointment.Duration = TimeSpan.FromMinutes(15);


                            //    Windows.UI.Xaml.Media.GeneralTransform buttonTransform = (this as FrameworkElement).TransformToVisual(null);
                            //    Windows.Foundation.Point point = buttonTransform.TransformPoint(new Windows.Foundation.Point());
                            //    var rect = new Windows.Foundation.Rect(point, new Windows.Foundation.Size((this as FrameworkElement).ActualWidth, (this as FrameworkElement).ActualHeight));
                            //    appointmentId = await Windows.ApplicationModel.Appointments.AppointmentManager.ShowAddAppointmentAsync(appointment, rect);


                            // BindAppointment.AppoitmentID = appointmentId;

                            Appointment.InsertNewAppointment(BindAppointment);
                            appointmentId = String.Empty;
                            // appList = (await Appointment.ReadAppointmentsList()).Where(a => a.UserID == SelectedDoctor.UserId).ToList();

                        }
                        else
                        {
                            // new MessageDialog(SelectedNVI.Appointment1.Complaint).ShowAsync();

                            app.UpdateAppointment(BindAppointment);
                            //  appList = (await Appointment.ReadAppointmentsList()).Where(a => a.UserID == SelectedDoctor.UserId).ToList();

                        }
                        // 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();
                    }
                    else
                    {

                        Invitation inv = new Invitation();
                        inv.Complaint = BindAppointment.Complaint.Substring(1, (BindAppointment.Complaint.Count() - 1));
                        inv.Date = BindAppointment.Date;
                        inv.PatientID = BindAppointment.PatientID;
                        inv.TimeFrom = BindAppointment.TimeFrom;
                        inv.TimeTo = BindAppointment.TimeTo;
                        inv.ToUserId = BindAppointment.UserID;
                        inv.FromUserId = Connection.User.UserId;

                        Invitation.InsertNewInvitation(inv);
                        // 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();

                    }

                    ShowAddAppointment = Visibility.Collapsed;
                    DeleteAppointmentVisibility = Visibility.Collapsed;
                    SelectedAppointment = null;
                    //invList = (await Invitation.ReadInvitationsList()).Where(i => i.ToUserId == SelectedDoctor.UserId).ToList();

                    //appList = (await Appointment.ReadAppointmentsList()).Where(a => a.UserID == SelectedDoctor.UserId).ToList();

                    fillWeeklyCalendar();
                }
                else
                {
                    //show message
                    mm = new MessageDialog("Appointment should be within the doctors work hours");
                    await mm.ShowAsync();
                    return;
                }

               // count = 0;
            }, true);

            Cancel_Appointment = new DelegateCommand(async () =>
            {


                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;
                // fillWeeklyCalendar();
               // count = 0;
            }, true);
            Delete_Appointment = new DelegateCommand(async () =>
            {

                Appointment.DeleteAppointment(BindAppointment);


                BindAppointment = null;
                ShowAddAppointment = Visibility.Collapsed;
                DeleteAppointmentVisibility = Visibility.Collapsed;
                SelectedAppointment = null;

                //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();
               // count = 0;
            }, true);

            Cal_Appointment = new DelegateCommand(async () =>
            {

                if (String.IsNullOrEmpty(BindAppointment.AppoitmentID))
                {

                    var appointment = new Windows.ApplicationModel.Appointments.Appointment();

                    // StartTime
                    var date = BindAppointment.Date.Date;
                    var time = BindAppointment.TimeFrom;
                    var timeZoneOffset = TimeZoneInfo.Local.GetUtcOffset(DateTime.Now);
                    var startTime = new DateTimeOffset(date.Year, date.Month, date.Day, time.Hours, time.Minutes, 0, timeZoneOffset);
                    appointment.StartTime = startTime;

                    // Subject
                    Patient p = Scheduling.getPatient(BindAppointment.PatientID);
                    appointment.Subject = "Clinic: " + p.LName + ", " + p.FName;
                    // Details
                    appointment.Details = BindAppointment.Complaint;
                    appointment.Duration = TimeSpan.FromMinutes(15);


                    Windows.UI.Xaml.Media.GeneralTransform buttonTransform = (this as FrameworkElement).TransformToVisual(null);
                    Windows.Foundation.Point point = buttonTransform.TransformPoint(new Windows.Foundation.Point());
                    var rect = new Windows.Foundation.Rect(point, new Windows.Foundation.Size((this as FrameworkElement).ActualWidth, (this as FrameworkElement).ActualHeight));
                    appointmentId = await Windows.ApplicationModel.Appointments.AppointmentManager.ShowAddAppointmentAsync(appointment, rect);


                    BindAppointment.AppoitmentID = appointmentId;
                }
                else
                {
                    await new MessageDialog("Appointment has already been added to the original calendar").ShowAsync();
                }

            }, true);



        }