コード例 #1
0
 private bool validatePatient()
 {
     if (BirthDateEditTextBox.IsFocused)
     {
         BirthDateEditTextBox.GetBindingExpression(TextBox.TextProperty).UpdateSource();
     }
     if (FirstNameEditTextBox.Text.Equals(string.Empty))
     {
         MessageBox.Show("First Name can't be null");
         FirstNameEditTextBox.Focus();
         return(false);
     }
     if (LastNameEditTextBox.Text.Equals(string.Empty))
     {
         MessageBox.Show("Last Name can't be null");
         LastNameEditTextBox.Focus();
         return(false);
     }
     if (GenderListBox.SelectedItem.Equals(string.Empty))
     {
         MessageBox.Show("Gender can't be null");
         GenderListBox.Focus();
         return(false);
     }
     if (BirthDateEditTextBox.Text.Equals(string.Empty))
     {
         MessageBox.Show("Birth Date can't be null");
         BirthDateEditTextBox.Focus();
         return(false);
     }
     if (BirthPlaceEditTextBox.Text.Equals(string.Empty))
     {
         MessageBox.Show("Birth Place can't be null");
         BirthPlaceEditTextBox.Focus();
         return(false);
     }
     if (Address1EditTextBox.Text.Equals(string.Empty))
     {
         MessageBox.Show("Address can't be null");
         Address1EditTextBox.Focus();
         return(false);
     }
     if (PhoneEditTextBox.Text.Equals(string.Empty))
     {
         MessageBox.Show("Phone can't be null");
         PhoneEditTextBox.Focus();
         return(false);
     }
     return(true);
 }
コード例 #2
0
        private void DoneEditButton_Click(object sender, RoutedEventArgs e)
        {
            // Make sure the data binding is updated for fields that update during LostFocus.
            // This is necessary since this method can be invoked when the Enter key is pressed,
            // but the text field has not lost focus yet, so it does not update binding. This
            // manually updates the binding for those fields.
            if (BirthDateEditTextBox.IsFocused)
            {
                BirthDateEditTextBox.GetBindingExpression(TextBox.TextProperty).UpdateSource();
            }
            if (DeathDateEditTextBox.IsFocused)
            {
                DeathDateEditTextBox.GetBindingExpression(TextBox.TextProperty).UpdateSource();
            }

            // Let the collection know that it has been updated so that the diagram control will update.
            family.OnContentChanged();
        }