public void buttonOK_Click(object sender, EventArgs e) { // test si tout les champs sont remplis if (TextBoxLibelle.Text != "" && comboBoxIntervenant.Text != "" && comboBoxType.SelectedIndex != -1 && ComboBoxDate.SelectedIndex != -1 && verifHeure(ComboBoxHeureD.Text) == true && verifHeure(ComboBoxHeureF.Text) == true) { idIntervenant = recupIntervenant(comboBoxIntervenant.SelectedIndex); if (idIntervenant != 0) { libelle = TextBoxLibelle.Text; idDate = recupDate(ComboBoxDate.SelectedIndex); idType = recupType(comboBoxType.Text); heureD = Convert.ToDateTime(ComboBoxHeureD.Text + ":00"); heureF = Convert.ToDateTime(ComboBoxHeureF.Text + ":00"); TimeSpan heureDebut = new TimeSpan(heureD.Hour, heureD.Minute, heureD.Second); TimeSpan heureFin = new TimeSpan(heureF.Hour, heureF.Minute, heureF.Second); if (verifDemiJourne(idDate, heureDebut) == true) { if (heureDebut < heureFin) { if (TextBoxPlaces.Text != "") { nbrPlaces = Convert.ToInt32(TextBoxPlaces.Text); } if (TextBoxSalle.Text != "") { salle = TextBoxSalle.Text; } if (RichTextBoxDescription.Text != "") { description = RichTextBoxDescription.Text; } if (comboBoxPublic.Text != "") { publ = comboBoxPublic.Text; } if (richTextBoxEntete.Text != "") { entete = richTextBoxEntete.Text; } code = calculCode(idType, comboBoxType.Text); if (idActivite == 0) { Controleur.ajouterActivite(idDate, idType, heureDebut, heureFin, libelle, nbrPlaces, salle, description, code, entete, publ); Controleur.ajouterAnime(idIntervenant); comboBoxIntervenant.Text = ""; TextBoxLibelle.Text = ""; ComboBoxHeureD.Text = ""; ComboBoxHeureF.Text = ""; TextBoxPlaces.Text = ""; TextBoxSalle.Text = ""; RichTextBoxDescription.Text = ""; comboBoxIntervenant.SelectedIndex = -1; ComboBoxDate.SelectedIndex = -1; richTextBoxEntete.Text = ""; comboBoxPublic.Text = "Tout public"; TextBoxLibelle.BackColor = Color.White; comboBoxIntervenant.BackColor = Color.White; comboBoxType.BackColor = Color.White; ComboBoxDate.BackColor = Color.White; ComboBoxHeureD.BackColor = Color.White; ComboBoxHeureF.BackColor = Color.White; } else { Controleur.modifierAnime(idActivite, idIntervenant); Controleur.modifierActivite(idActivite, idDate, idType, heureDebut, heureFin, libelle, nbrPlaces, salle, description, entete, publ); this.Close(); } } else { MessageBox.Show("l'heure de debut est après l'heure de fin"); } } } else { MessageBox.Show("l'intervenant n'existe pas"); } } else { MessageBox.Show("Veuillez remplir tous les champs"); if (TextBoxLibelle.Text == "") { TextBoxLibelle.BackColor = Color.Red; } else { TextBoxLibelle.BackColor = Color.White; } if (comboBoxIntervenant.SelectedIndex == -1) { comboBoxIntervenant.BackColor = Color.Red; } else { comboBoxIntervenant.BackColor = Color.White; } if (comboBoxType.SelectedIndex == -1) { comboBoxType.BackColor = Color.Red; } else { comboBoxType.BackColor = Color.White; } if (ComboBoxDate.SelectedIndex == -1) { ComboBoxDate.BackColor = Color.Red; } else { ComboBoxDate.BackColor = Color.White; } if (verifHeure(ComboBoxHeureD.Text) == false) { ComboBoxHeureD.BackColor = Color.Red; } else { ComboBoxHeureD.BackColor = Color.White; } if (verifHeure(ComboBoxHeureF.Text) == false) { ComboBoxHeureF.BackColor = Color.Red; } else { ComboBoxHeureF.BackColor = Color.White; } } }