private void buttonValidAjout_Click(object sender, EventArgs e) { if (Verif() == false) { MessageBox.Show("Veuillez compléter toutes les zones de saisies"); } else { try { garage unGarage = new garage(); unGarage.nomG = txtNomGarage.Text; unGarage.telG = txtTelephone.Text; unGarage.idType = Convert.ToInt16(comboTypeGarage.SelectedValue); unGarage.adresseG = txtAdresse.Text; unGarage.cpG = txtCodePostal.Text; unGarage.emailG = txtEmail.Text; db.garage.Add(unGarage); db.SaveChanges(); chargerDataGrind(); deverouillerVerrouiller(); MessageBox.Show("Modification effectuée"); chargerDataGrind(); } catch (Exception ex) { MessageBox.Show(ex.Message); deverouillerVerrouiller(); } //Activation / Désactivation des boutons buttonModif.Visible = true; buttonAjouterUtil.Visible = true; buttonSupprimer.Visible = true; buttonValidAjout.Visible = false; buttonAnnuler.Visible = false; AffecterValeurs(0); } txtNumGarage.Visible = true; label1.Visible = true; }
private void buttonValidModif_Click(object sender, EventArgs e) { if (Verif() == false) { MessageBox.Show("Veuillez compléter toutes les zones de saisies"); } else { try { garage unGarage = db.garage.First(g => g.idGarage.ToString() == txtNumGarage.Text); unGarage.nomG = txtNomGarage.Text; unGarage.idGarage = Convert.ToInt16(txtNumGarage.Text); unGarage.telG = txtTelephone.Text; unGarage.idType = Convert.ToInt16(comboTypeGarage.SelectedValue); unGarage.adresseG = txtAdresse.Text; unGarage.cpG = txtCodePostal.Text; unGarage.emailG = txtEmail.Text; db.SaveChanges(); chargerDataGrind(); MessageBox.Show("Modification effectuée"); } catch (Exception ex) { MessageBox.Show(ex.Message); } buttonModif.Visible = true; buttonSupprimer.Visible = true; buttonValidModif.Visible = false; buttonAnnuler.Visible = false; Verrou(); deverouillerVerrouiller(); } }