private void InsertButton_Click(object sender, RoutedEventArgs e) { #region validation ForceValidation(); if (Validation.GetHasError(NameTextBox) || Validation.GetHasError(AddressTextBox) || Validation.GetHasError(EmailTextBox) || Validation.GetHasError(PhoneNoTextBox)) { var sMessageDialog = new MessageDialog { Message = { Text = "ERROR: Fill required fields!" } }; DialogHost.Show(sMessageDialog, "RootDialog"); return; } #endregion Contact comp = new Contact(); comp.CompanyName = NameTextBox.Text; comp.Phone = PhoneNoTextBox.Text; comp.Email = EmailTextBox.Text; comp.Address = AddressTextBox.Text; ContactFactory fac = new ContactFactory(); if (fac.InsertContact(comp)) { var sMessageDialog = new MessageDialog { Message = { Text = "Added succesfully!" } }; DialogHost.Show(sMessageDialog, "RootDialog"); Clear(); return; } else { var sMessageDialog = new MessageDialog { Message = { Text = "Unable to add..." } }; DialogHost.Show(sMessageDialog, "RootDialog"); return; } }