private void btnEnr_Click(object sender, EventArgs e) { if (txtAdresse.Text == "" || txtCp.Text == "" || txtNom.Text == "" || txtVille.Text == "") { MessageBox.Show("Veuillez remplir les champs.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { if (btnEnr.Text == "Ajouter") { var dataSite = new Data_Sites(txtNom.Text.Trim(), txtAdresse.Text.Trim(), txtCp.Text.Trim(), txtVille.Text.Trim()); Fcts_Sites.AjouterSite(dataSite); } else if (btnEnr.Text == "Modifier") { var dataSite = new Data_Sites(txtNom.Text.Trim(), txtAdresse.Text.Trim(), txtCp.Text.Trim(), txtVille.Text.Trim()); Fcts_Sites.ModifierSite(dataSite, id); } } _parent.Display(); }
private void dgvSites_CellClick(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex == 0) { formAm.id = dgvSites.Rows[e.RowIndex].Cells[2].Value.ToString(); formAm.nom = dgvSites.Rows[e.RowIndex].Cells[3].Value.ToString(); formAm.adresse = dgvSites.Rows[e.RowIndex].Cells[4].Value.ToString(); formAm.cp = dgvSites.Rows[e.RowIndex].Cells[5].Value.ToString(); formAm.ville = dgvSites.Rows[e.RowIndex].Cells[6].Value.ToString(); formAm.ModifSite(); formAm.ShowDialog(); } else if (e.ColumnIndex == 1) { if (MessageBox.Show("Voulez vous vraiment le site " + formAm.nom + " ?", "Information", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question) == DialogResult.Yes) { Fcts_Sites.SupprSite(dgvSites.Rows[e.RowIndex].Cells[2].Value.ToString()); Display(); } } }