private void dgvClients_CellClick(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex == 0) { formAm.id = dgvClients.Rows[e.RowIndex].Cells[2].Value.ToString(); formAm.nom = dgvClients.Rows[e.RowIndex].Cells[3].Value.ToString(); formAm.adresse = dgvClients.Rows[e.RowIndex].Cells[4].Value.ToString(); formAm.ModifClient(); formAm.ShowDialog(); } else if (e.ColumnIndex == 1) { if (MessageBox.Show("Voulez-vous vraiment supprimer ce client ?", "Information", MessageBoxButtons.YesNoCancel) == DialogResult.Yes) { Fcts_Clients.SupprClient(dgvClients.Rows[e.RowIndex].Cells[2].Value.ToString()); Display(); } } }
private void btnEnr_Click(object sender, EventArgs e) { if (txtNom.Text == "" || txtAdresse.Text == "") { MessageBox.Show("Veuillez remplir les champs.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { if (btnEnr.Text == "Ajouter") { var dataClient = new Data_Clients(txtNom.Text.Trim(), txtAdresse.Text.Trim()); Fcts_Clients.AjouterClient(dataClient); } else if (btnEnr.Text == "Modifier") { var dataClient = new Data_Clients(txtNom.Text.Trim(), txtAdresse.Text.Trim()); Fcts_Clients.ModifierClient(dataClient, id); } } _parent.Display(); }