private void Form_gestionReservation_achat_Load(object sender, EventArgs e) { #region Loading comboBox choix Adhérent //On désactive l'évenement pour ne pas que la méthode SelectedIndexChanged se lance lors du binding au dataSource this.cb_gestionReservation_achat_adherent.SelectedIndexChanged -= new EventHandler(cb_gestionReservation_achat_adherent_SelectedIndexChanged); cb_gestionReservation_achat_adherent.DataSource = GestionClub.getTousLesAdherents(); cb_gestionReservation_achat_adherent.DisplayMember = "EtatCivil"; cb_gestionReservation_achat_adherent.ValueMember = "Numero"; //On désélectionne les valeurs (ici le DataSource séléctionne par défaut la première valeur de la liste) cb_gestionReservation_achat_adherent.SelectedIndex = -1; //On réactive l'évènement pour pouvoir accéder à la méthode SelectedIndexChanged lors des conditions requises this.cb_gestionReservation_achat_adherent.SelectedIndexChanged += new EventHandler(cb_gestionReservation_achat_adherent_SelectedIndexChanged); #endregion #region Loading comboBox nbPlaces int i = 0; foreach (int nbPlaces in GestionClub.getParamNbPlacesAchetables()) { cb_gestionReservation_achat_nbPlaces.Items.Add(GestionClub.getParamNbPlacesAchetables()[i]); i++; } #endregion }
private void bt_gestionAdherent_afficher_delete_Click(object sender, EventArgs e) { //Si l'utilisateur sélectionne une ligne if (dgv_gestionAdherent_Afficher.SelectedRows.Count == 1) { //Dialog box de confirmation de choix avant la suppression DialogResult dialogResult = MessageBox.Show("Êtes vous sur de vouloir supprimer l'adhérent ?", "Suppresssion", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (dialogResult == DialogResult.Yes) { int selectedRowIndex = dgv_gestionAdherent_Afficher.SelectedCells[0].RowIndex; DataGridViewRow selectedRow = dgv_gestionAdherent_Afficher.Rows[selectedRowIndex]; int numeroAdherent = Convert.ToInt32(selectedRow.Cells[0].Value); //Supprime l'adhérent de la liste à l'index où se trouve le num Adhérent correspondant (mais ne supprime pas l'adhérent) GestionClub.getTousLesAdherents().RemoveAt(GestionClub.getIndexOfAdherent(numeroAdherent)); MessageBox.Show("Vous avez bien supprimé l'adhérent"); Form_gestionAdherent_Afficher.ActiveForm.Close(); } } //Si aucune ligne n'a été sélectionnée else { MessageBox.Show("Veuillez d'abord sélectionner la ligne correspondant à l'adhérent que vous souhaitez supprimer. \n \n Pour cela utiliser la flèche au début de la ligne.", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private void bt_gestionReservation_achat_valider_Click(object sender, EventArgs e) { int index = GestionClub.getIndexOfAdherent(Convert.ToInt32(cb_gestionReservation_achat_adherent.SelectedValue)); //Lorsque la méthode retourne -1 c'est que l'adhérent n'a pas été trouvé dans la liste avec le numéro fournit if (index != -1) { GestionClub.getTousLesAdherents()[index].setNbReservation(GestionClub.getTousLesAdherents()[index].getNbReservation() + Convert.ToInt32(cb_gestionReservation_achat_nbPlaces.SelectedItem)); MessageBox.Show(GestionClub.getTousLesAdherents()[index].EtatCivil + " a acheté " + Convert.ToString(cb_gestionReservation_achat_nbPlaces.SelectedItem) + " places" + "\n Places restantes : " + GestionClub.getTousLesAdherents()[index].getNbReservation()); } }
private void cb_gestionReservation_modif_adherent_SelectedIndexChanged(object sender, EventArgs e) { int index = GestionClub.getIndexOfReserv(Convert.ToInt32(cb_gestionReservation_modif_adherent.SelectedValue)); //Si l'adhérent n'a plus de places de réservation if (GestionClub.getTousLesAdherents()[index].getNbReservation() == 0) { MessageBox.Show("L'adhérent " + GestionClub.getTousLesAdherents()[index].EtatCivil + " n'a plus de places, il doit en acheter avant de faire une réservation !"); //On remet la valeur affichée à vide tout en empêchant l'évènement de se relancer this.cb_gestionReservation_modif_adherent.SelectedIndexChanged -= new EventHandler(cb_gestionReservation_modif_adherent_SelectedIndexChanged); cb_gestionReservation_modif_adherent.SelectedIndex = -1; this.cb_gestionReservation_modif_adherent.SelectedIndexChanged += new EventHandler(cb_gestionReservation_modif_adherent_SelectedIndexChanged); } }
private void bt_gestionReservation_modif_valid_Click(object sender, EventArgs e) { DialogResult dialogResult = MessageBox.Show("Êtes vous sûr de vouloir modifier la réservation ?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (dialogResult == DialogResult.Yes) { int indexReserv = GestionClub.getIndexOfReserv(Convert.ToInt32(tb_gestionReservation_modif_num.Text)); int indexAdherent = GestionClub.getIndexOfAdherent(Convert.ToInt32(cb_gestionReservation_modif_adherent.SelectedValue)); int indexCourt = GestionClub.getIndexOfCourt(Convert.ToInt32(cb_gestionReservation_modif_court.Text)); //On vérifie que l'utilisateur a bien modifié la valeur avant de faire un setter try { //Si l'adhérent réservatn le terrain a été modifié on décrémente son nb de réservation et on incrémente les réservatio n du précédant réservant if (GestionClub.getTousLesAdherents()[indexAdherent].getNumero().ToString() != tb_gestionReservation_modif_num.Text) { GestionClub.getTousLesAdherents()[indexAdherent].setNbReservation(GestionClub.getTousLesAdherents()[indexAdherent].getNbReservation() - 1); GestionClub.getTousLesAdherents()[Convert.ToInt32(tb_gestionReservation_modif_num.Text)].setNbReservation(GestionClub.getTousLesAdherents()[Convert.ToInt32(tb_gestionReservation_modif_num.Text)].getNbReservation() + 1); } //Modif adhérent if (cb_gestionReservation_modif_adherent.SelectedValue.ToString() != GestionClub.getToutesLesReservations()[indexReserv].getAdherentReserve().getNumero().ToString()) { GestionClub.getToutesLesReservations()[indexReserv].setAdherentReserve(GestionClub.getTousLesAdherents()[indexAdherent]); } if (dtp_gestionReservation_modif_date.Value != GestionClub.getToutesLesReservations()[indexReserv].getDtReservation()) { GestionClub.getToutesLesReservations()[indexReserv].setDtReservation(dtp_gestionReservation_modif_date.Value); } if (cb_gestionReservation_modif_court.Text != GestionClub.getToutesLesReservations()[indexReserv].getCourtReserve().ToString()) { GestionClub.getToutesLesReservations()[indexReserv].setCourtReserve(GestionClub.getTousLesCourts()[indexCourt]); } if (cb_gestionReservation_modif_nbJoueurs.Text != GestionClub.getToutesLesReservations()[indexReserv].getNbJoueurs().ToString()) { GestionClub.getToutesLesReservations()[indexReserv].setNbJoueurs(Convert.ToInt32(cb_gestionReservation_modif_nbJoueurs.Text)); } MessageBox.Show("La modification a bien été réalisée"); Form_gestionReservation_modif.ActiveForm.Close(); Form_gestionReservation_informations form_getionReservation_infos = new Form_gestionReservation_informations(); form_getionReservation_infos.ShowDialog(); } catch { MessageBox.Show("Une erreur est survenue pendant la modification, veuillez vérifier que tous les champs soient remplis et que ce soit seulement des numériques"); } } }
private void Form_gestionAdherent_Afficher_Load(object sender, EventArgs e) { foreach (Adherent unAdherent in GestionClub.getTousLesAdherents()) { dgv_gestionAdherent_Afficher.Rows.Add(unAdherent.getNumero(), unAdherent.getNom(), unAdherent.getPrenom(), unAdherent.getDtNaissance().ToShortDateString(), unAdherent.getNumTel(), unAdherent.getMail(), unAdherent.getClassement().ToString(), unAdherent.getDtFinAdhesion().ToShortDateString(), unAdherent.getNbReservation()); } }
//Constructeur public Adherent(string unNom, string unPrenom, DateTime uneDtNaissance, string unNumTel, string unMail, string unClassement, DateTime uneDtFinAdhesion) { //On remplit avec le dernier numéro d'ahérent qui n'est pas encore attribué this.numero = GestionClub.getDernierNumAdherent(); //On incrémentente le prochain numéro à assigner GestionClub.setDernierNumAdherent(GestionClub.getDernierNumAdherent() + 1); this.nom = unNom; this.prenom = unPrenom; this.dtNaissance = uneDtNaissance; this.numTel = unNumTel; this.mail = unMail; this.classement = unClassement; this.dtFinAdhesion = uneDtFinAdhesion; this.nbReservation = 0; GestionClub.getTousLesAdherents().Add(this); }
private void Form_gestionReservation_modif_Load(object sender, EventArgs e) { int indexAdherent = GestionClub.getIndexOfAdherent(Convert.ToInt32(cb_gestionReservation_modif_adherent.ValueMember)); #region Loading comboBox Adhérent this.cb_gestionReservation_modif_adherent.SelectedIndexChanged -= new EventHandler(cb_gestionReservation_modif_adherent_SelectedIndexChanged); cb_gestionReservation_modif_adherent.DataSource = GestionClub.getTousLesAdherents(); cb_gestionReservation_modif_adherent.DisplayMember = "EtatCivil"; cb_gestionReservation_modif_adherent.ValueMember = "Numero"; //On désélectionne les valeurs (ici le DataSource séléctionne par défaut la première valeur de la liste) cb_gestionReservation_modif_adherent.SelectedIndex = indexAdherent; this.cb_gestionReservation_modif_adherent.SelectedIndexChanged += new EventHandler(cb_gestionReservation_modif_adherent_SelectedIndexChanged); #endregion #region Loading comboBox nbJoueurs foreach (int nbPlaces in GestionClub.getParamNbJoueursCourt()) { cb_gestionReservation_modif_nbJoueurs.Items.Add(nbPlaces); } #endregion }