Exemplo n.º 1
0
        public MainPage()
        {
            InitializeComponent();
            NavigationCacheMode = NavigationCacheMode.Enabled;

            var appointment = new Windows.ApplicationModel.Appointments.Appointment();
        }
Exemplo n.º 2
0
 private async void Button_Tapped(object sender, TappedRoutedEventArgs e)
 {
     if (((Button)sender).DataContext != null && ((Button)sender).DataContext is Feature.DataModel.SampleItem)
     {
         Feature.DataModel.SampleItem sampleItem = ((Button)sender).DataContext as Feature.DataModel.SampleItem;
         this.currentSampleItem = sampleItem;
         if (sampleItem.Option.Contains("选座"))
         {
             this.clearSelect();
             this.StoryexpansionSeat.Begin();
         }
         else
         {
             var appointment = new Windows.ApplicationModel.Appointments.Appointment();
             appointment.Subject   = this.sampleItem.Title;
             appointment.StartTime = new DateTimeOffset(DateTime.Now.AddSeconds(1));
             appointment.Duration  = TimeSpan.FromSeconds(1);
             appointment.Location  = "beijing";
             Windows.UI.Xaml.Media.GeneralTransform buttonTransform = (sender 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((sender as FrameworkElement).ActualWidth, (sender as FrameworkElement).ActualHeight));
             await Windows.ApplicationModel.Appointments.AppointmentManager.ShowAddAppointmentAsync(appointment, rect, Windows.UI.Popups.Placement.Default);
         }
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// Creates an Appointment based on the input fields and validates it.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Create_Click(object sender, RoutedEventArgs e)
        {
            string errorMessage = null;
            var    appointment  = new Windows.ApplicationModel.Appointments.Appointment();

            // StartTime
            //var date = StartTimeDatePicker.Date;
            var time           = StartTimeTimePicker.Time;
            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
            appointment.Subject = SubjectTextBox.Text;

            if (appointment.Subject.Length > 255)
            {
                errorMessage = "The subject cannot be greater than 255 characters.";
            }

            // Location
            appointment.Location = LocationTextBox.Text;

            if (appointment.Location.Length > 32768)
            {
                errorMessage = "The location cannot be greater than 32,768 characters.";
            }

            // Details
            appointment.Details = DetailsTextBox.Text;

            if (appointment.Details.Length > 1073741823)
            {
                errorMessage = "The details cannot be greater than 1,073,741,823 characters.";
            }

            // Duration
            if (DurationComboBox.SelectedIndex == 0)
            {
                // 30 minute duration is selected
                appointment.Duration = TimeSpan.FromMinutes(30);
            }
            else
            {
                // 1 hour duration is selected
                appointment.Duration = TimeSpan.FromHours(1);
            }

            if (errorMessage == null)
            {
                // rootPage.NotifyUser("The appointment was created successfully and is valid.", NotifyType.StatusMessage);
            }
            else
            {
                // rootPage.NotifyUser(errorMessage, NotifyType.ErrorMessage);
            }
        }
        private async void button1_Click(object sender, RoutedEventArgs e)
        {
            var appointment = new Windows.ApplicationModel.Appointments.Appointment();
            appointment.StartTime = new DateTimeOffset(DateTime.Now);

            appointment.Subject = "test";
            appointment.Location = "testlocation";
                   
            var rect = GetElementRect(sender as FrameworkElement);
            var appointmentId = await Windows.ApplicationModel.Appointments.AppointmentManager.ShowAddAppointmentAsync(appointment, rect);
        }
Exemplo n.º 5
0
        public static async Task AddAppointment(object sender, DateTime time, string subject, string name)
        {
            var appointment = new Windows.ApplicationModel.Appointments.Appointment();
            var timeNow     = DateTime.Now;
            var startTime   = time.Month >= timeNow.Month ? new DateTime(timeNow.Year, time.Month, time.Day) : new DateTime(timeNow.Year + 1, time.Month, time.Day);

            appointment.StartTime = startTime;
            appointment.Subject   = subject;
            appointment.Details   = $"Congratulate {name} birthday";
            appointment.Reminder  = TimeSpan.FromDays(1);
            var rect = new Rect(0, 0, 100, 100);
            await Windows.ApplicationModel.Appointments.AppointmentManager.ShowAddAppointmentAsync(appointment, rect, Windows.UI.Popups.Placement.Default);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Replace an appointment on the user's calendar using the default appointments provider app.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void Replace_Click(object sender, RoutedEventArgs e)
        {
            // The appointment id argument for ReplaceAppointmentAsync is typically retrieved from AddAppointmentAsync and stored in app data.
            String appointmentIdOfAppointmentToReplace = AppointmentIdTextBox.Text;

            if (String.IsNullOrEmpty(appointmentIdOfAppointmentToReplace))
            {
                ResultTextBlock.Text = "The appointment id cannot be empty";
            }
            else
            {
                // The Appointment argument for ReplaceAppointmentAsync should contain all of the Appointment's properties including those that may have changed.
                var appointment = new Windows.ApplicationModel.Appointments.Appointment();

                // Get the selection rect of the button pressed to replace this appointment
                var rect = GetElementRect(sender as FrameworkElement);

                // ReplaceAppointmentAsync returns an updated appointment id when the appointment was successfully replaced.
                // The updated id may or may not be the same as the original one retrieved from AddAppointmentAsync.
                // An optional instance start time can be provided to indicate that a specific instance on that date should be replaced
                // in the case of a recurring appointment.
                // If the appointment id returned is an empty string, that indicates that the appointment was not replaced.
                String updatedAppointmentId;
                if (InstanceStartDateCheckBox.IsChecked.Value)
                {
                    // Replace a specific instance starting on the date provided.
                    var instanceStartDate = InstanceStartDateDatePicker.Date;
                    updatedAppointmentId = await Windows.ApplicationModel.Appointments.AppointmentManager.ShowReplaceAppointmentAsync(appointmentIdOfAppointmentToReplace, appointment, rect, Windows.UI.Popups.Placement.Default, instanceStartDate);
                }
                else
                {
                    // Replace an appointment that occurs only once or in the case of a recurring appointment, replace the entire series.
                    updatedAppointmentId = await Windows.ApplicationModel.Appointments.AppointmentManager.ShowReplaceAppointmentAsync(appointmentIdOfAppointmentToReplace, appointment, rect, Windows.UI.Popups.Placement.Default);
                }

                if (updatedAppointmentId != String.Empty)
                {
                    ResultTextBlock.Text = "Updated Appointment Id: " + updatedAppointmentId;
                }
                else
                {
                    ResultTextBlock.Text = "Appointment not replaced.";
                }
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// Replace an appointment on the user's calendar using the default appointments provider app.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void Replace_Click(object sender, RoutedEventArgs e)
        {
            // The appointment id argument for ReplaceAppointmentAsync is typically retrieved from AddAppointmentAsync and stored in app data.
            String appointmentIdOfAppointmentToReplace = AppointmentIdTextBox.Text;

            if (String.IsNullOrEmpty(appointmentIdOfAppointmentToReplace))
            {
                rootPage.NotifyUser("The appointment id cannot be empty", NotifyType.ErrorMessage);
            }
            else
            {
                // The Appointment argument for ReplaceAppointmentAsync should contain all of the Appointment's properties including those that may have changed.
                var appointment = new Windows.ApplicationModel.Appointments.Appointment();

                // Get the selection rect of the button pressed to replace this appointment
                var rect = MainPage.GetElementRect(sender as FrameworkElement);

                // ReplaceAppointmentAsync returns an updated appointment id when the appointment was successfully replaced.
                // The updated id may or may not be the same as the original one retrieved from AddAppointmentAsync.
                // An optional instance start time can be provided to indicate that a specific instance on that date should be replaced
                // in the case of a recurring appointment.
                // If the appointment id returned is an empty string, that indicates that the appointment was not replaced.
                String updatedAppointmentId;
                if (InstanceStartDateCheckBox.IsChecked.Value)
                {
                    // Replace a specific instance starting on the date provided.
                    var instanceStartDate = InstanceStartDateDatePicker.Date;
                    updatedAppointmentId = await Windows.ApplicationModel.Appointments.AppointmentManager.ShowReplaceAppointmentAsync(appointmentIdOfAppointmentToReplace, appointment, rect, Windows.UI.Popups.Placement.Default, instanceStartDate);
                }
                else
                {
                    // Replace an appointment that occurs only once or in the case of a recurring appointment, replace the entire series.
                    updatedAppointmentId = await Windows.ApplicationModel.Appointments.AppointmentManager.ShowReplaceAppointmentAsync(appointmentIdOfAppointmentToReplace, appointment, rect, Windows.UI.Popups.Placement.Default);
                }

                if (updatedAppointmentId != String.Empty)
                {
                    rootPage.NotifyUser("Updated Appointment Id: " + updatedAppointmentId, NotifyType.StatusMessage);
                }
                else
                {
                    rootPage.NotifyUser("Appointment not replaced.", NotifyType.ErrorMessage);
                }
            }
        }
        public async Task CreateAppointmentAsync(Event @event)
        {
            //  Maak afspraak voor toe te voegen in de agenda
            var appointment = new Windows.ApplicationModel.Appointments.Appointment();

            appointment.Subject   = @event.Title;
            appointment.Details   = @event.Description;
            appointment.StartTime = new DateTimeOffset(@event.Date);
            var appointmentId = await Windows.ApplicationModel.Appointments.AppointmentManager.ShowAddAppointmentAsync(appointment, new Rect());

            if (appointmentId != String.Empty)
            {
                AlertService.Toast("Afspraak gemaakt", $"Afspraak {@event.Title} toegevoegd aan uw agenda");
            }
            else
            {
                // Er ging iets fout
            }
        }
Exemplo n.º 9
0
        private async void btnVisita_Click(object sender, RoutedEventArgs e)
        {
            var appointment = new Windows.ApplicationModel.Appointments.Appointment();

            // StartTime
            var date = StartTimeDatePicker.Date;
            var time = StartTimeTimePicker.Time;
            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;
    
            appointment.Subject = txtName.Text;
            appointment.Location = txtLocal.Text;


            // Duration
            if (DurationComboBox.SelectedIndex == 0)
            {
                // 30 minute duration is selected
                appointment.Duration = TimeSpan.FromMinutes(30);
            }
            else if (DurationComboBox.SelectedIndex == 1)
            {
                // 1 hour duration is selected
                appointment.Duration = TimeSpan.FromHours(1);
            }
            else if (DurationComboBox.SelectedIndex == 2)
            {
                // 1 hour duration is selected
                appointment.Duration = TimeSpan.FromHours(2);
            }
            else
            {
                // 1 hour duration is selected
                appointment.Duration = TimeSpan.FromHours(4);
            }
            
            string appointmentId = 
                await Windows.ApplicationModel.Appointments.AppointmentManager.ShowAddAppointmentAsync(
                    appointment, 
                    Windows.Foundation.Rect.Empty);
        }
Exemplo n.º 10
0
        /// <summary>
        /// Adds an appointment to the default appointment provider app.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void Add_Click(object sender, RoutedEventArgs e)
        {
            // Create an Appointment that should be added the user's appointments provider app.
            var appointment = new Windows.ApplicationModel.Appointments.Appointment();

            // Get the selection rect of the button pressed to add this appointment
            var rect = GetElementRect(sender as FrameworkElement);

            // ShowAddAppointmentAsync returns an appointment id if the appointment given was added to the user's calendar.
            // This value should be stored in app data and roamed so that the appointment can be replaced or removed in the future.
            // An empty string return value indicates that the user canceled the operation before the appointment was added.
            String appointmentId = await Windows.ApplicationModel.Appointments.AppointmentManager.ShowAddAppointmentAsync(appointment, rect, Windows.UI.Popups.Placement.Default);
            if (appointmentId != String.Empty)
            {
                ResultTextBlock.Text = "Appointment Id: " + appointmentId;
            }
            else
            {
                ResultTextBlock.Text = "Appointment not added.";
            }
        }
Exemplo n.º 11
0
        private async void AddAppointment()
        {
            // Create an Appointment that should be added the user's appointments provider app.
            var appointment = new Windows.ApplicationModel.Appointments.Appointment();

            appointment.Subject   = Event.Name;
            appointment.StartTime = new DateTimeOffset(Event.Date);
            appointment.Location  = Event.Street + ", " + Event.ZipCode + " " + Event.City;
            String appointmentId = await Windows.ApplicationModel.Appointments.AppointmentManager.ShowAddAppointmentAsync(appointment, new Rect());

            if (appointmentId != String.Empty)
            {
                var dialogue = new MessageDialog("Created new Appointment with the ID: " + appointmentId);
                await dialogue.ShowAsync();
            }
            else
            {
                var dialogue = new MessageDialog("Failed to create new Appointment");
                await dialogue.ShowAsync();
            }
        }
Exemplo n.º 12
0
        /// <summary>
        /// Adds an appointment to the default appointment provider app.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void Add_Click(object sender, RoutedEventArgs e)
        {
            // Create an Appointment that should be added the user's appointments provider app.
            var appointment = new Windows.ApplicationModel.Appointments.Appointment();

            // Get the selection rect of the button pressed to add this appointment
            var rect = MainPage.GetElementRect(sender as FrameworkElement);

            // ShowAddAppointmentAsync returns an appointment id if the appointment given was added to the user's calendar.
            // This value should be stored in app data and roamed so that the appointment can be replaced or removed in the future.
            // An empty string return value indicates that the user canceled the operation before the appointment was added.
            String appointmentId = await Windows.ApplicationModel.Appointments.AppointmentManager.ShowAddAppointmentAsync(appointment, rect, Windows.UI.Popups.Placement.Default);

            if (appointmentId != String.Empty)
            {
                rootPage.NotifyUser("Appointment Id: " + appointmentId, NotifyType.StatusMessage);
            }
            else
            {
                rootPage.NotifyUser("Appointment not added.", NotifyType.ErrorMessage);
            }
        }
        private void GetAppointments(Pithline.FMS.BusinessLogic.Portable.SSModels.Task task)
        {
            try
            {
                var appointment = new Windows.ApplicationModel.Appointments.Appointment();

                var date           = task.AppointmentStart.Date;
                var time           = task.AppointmentEnd.TimeOfDay - task.AppointmentStart.TimeOfDay;
                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;
                appointment.Subject   = task.CaseNumber;
                appointment.Location  = task.Address;
                appointment.Details   = task.Description;
                appointment.Duration  = TimeSpan.FromHours(1);
                appointment.Reminder  = TimeSpan.FromMinutes(15);
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemplo n.º 14
0
        private async void addEvenement(object sender, RoutedEventArgs e)
        {
            Evenement   evenement   = (sender as Button).DataContext as Evenement;
            Onderneming onderneming = DataContext as Onderneming;
            // Create an Appointment that should be added the user's appointments provider app.
            var appointment = new Windows.ApplicationModel.Appointments.Appointment();

            //Locatie
            appointment.Location = evenement.Plaats;
            //Naam
            appointment.Subject = "Evenement van " + onderneming.Naam;
            //Details
            appointment.Details = evenement.Beschrijving;

            appointment.StartTime = evenement.Datum;

            var rect = new Rect();
            // ShowAddAppointmentAsync returns an appointment id if the appointment given was added to the user's calendar.
            // This value should be stored in app data and roamed so that the appointment can be replaced or removed in the future.
            // An empty string return value indicates that the user canceled the operation before the appointment was added.
            String appointmentId = await Windows.ApplicationModel.Appointments.AppointmentManager.ShowAddAppointmentAsync(
                appointment, rect, Windows.UI.Popups.Placement.Default);
        }
Exemplo n.º 15
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);



        }
Exemplo n.º 16
0
        private async void Button_Click(object sender, RoutedEventArgs e)
        {
            bool isAppointmentValid = true;
            var appointment = new Windows.ApplicationModel.Appointments.Appointment();


            // StartTime
            var date = StartTimeDatePicker.Date;
            var time = StartTimeTimePicker.Time;
            //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
            appointment.Subject = SubjectTextBox.Text;

            if (appointment.Subject.Length > 255)
            {
                isAppointmentValid = false;
                //  ResultTextBlock.Text = "The subject cannot be greater than 255 characters.";
            }

            // Location
            //appointment.Location = LocationTextBox.Text;
            /*
            if (appointment.Location.Length > 32768)
            {
                isAppointmentValid = false;
                ResultTextBlock.Text = "The location cannot be greater than 32,768 characters.";
            }
             * */

            // Details
            appointment.Details = DetailsTextBox.Text;

            if (appointment.Details.Length > 1073741823)
            {
                isAppointmentValid = false;
                //ResultTextBlock.Text = "The details cannot be greater than 1,073,741,823 characters.";
            }


            /*
            // All Day
            appointment.AllDay = AllDayCheckBox.IsChecked.Value;

            // Reminder
            if (ReminderCheckBox.IsChecked.Value)
            {
                switch (ReminderComboBox.SelectedIndex)
                {
                    case 0:
                        appointment.Reminder = TimeSpan.FromMinutes(15);
                        break;
                    case 1:
                        appointment.Reminder = TimeSpan.FromHours(1);
                        break;
                    case 2:
                        appointment.Reminder = TimeSpan.FromDays(1);
                        break;
                }
            }

            */

            if (isAppointmentValid)
            {
                var rect = GetElementRect(sender as FrameworkElement);

                // ShowAddAppointmentAsync returns an appointment id if the appointment given was added to the user's calendar.
                // This value should be stored in app data and roamed so that the appointment can be replaced or removed in the future.
                // An empty string return value indicates that the user canceled the operation before the appointment was added.
                String appointmentId = await Windows.ApplicationModel.Appointments.AppointmentManager.ShowAddAppointmentAsync(
                                       appointment, rect, Windows.UI.Popups.Placement.Default);
                // ResultTextBlock.Text = "The event was created successfully and a tile was placed.";



                //  String tileid = long.Parse(appointmentId).ToString();
                // int tidl = tileid.Length;
                if (appointmentId != null)
                {
                    //id = id + 1;

                    await TileInfoDataSource.AddTile(new TileInfo()
                    {
                        Name = SubjectTextBox.Text
                    });


                    string tileid = TileInfoDataSource.latestID.ToString();

                    //pining the tile
                    Uri square150x150Logo = new Uri("ms-appx:///Assets/square150x150Tile-sdk.png");

                    String tileActivationArguments = tileid + " WasPinnedAt=" + DateTime.Now.ToLocalTime().ToString();

                    SecondaryTile secondaryTile = new SecondaryTile(tileid,
                                                                        SubjectTextBox.Text,
                                                                         tileActivationArguments,
                                                                         square150x150Logo,
                                                                         TileSize.Square150x150);

                    secondaryTile.VisualElements.ShowNameOnSquare150x150Logo = true;
                    secondaryTile.VisualElements.ForegroundText = ForegroundText.Dark;
                    await secondaryTile.RequestCreateAsync();
                }
            }

        }
Exemplo n.º 17
0
        /// <summary>
        /// Creates an Appointment based on the input fields and validates it.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Create_Click(object sender, RoutedEventArgs e)
        {
            bool isAppointmentValid = true;
            var  appointment        = new Windows.ApplicationModel.Appointments.Appointment();

            // StartTime
            var date           = StartTimeDatePicker.Date;
            var time           = StartTimeTimePicker.Time;
            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
            appointment.Subject = SubjectTextBox.Text;

            if (appointment.Subject.Length > 255)
            {
                isAppointmentValid   = false;
                ResultTextBlock.Text = "The subject cannot be greater than 255 characters.";
            }

            // Location
            appointment.Location = LocationTextBox.Text;

            if (appointment.Location.Length > 32768)
            {
                isAppointmentValid   = false;
                ResultTextBlock.Text = "The location cannot be greater than 32,768 characters.";
            }

            // Details
            appointment.Details = DetailsTextBox.Text;

            if (appointment.Details.Length > 1073741823)
            {
                isAppointmentValid   = false;
                ResultTextBlock.Text = "The details cannot be greater than 1,073,741,823 characters.";
            }

            // Duration
            if (DurationComboBox.SelectedIndex == 0)
            {
                // 30 minute duration is selected
                appointment.Duration = TimeSpan.FromMinutes(30);
            }
            else
            {
                // 1 hour duration is selected
                appointment.Duration = TimeSpan.FromHours(1);
            }

            // All Day
            appointment.AllDay = AllDayCheckBox.IsChecked.Value;

            // Reminder
            if (ReminderCheckBox.IsChecked.Value)
            {
                switch (ReminderComboBox.SelectedIndex)
                {
                case 0:
                    appointment.Reminder = TimeSpan.FromMinutes(15);
                    break;

                case 1:
                    appointment.Reminder = TimeSpan.FromHours(1);
                    break;

                case 2:
                    appointment.Reminder = TimeSpan.FromDays(1);
                    break;
                }
            }

            //Busy Status
            switch (BusyStatusComboBox.SelectedIndex)
            {
            case 0:
                appointment.BusyStatus = Windows.ApplicationModel.Appointments.AppointmentBusyStatus.Busy;
                break;

            case 1:
                appointment.BusyStatus = Windows.ApplicationModel.Appointments.AppointmentBusyStatus.Tentative;
                break;

            case 2:
                appointment.BusyStatus = Windows.ApplicationModel.Appointments.AppointmentBusyStatus.Free;
                break;

            case 3:
                appointment.BusyStatus = Windows.ApplicationModel.Appointments.AppointmentBusyStatus.OutOfOffice;
                break;

            case 4:
                appointment.BusyStatus = Windows.ApplicationModel.Appointments.AppointmentBusyStatus.WorkingElsewhere;
                break;
            }

            // Sensitivity
            switch (SensitivityComboBox.SelectedIndex)
            {
            case 0:
                appointment.Sensitivity = Windows.ApplicationModel.Appointments.AppointmentSensitivity.Public;
                break;

            case 1:
                appointment.Sensitivity = Windows.ApplicationModel.Appointments.AppointmentSensitivity.Private;
                break;
            }

            // Uri
            if (UriTextBox.Text.Length > 0)
            {
                try
                {
                    appointment.Uri = new System.Uri(UriTextBox.Text);
                }
                catch (Exception)
                {
                    isAppointmentValid   = false;
                    ResultTextBlock.Text = "The Uri provided is invalid.";
                }
            }

            // Organizer
            // Note: Organizer can only be set if there are no invitees added to this appointment.
            if (OrganizerRadioButton.IsChecked.Value)
            {
                var organizer = new Windows.ApplicationModel.Appointments.AppointmentOrganizer();

                // Organizer Display Name
                organizer.DisplayName = OrganizerDisplayNameTextBox.Text;

                if (organizer.DisplayName.Length > 256)
                {
                    isAppointmentValid   = false;
                    ResultTextBlock.Text = "The organizer display name cannot be greater than 256 characters.";
                }
                else
                {
                    // Organizer Address (e.g. Email Address)
                    organizer.Address = OrganizerAddressTextBox.Text;

                    if (organizer.Address.Length > 321)
                    {
                        isAppointmentValid   = false;
                        ResultTextBlock.Text = "The organizer address cannot be greater than 321 characters.";
                    }
                    else if (organizer.Address.Length == 0)
                    {
                        isAppointmentValid   = false;
                        ResultTextBlock.Text = "The organizer address must be greater than 0 characters.";
                    }
                    else
                    {
                        appointment.Organizer = organizer;
                    }
                }
            }

            // Invitees
            // Note: If the size of the Invitees list is not zero, then an Organizer cannot be set.
            if (InviteeRadioButton.IsChecked.Value)
            {
                var invitee = new Windows.ApplicationModel.Appointments.AppointmentInvitee();

                // Invitee Display Name
                invitee.DisplayName = InviteeDisplayNameTextBox.Text;

                if (invitee.DisplayName.Length > 256)
                {
                    isAppointmentValid   = false;
                    ResultTextBlock.Text = "The invitee display name cannot be greater than 256 characters.";
                }
                else
                {
                    // Invitee Address (e.g. Email Address)
                    invitee.Address = InviteeAddressTextBox.Text;

                    if (invitee.Address.Length > 321)
                    {
                        isAppointmentValid   = false;
                        ResultTextBlock.Text = "The invitee address cannot be greater than 321 characters.";
                    }
                    else if (invitee.Address.Length == 0)
                    {
                        isAppointmentValid   = false;
                        ResultTextBlock.Text = "The invitee address must be greater than 0 characters.";
                    }
                    else
                    {
                        // Invitee Role
                        switch (RoleComboBox.SelectedIndex)
                        {
                        case 0:
                            invitee.Role = Windows.ApplicationModel.Appointments.AppointmentParticipantRole.RequiredAttendee;
                            break;

                        case 1:
                            invitee.Role = Windows.ApplicationModel.Appointments.AppointmentParticipantRole.OptionalAttendee;
                            break;

                        case 2:
                            invitee.Role = Windows.ApplicationModel.Appointments.AppointmentParticipantRole.Resource;
                            break;
                        }

                        // Invitee Response
                        switch (ResponseComboBox.SelectedIndex)
                        {
                        case 0:
                            invitee.Response = Windows.ApplicationModel.Appointments.AppointmentParticipantResponse.None;
                            break;

                        case 1:
                            invitee.Response = Windows.ApplicationModel.Appointments.AppointmentParticipantResponse.Tentative;
                            break;

                        case 2:
                            invitee.Response = Windows.ApplicationModel.Appointments.AppointmentParticipantResponse.Accepted;
                            break;

                        case 3:
                            invitee.Response = Windows.ApplicationModel.Appointments.AppointmentParticipantResponse.Declined;
                            break;

                        case 4:
                            invitee.Response = Windows.ApplicationModel.Appointments.AppointmentParticipantResponse.Unknown;
                            break;
                        }

                        appointment.Invitees.Add(invitee);
                    }
                }
            }

            if (isAppointmentValid)
            {
                ResultTextBlock.Text = "The appointment was created successfully and is valid.";
            }
        }
        /// <summary>
        /// Creates an Appointment based on the input fields and validates it.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Create_Click(object sender, RoutedEventArgs e)
        {
            string errorMessage = null;
            var appointment = new Windows.ApplicationModel.Appointments.Appointment();

            // StartTime
            var date = StartTimeDatePicker.Date;
            var time = StartTimeTimePicker.Time;
            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
            appointment.Subject = SubjectTextBox.Text;

            if (appointment.Subject.Length > 255)
            {
                errorMessage = "The subject cannot be greater than 255 characters.";
            }

            // Location
            appointment.Location = LocationTextBox.Text;

            if (appointment.Location.Length > 32768)
            {
                errorMessage = "The location cannot be greater than 32,768 characters.";
            }

            // Details
            appointment.Details = DetailsTextBox.Text;

            if (appointment.Details.Length > 1073741823)
            {
                errorMessage = "The details cannot be greater than 1,073,741,823 characters.";
            }

            // Duration
            if (DurationComboBox.SelectedIndex == 0)
            {
                // 30 minute duration is selected
                appointment.Duration = TimeSpan.FromMinutes(30);
            }
            else
            {
                // 1 hour duration is selected
                appointment.Duration = TimeSpan.FromHours(1);
            }

            // All Day
            appointment.AllDay = AllDayCheckBox.IsChecked.Value;

            // Reminder
            if (ReminderCheckBox.IsChecked.Value)
            {
                switch (ReminderComboBox.SelectedIndex)
                {
                    case 0:
                        appointment.Reminder = TimeSpan.FromMinutes(15);
                        break;
                    case 1:
                        appointment.Reminder = TimeSpan.FromHours(1);
                        break;
                    case 2:
                        appointment.Reminder = TimeSpan.FromDays(1);
                        break;
                }
            }

            //Busy Status
            switch (BusyStatusComboBox.SelectedIndex)
            {
                case 0:
                    appointment.BusyStatus = Windows.ApplicationModel.Appointments.AppointmentBusyStatus.Busy;
                    break;
                case 1:
                    appointment.BusyStatus = Windows.ApplicationModel.Appointments.AppointmentBusyStatus.Tentative;
                    break;
                case 2:
                    appointment.BusyStatus = Windows.ApplicationModel.Appointments.AppointmentBusyStatus.Free;
                    break;
                case 3:
                    appointment.BusyStatus = Windows.ApplicationModel.Appointments.AppointmentBusyStatus.OutOfOffice;
                    break;
                case 4:
                    appointment.BusyStatus = Windows.ApplicationModel.Appointments.AppointmentBusyStatus.WorkingElsewhere;
                    break;
            }

            // Sensitivity
            switch (SensitivityComboBox.SelectedIndex)
            {
                case 0:
                    appointment.Sensitivity = Windows.ApplicationModel.Appointments.AppointmentSensitivity.Public;
                    break;
                case 1:
                    appointment.Sensitivity = Windows.ApplicationModel.Appointments.AppointmentSensitivity.Private;
                    break;
            }

            // Uri
            if (UriTextBox.Text.Length > 0)
            {
                try
                {
                    appointment.Uri = new System.Uri(UriTextBox.Text);
                }
                catch (Exception)
                {
                    errorMessage = "The Uri provided is invalid.";
                }
            }

            // Organizer
            // Note: Organizer can only be set if there are no invitees added to this appointment.
            if (OrganizerRadioButton.IsChecked.Value)
            {
                var organizer = new Windows.ApplicationModel.Appointments.AppointmentOrganizer();

                // Organizer Display Name
                organizer.DisplayName = OrganizerDisplayNameTextBox.Text;

                if (organizer.DisplayName.Length > 256)
                {
                    errorMessage = "The organizer display name cannot be greater than 256 characters.";
                }
                else
                {
                    // Organizer Address (e.g. Email Address)
                    organizer.Address = OrganizerAddressTextBox.Text;

                    if (organizer.Address.Length > 321)
                    {
                        errorMessage = "The organizer address cannot be greater than 321 characters.";
                    }
                    else if (organizer.Address.Length == 0)
                    {
                        errorMessage = "The organizer address must be greater than 0 characters.";
                    }
                    else
                    {
                        appointment.Organizer = organizer;
                    }
                }
            }

            // Invitees
            // Note: If the size of the Invitees list is not zero, then an Organizer cannot be set.
            if (InviteeRadioButton.IsChecked.Value)
            {
                var invitee = new Windows.ApplicationModel.Appointments.AppointmentInvitee();

                // Invitee Display Name
                invitee.DisplayName = InviteeDisplayNameTextBox.Text;

                if (invitee.DisplayName.Length > 256)
                {
                    errorMessage = "The invitee display name cannot be greater than 256 characters.";
                }
                else
                {
                    // Invitee Address (e.g. Email Address)
                    invitee.Address = InviteeAddressTextBox.Text;

                    if (invitee.Address.Length > 321)
                    {
                        errorMessage = "The invitee address cannot be greater than 321 characters.";
                    }
                    else if (invitee.Address.Length == 0)
                    {
                        errorMessage = "The invitee address must be greater than 0 characters.";
                    }
                    else
                    {
                        // Invitee Role
                        switch (RoleComboBox.SelectedIndex)
                        {
                            case 0:
                                invitee.Role = Windows.ApplicationModel.Appointments.AppointmentParticipantRole.RequiredAttendee;
                                break;
                            case 1:
                                invitee.Role = Windows.ApplicationModel.Appointments.AppointmentParticipantRole.OptionalAttendee;
                                break;
                            case 2:
                                invitee.Role = Windows.ApplicationModel.Appointments.AppointmentParticipantRole.Resource;
                                break;
                        }

                        // Invitee Response
                        switch (ResponseComboBox.SelectedIndex)
                        {
                            case 0:
                                invitee.Response = Windows.ApplicationModel.Appointments.AppointmentParticipantResponse.None;
                                break;
                            case 1:
                                invitee.Response = Windows.ApplicationModel.Appointments.AppointmentParticipantResponse.Tentative;
                                break;
                            case 2:
                                invitee.Response = Windows.ApplicationModel.Appointments.AppointmentParticipantResponse.Accepted;
                                break;
                            case 3:
                                invitee.Response = Windows.ApplicationModel.Appointments.AppointmentParticipantResponse.Declined;
                                break;
                            case 4:
                                invitee.Response = Windows.ApplicationModel.Appointments.AppointmentParticipantResponse.Unknown;
                                break;
                        }

                        appointment.Invitees.Add(invitee);
                    }
                }
            }

            if (errorMessage == null)
            {
                rootPage.NotifyUser("The appointment was created successfully and is valid.", NotifyType.StatusMessage);
            }
            else
            {
                rootPage.NotifyUser(errorMessage, NotifyType.ErrorMessage);
            }
        }