Beispiel #1
0
        private void btnSupprimer_Click(object sender, EventArgs e)
        {
            try
            {
                // si une personne est pointée dans la datagridview
                if (this.grdPersonnes.CurrentRow != null)
                {
                    Int32 clePersonne;
                    clePersonne = (Int32)this.grdPersonnes.CurrentRow.Cells[0].Value;

                    personne = MPersonnes.RestituerPersonne(clePersonne);

                    clePersonne = Int32.Parse(this.grdPersonnes.CurrentRow.Cells[0].Value.ToString());
                    // demande confirmation de la suppression
                    if (MessageBox.Show("Voulez-vous supprimer la personne numéro : " + clePersonne.ToString(), "Suppression", MessageBoxButtons.YesNo,
                                        MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        MPersonnes.DeletePersonne(clePersonne);
                        MAdherents.DeleteAdherent(personne.NumAdherent);
                        // réaffiche la datagridview
                        affichePersonnes();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Une erreur est survenue \n" + ex.Message);
            }
        }
        public static void UpdateCotisation(MAdherents adh)
        {
            // crée la commande sql
            MySqlCommand cmd = ConnexionBase.GetConnexion().CreateCommand();

            cmd.CommandText = "UPDATE adherents SET date_cotisation=@dateCotisation WHERE num_adherent=@numAdherent";

            cmd.Parameters.AddWithValue("@numAdherent", adh.numAdherent);
            cmd.Parameters.AddWithValue("@dateCotisation", adh.dateCotisation);
            // exécute la requête
            cmd.ExecuteNonQuery();
        }
        public static void InsertAdherent(MAdherents adh)
        {
            // crée la commande sql
            MySqlCommand cmd = ConnexionBase.GetConnexion().CreateCommand();

            cmd.CommandText = "INSERT INTO adherents(num_adherent, date_inscription, date_cotisation) " +
                              "VALUES (@numAdherent, @dateInscription, @dateCotisation)";

            cmd.Parameters.AddWithValue("@numAdherent", adh.numAdherent);
            cmd.Parameters.AddWithValue("@dateInscription", adh.dateInscription);
            cmd.Parameters.AddWithValue("@dateCotisation", adh.dateCotisation);
            // exécute la requête
            cmd.ExecuteNonQuery();
        }
Beispiel #4
0
        private void frmConsultationPersonne_Load(object sender, EventArgs e)
        {
            this.adherents = MAdherents.ChercherAdherent(laPersonne.NumAdherent);
            this.affichePersonnes();
            now    = DateTime.Now;
            valide = adherents.dateCotisation.AddYears(1);

            if (now > valide)
            {
                lblRetard.Visible = true;
            }
            else
            {
                lblRetard.Visible = false;
            }
        }
        public static MAdherents ChercherAdherent(Int32 num)
        {
            MAdherents   adh = null;
            MySqlCommand cmd = ConnexionBase.GetConnexion().CreateCommand();

            cmd.CommandText = "SELECT * from adherents where num_adherent=@num";
            cmd.Parameters.AddWithValue("@num", num);
            MySqlDataReader reader = cmd.ExecuteReader();

            while (reader.Read())
            {
                adh = new MAdherents();

                adh.dateCotisation  = reader.GetDateTime("date_cotisation");
                adh.dateInscription = reader.GetDateTime("date_inscription");
            }
            reader.Close();
            return(adh);
        }
Beispiel #6
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            try
            {
                MAdherents modifierAdherent = new MAdherents();
                modifierAdherent.dateCotisation = DateTime.Parse(base.dateTimeCotisation.Text);
                modifierAdherent.numAdherent    = (MPersonnes.RestituerPersonne(Int32.Parse(base.txtbNumPersonne.Text))).NumAdherent;
                MAdherents.UpdateCotisation(modifierAdherent);

                // crée une référence d'objets MPersonnes
                MPersonnes modifierPersonne = new MPersonnes();

                // affecte des variables/propriétés
                modifierPersonne.NumPersonne = Int32.Parse(base.txtbNumPersonne.Text);
                modifierPersonne.Nom         = base.txtbNom.Text.ToUpper();
                modifierPersonne.Prenom      = base.txtbPrenom.Text.ToLower();
                modifierPersonne.CodePostal  = base.txtbCodePostal.Text;
                modifierPersonne.Ville       = base.txtbVille.Text.ToUpper();
                modifierPersonne.Adresse1    = base.txtbAdresse.Text;
                modifierPersonne.Email       = base.txtbEmail.Text;
                modifierPersonne.Telephone   = base.txtbTelephone.Text;
                modifierPersonne.Naissance   = DateTime.Parse(base.dateTimeNaissance.Text);

                // enregistrement de la modification de la personne dans la BDD
                MPersonnes.UpdatePersonne(modifierPersonne);

                // ajoute la référence d'objet MPersonnes dans la collection
                Donnees.tablePersonnes = MPersonnes.ListerPersonnes("");
                // incrémentation du compteur de personnes
                MPersonnes.NPersonnes = 1;

                this.Close();

                // fermeture de la boite de dialogue par validation
                this.DialogResult = DialogResult.OK;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Une erreur est survenue \n" + ex.Message);
            }
        }
Beispiel #7
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            try
            {
                if (chkParticuliers.Checked == true)
                {
                    MAdherents nouvelAdherent = new MAdherents();
                    nouvelAdherent.dateInscription = DateTime.Parse(base.dateTimeInscription.Text);
                    nouvelAdherent.dateCotisation  = DateTime.Parse(base.dateTimeCotisation.Text);
                    MAdherents.InsertAdherent(nouvelAdherent);

                    // crée une référence d'objets MAdherents
                    MPersonnes nouvellePersonne = new MPersonnes(leNumero, leNom, lePrenom, uneAdresse1, leTelephone, unEmail, uneDate, leCodePostal,
                                                                 laVille);

                    // affecte des variables/propriétés
                    nouvellePersonne.NumPersonne = Int32.Parse(base.txtbNumPersonne.Text);
                    nouvellePersonne.NumAdherent = (Int32)(MAdherents.LastInsertId());
                    nouvellePersonne.Nom         = base.txtbNom.Text.ToUpper();
                    nouvellePersonne.Prenom      = base.txtbPrenom.Text.ToLower();
                    nouvellePersonne.CodePostal  = base.txtbCodePostal.Text;
                    nouvellePersonne.Ville       = base.txtbVille.Text.ToUpper();
                    nouvellePersonne.Adresse1    = base.txtbAdresse.Text;
                    nouvellePersonne.Telephone   = base.txtbTelephone.Text;
                    nouvellePersonne.Email       = base.txtbEmail.Text;
                    nouvellePersonne.Naissance   = DateTime.Parse(base.dateTimeNaissance.Text);

                    // enregistrement de la nouvelle personne dans la BDD
                    MPersonnes.InsertPersonne(nouvellePersonne);

                    // ajoute la référence d'objet MPersonnes dans la collection
                    Donnees.tablePersonnes = MPersonnes.ListerPersonnes("");
                    // incrémentation du compteur de personnes
                    MPersonnes.NPersonnes += 1;
                }
                else
                {
                    chkScolaires.Checked = true;
                    MAdherents nouvelAdherent = new MAdherents();
                    nouvelAdherent.dateInscription = DateTime.Parse(base.dateTimeInscriptionSco.Text);
                    MAdherents.InsertAdherent(nouvelAdherent);

                    MScolaires nouveauScolaire = new MScolaires(leCode, uneVille, uneEcole, uneClasse, unNom, unPrenom, unCP);

                    nouveauScolaire.Code          = Int32.Parse(base.txtbCodeSco.Text);
                    nouveauScolaire.NumAdherent   = (Int32)(MAdherents.LastInsertId());
                    nouveauScolaire.Ville         = base.txtbVilleEcole.Text;
                    nouveauScolaire.CodePostal    = base.txtbCP.Text;
                    nouveauScolaire.Etablissement = base.txtbEcole.Text;
                    nouveauScolaire.Classe        = base.cbbClasse.Text;
                    nouveauScolaire.Nom           = base.txtbNomProf.Text;
                    nouveauScolaire.Prenom        = base.txtbPrenomProf.Text;

                    MScolaires.InsertScolaire(nouveauScolaire);

                    Donnees.tableScolaires = MScolaires.ListerScolaires("");
                    MScolaires.NScolaires += 1;
                }
                this.Close();

                // fermeture de la boite de dialogue par validation
                this.DialogResult = DialogResult.OK;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Une erreur est survenue \n" + ex.Message);
            }
        }
Beispiel #8
0
 private void frmConsultationScolaire_Load(object sender, EventArgs e)
 {
     this.adherents = MAdherents.ChercherAdherent(leScolaire.NumAdherent);
     this.afficheScolaires();
 }