コード例 #1
0
        private async void SubmitBarBtn_Click(object sender, RoutedEventArgs e)
        {
            Appointment c = new Appointment();

            //validate FirstName is empty
            if (String.IsNullOrEmpty(AppNameTxtBox.Text))
            {
                MessageDialog md = new MessageDialog("Please write Name in field", "Wrong Name");
                await md.ShowAsync();

                AppNameTxtBox.Focus(FocusState.Programmatic);
                AppNameTxtBox.SelectAll();
                return;
            }
            else
            {
                c.EventName = AppNameTxtBox.Text;
            }

            //validate LastName is empty
            if (String.IsNullOrEmpty(AppLocTxtBox.Text))
            {
                MessageDialog md = new MessageDialog("Please write the Location in field", "Wrong Location");
                await md.ShowAsync();

                AppLocTxtBox.Focus(FocusState.Programmatic);
                AppLocTxtBox.SelectAll();
                return;
            }
            else
            {
                c.EventLocation = AppLocTxtBox.Text;
            }

            //validate CompanyName is empty
            if (String.IsNullOrEmpty(StartTimeTxtBox.Text))
            {
                MessageDialog md = new MessageDialog("Please write Time in field", "Wrong Start Time");
                await md.ShowAsync();

                StartTimeTxtBox.Focus(FocusState.Programmatic);
                StartTimeTxtBox.SelectAll();
                return;
            }
            else
            {
                c.EventStartTime = StartTimeTxtBox.Text;
            }

            //validate Mobile number is empty
            if (String.IsNullOrEmpty(EndTimeTxtBox.Text))
            {
                MessageDialog md = new MessageDialog("Please write Time in field", "Wrong End Time");
                await md.ShowAsync();

                EndTimeTxtBox.Focus(FocusState.Programmatic);
                EndTimeTxtBox.SelectAll();
                return;
            }
            else
            {
                c.EventEndTime = EndTimeTxtBox.Text;
            }

            viewModel.AddNewAppointment(c);


            Frame.Navigate(typeof(AppointmentPage));
        }
コード例 #2
0
        private async void UpdateBarBtn_Click(object sender, RoutedEventArgs e)
        {
            Appointment c = new Appointment();

            //validate FirstName is empty
            if (String.IsNullOrEmpty(AppNameTxtBox.Text))
            {
                MessageDialog md = new MessageDialog("Please write Name in field", "Wrong Name");
                await md.ShowAsync();

                AppNameTxtBox.Focus(FocusState.Programmatic);
                AppNameTxtBox.SelectAll();
                return;
            }
            else
            {
                c.EventName = AppNameTxtBox.Text;
            }

            //validate LastName is empty
            if (String.IsNullOrEmpty(AppLocTxtBox.Text))
            {
                MessageDialog md = new MessageDialog("Please write Location in field", "Wrong Location");
                await md.ShowAsync();

                AppLocTxtBox.Focus(FocusState.Programmatic);
                AppLocTxtBox.SelectAll();
                return;
            }
            else
            {
                c.EventLocation = AppLocTxtBox.Text;
            }

            //validate CompanyName is empty
            if (String.IsNullOrEmpty(StartTimeTxtBox.Text))
            {
                MessageDialog md = new MessageDialog("Please write Time in field", "Wrong Start Time");
                await md.ShowAsync();

                StartTimeTxtBox.Focus(FocusState.Programmatic);
                StartTimeTxtBox.SelectAll();
                return;
            }
            else
            {
                c.EventStartTime = StartTimeTxtBox.Text;
            }

            //validate Mobile number is empty
            if (String.IsNullOrEmpty(EndTimeTxtBox.Text))
            {
                MessageDialog md = new MessageDialog("Please write Time in field", "Wrong End Time");
                await md.ShowAsync();

                EndTimeTxtBox.Focus(FocusState.Programmatic);
                EndTimeTxtBox.SelectAll();
                return;
            }
            else
            {
                c.EventEndTime = EndTimeTxtBox.Text;
            }


            //show update is successed
            if (viewModel.SaveEditedProduct(viewModel.Appointment))
            {
                MessageDialog md = new MessageDialog("Appointment changes updated", "UPDATE OUTCOME");
                await md.ShowAsync();
            }
            else
            {
                MessageDialog md = new MessageDialog("Appointment changes NOT updated", "UPDATE OUTCOME");
                await md.ShowAsync();
            }

            Frame.Navigate(typeof(AppointmentViewPage), viewModel.Appointment.EventID);
        }