private void FormAddEditAndContact_FormClosing(object sender, FormClosingEventArgs e) { if (DialogResult == DialogResult.OK) { if (string.IsNullOrEmpty(txtName.Text)) { MessageBox.Show("Veuillez entrez le nom de votre contact !", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information); txtName.Focus(); e.Cancel = true; return; } if (IsNew) { ContactServices.Insert(contactBindingSource.Current as Contact); } else { ContactServices.Update(contactBindingSource.Current as Contact); } } }