public FormGestionLicenciesAjout(string type, Licencie lcn, Telephone[] tel, string[] idsnc, string nom, string prenom, string mail)
        //constructeur 2 : formulaire d'édition/réinscription de licencié (pré-rempli)
        {
            try
            {
                InitializeComponent();

                //on affiche la page 1
                panel1.Visible = true;
                panel2.Visible = false;
                panel3.Visible = false;

                //affectation des variables
                _typeForm   = type;
                _nom        = nom;
                _prenom     = prenom;
                _mail       = mail;
                _seancesNow = idsnc;
                _lcn        = lcn;
                _tel        = tel;

                //customisation du form selon son type (ici : édition ou réinscription d'un licencié connu)
                this.Text = _typeForm + " de : " + _prenom + " " + _nom;
                labelOngletContact.Text     = _typeForm + labelOngletContact.Text;
                labelOngletInscription.Text = _typeForm + labelOngletInscription.Text;
                labelOngletInfo.Text        = _typeForm + labelOngletInfo.Text;
            }
            catch (Exception ex) { MessageBox.Show(ex.Message); }
        }
Exemplo n.º 2
0
        public void ReadLicencie(Licencie l)
        {
            string          sql       = "SELECT * FROM licencie WHERE id=" + l.Id;
            MySqlCommand    maReq     = new MySqlCommand(sql, conn);
            MySqlDataReader resultats = maReq.ExecuteReader();

            while (resultats.Read())
            {
                resultats[2].ToString();
            }
        }
Exemplo n.º 3
0
 public bool ReinscrireLicencie(string nom, string prenom, string mail, Licencie lcn, Telephone[] tel, string[] idSnc, DateTime anneeIsc)
 {
     try {
         nom    = RemoveDiacritics(nom);
         prenom = RemoveDiacritics(prenom);
         //réinscription d'un licencie
         return(_dao.ReinscrireLicencie(nom, prenom, mail, lcn, tel, idSnc, anneeIsc));
     }
     catch (Exception e)
     {
         throw new Exception("Erreur Metier.cs/ReinscrireLicencie():\r\n" + e.Message, e);
     }
 }
Exemplo n.º 4
0
 public bool EditerLicencie(string nom, string prenom, string mail, Licencie lcn, Telephone[] tel, string[] idSnc, DateTime anneeIsc)
 {
     try {
         nom    = RemoveDiacritics(nom);
         prenom = RemoveDiacritics(prenom);
         mail   = RemoveDiacritics(mail);
         //édition des données d'un licencie
         return(_dao.EditerLicencie(nom, prenom, mail, lcn, tel, idSnc, anneeIsc));
     }
     catch (Exception e)
     {
         throw new Exception("Erreur Metier.cs/EditerLicencie():\r\n" + e.Message, e);
     }
 }
Exemplo n.º 5
0
 public bool GetLicencie(string nom, string prenom, string mail, ref Licencie lcn, ref Telephone[] tel, ref string[] snc)
 {
     try{
         nom    = RemoveDiacritics(nom);
         prenom = RemoveDiacritics(prenom);
         mail   = RemoveDiacritics(mail);
         //récupération des données d'un licencie
         return(_dao.GetLicencie(nom, prenom, mail, out lcn, out tel, out snc));
     }
     catch (Exception e)
     {
         throw new Exception("Erreur Metier.cs/GetLicencie():\r\n" + e.Message, e);
     }
 }
Exemplo n.º 6
0
        public HttpResponseMessage AddLicencie([FromBody] Licencie l)
        {
            ContactDAO dao = new ContactDAO();

            dao.AddLicencie(l.Id, l.Nom, l.Prenom, l.Email, l.Tel, l.Mdp);

            if (l != null)
            {
                return(Request.CreateResponse(HttpStatusCode.Created, l));
            }
            else
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest, l));
            }
        }
Exemplo n.º 7
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Licencie = await _context.Licensie.FirstOrDefaultAsync(m => m.ID == id);

            if (Licencie == null)
            {
                return(NotFound());
            }
            return(Page());
        }
Exemplo n.º 8
0
        public List <Licencie> getAllLicencie()
        {
            List <Licencie> lesLicencie = new List <Licencie>();
            string          requete     = "select * from licencie";
            MySqlCommand    cmd         = new MySqlCommand(requete, conn);
            MySqlDataReader rdr         = cmd.ExecuteReader();

            while (rdr.Read())
            {
                Licencie l = new Licencie(Convert.ToInt16(rdr[0].ToString()), rdr[1].ToString(),
                                          rdr[2].ToString(), rdr[3].ToString(), rdr[4].ToString(), rdr[5].ToString());
                lesLicencie.Add(l);
            }
            rdr.Close();
            return(lesLicencie);
        }
Exemplo n.º 9
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Licencie = await _context.Licensie.FindAsync(id);

            if (Licencie != null)
            {
                _context.Licensie.Remove(Licencie);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }
Exemplo n.º 10
0
 public bool CreerLicencie(Licencie licencie, Telephone[] tabTelephone, string[] idSceance, DateTime anneeInscription)
 {
     try {
         //Enlever les accents
         licencie.Nom     = RemoveDiacritics(licencie.Nom);
         licencie.Prenom  = RemoveDiacritics(licencie.Prenom);
         licencie.Mail    = RemoveDiacritics(licencie.Mail);
         licencie.Adresse = RemoveDiacritics(licencie.Adresse);
         licencie.Ville   = RemoveDiacritics(licencie.Ville);
         //création d'un licencie
         return(_dao.CreerLicencie(licencie, tabTelephone, idSceance, anneeInscription));
     }
     catch (Exception e)
     {
         throw new Exception("Erreur Metier.cs/CreerLicencie():\r\n" + e.Message, e);
     }
 }
        private void buttonTerminer_Click(object sender, EventArgs e)
        //vérifie la présence d'au moins un contact valide puis ajoute/réinscrit/édite le licencié dans la BDD avant de fermer le formulaire
        {
            try
            {
                //rassemble les infos perso du licencié dans une entité
                Licencie lcn = new Licencie(_champNom, _champPrenom, comboBoxGenre.Text,
                                            _dateNaissance, _champAdresse, _champCP, _champVille, _champMail,
                                            comboBoxPaiement.Text, comboBoxCertificat.Text, comboBoxLicence.Text);

                //SECURITE
                if (dataGridViewContact.RowCount == 0)
                {
                    throw new Exception("Veuillez renseigner au moins un contact.");
                }

                //rassemble les contacts dans un tableau d'entité
                Telephone[] tel = new Telephone[dataGridViewContact.RowCount];
                for (int i = 0; i < dataGridViewContact.RowCount; i++)
                {
                    tel[i] = new Telephone(
                        dataGridViewContact[2, i].Value.ToString(), dataGridViewContact[1, i].Value.ToString(),
                        dataGridViewContact[0, i].Value.ToString(), dataGridViewContact[3, i].Value.ToString());
                }

                //rassemble les ID des inscriptions sélectionnées dans un tableau
                string[] idSnc = new string[checkedListBoxInscriptions.CheckedItems.Count];
                for (int i = 0; i < checkedListBoxInscriptions.CheckedIndices.Count; i++)
                {
                    idSnc[i] = _seances[checkedListBoxInscriptions.CheckedIndices[i]].Id;
                }

                //transforme la saison d'inscription en DateTime
                DateTime anneeIsc = new DateTime(int.Parse(ComboBoxSaison.Text.Split('/')[0]), 9, 1);

                //traitement métier et dao suivant l'opération demandée (ajout, édition, réinscription)
                switch (_typeForm)
                {
                case "édition":
                    if (_metier.EditerLicencie(_nom, _prenom, _mail, lcn, tel, idSnc, anneeIsc) == true)
                    {
                        MessageBox.Show("Le licencié a été édité avec succès !");
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("Echec lors de l'édition.");
                    }
                    break;

                case "réinscription":
                    if (_metier.ReinscrireLicencie(_nom, _prenom, _mail, lcn, tel, idSnc, anneeIsc) == true)
                    {
                        MessageBox.Show("Le licencié a été réinscrit avec succès !");
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("Echec lors de la réinscription.");
                    }
                    break;

                default:
                    if (_metier.CreerLicencie(lcn, tel, idSnc, anneeIsc) == true)
                    {
                        MessageBox.Show("Le licencié a été ajouté à la base de données avec succès !");
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("Echec lors de l'ajout à la base de données.");
                    }
                    break;
                }
            }
            catch (Exception ex) { MessageBox.Show(ex.Message); }
        }
Exemplo n.º 12
0
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        //Gère l'édition, la réinscription et la suppression d'un licencié parmis les résultats de la recherche
        {
            try
            {
                var senderGrid = (DataGridView)sender;
                //on ne regarde que les clicks sur un bouton ici
                if (senderGrid.Columns[e.ColumnIndex] is DataGridViewButtonColumn && e.RowIndex >= 0)
                {
                    //si le user choisit de supprimer un licencié
                    if (senderGrid.Columns[e.ColumnIndex].HeaderText == "Suppression")
                    {
                        //on demande une confirmation car l'opération est irresversible
                        var confirm = DialogResult.No;
                        confirm = MessageBox.Show("Vous allez supprimer le licencié :" + senderGrid[0, e.RowIndex].Value
                                                  + " " + senderGrid[1, e.RowIndex].Value + " (" + senderGrid[2, e.RowIndex].Value
                                                  + ").\nÊtes-vous sûr ?", "Confirmation", MessageBoxButtons.YesNo);
                        if (confirm == DialogResult.Yes)
                        {
                            //on supprime le licencié dans la BDD
                            _metier.SupprimerLicencie(senderGrid[0, e.RowIndex].Value.ToString(),
                                                      senderGrid[1, e.RowIndex].Value.ToString(), senderGrid[3, e.RowIndex].Value.ToString());

                            //on supprime le licencié dans la grille des résultats et on actualise les indexs des lignes
                            dataGridViewGestionLicencies.Rows.RemoveAt(e.RowIndex);
                            for (int i = e.RowIndex; i < dataGridViewGestionLicencies.Rows.Count; i++)
                            {
                                dataGridViewGestionLicencies.Rows[i].HeaderCell.Value =
                                    String.Format("{0}", dataGridViewGestionLicencies.Rows[i].Index + 1);
                            }
                        }
                    }

                    //si le user choisit de réinscrire le licencié (année en cours ou suivante)
                    if (senderGrid.Columns[e.ColumnIndex].HeaderText == "Réinscription")
                    {
                        //initialisation des entités
                        Licencie    lcn   = null;
                        Telephone[] tel   = null;
                        string[]    idsnc = null;

                        //on récupère les informations de la BDD dans les entités ci-dessus (via les refs ci-dessous)
                        _metier.GetLicencie(senderGrid[0, e.RowIndex].Value.ToString(),
                                            senderGrid[1, e.RowIndex].Value.ToString(), senderGrid[3, e.RowIndex].Value.ToString(),
                                            ref lcn, ref tel, ref idsnc);

                        //Création/remplissage/affichage du formulaire de réinscription via le constructeur 2 (infos pré-complétées)
                        FormGestionLicenciesAjout ReinscrireLicencie = new FormGestionLicenciesAjout("réinscription",
                                                                                                     lcn, tel, idsnc, senderGrid[0, e.RowIndex].Value.ToString(),
                                                                                                     senderGrid[1, e.RowIndex].Value.ToString(), senderGrid[3, e.RowIndex].Value.ToString());
                        ReinscrireLicencie.SetMetier(_metier);
                        ReinscrireLicencie.RemplirChamps();
                        ReinscrireLicencie.ShowDialog(); // priorité donc un seul form de ce type à la fois

                        //si le user a confirmé la réinscription (bouton Terminer du formulaire), on actualise la grille de résultats
                        if (ReinscrireLicencie.DialogResult == DialogResult.OK)
                        {
                            senderGrid[0, e.RowIndex].Value = ReinscrireLicencie.GetNewNom();
                            senderGrid[1, e.RowIndex].Value = ReinscrireLicencie.GetNewPrenom();
                            senderGrid[2, e.RowIndex].Value = ReinscrireLicencie.GetNewDateNaissance();
                            senderGrid[3, e.RowIndex].Value = ReinscrireLicencie.GetNewMail();
                        }
                    }

                    //si le user choisit d'éditer les infos du licencié (année en cours uniquement)
                    if (senderGrid.Columns[e.ColumnIndex].HeaderText == "Édition")
                    {
                        //initialisation des entités
                        Licencie    lcn   = null;
                        Telephone[] tel   = null;
                        string[]    idsnc = null;

                        //on récupère les informations de la BDD dans les entités ci-dessus (via les refs ci-dessous)
                        _metier.GetLicencie(senderGrid[0, e.RowIndex].Value.ToString(),
                                            senderGrid[1, e.RowIndex].Value.ToString(), senderGrid[3, e.RowIndex].Value.ToString(),
                                            ref lcn, ref tel, ref idsnc);

                        //Création/remplissage/affichage du formulaire d'édition via le constructeur 2 (infos pré-complétées)
                        FormGestionLicenciesAjout EditerLicencie = new FormGestionLicenciesAjout("édition",
                                                                                                 lcn, tel, idsnc, senderGrid[0, e.RowIndex].Value.ToString(), senderGrid[1, e.RowIndex].Value.ToString(),
                                                                                                 senderGrid[3, e.RowIndex].Value.ToString());
                        EditerLicencie.SetMetier(_metier);
                        EditerLicencie.RemplirChamps();
                        EditerLicencie.ShowDialog(); // priorité donc un seul form de ce type à la fois

                        //si le user a confirmé l'édition (bouton Terminer du formulaire), on actualise la grille de résultats
                        if (EditerLicencie.DialogResult == DialogResult.OK)
                        {
                            senderGrid[0, e.RowIndex].Value = EditerLicencie.GetNewNom();
                            senderGrid[1, e.RowIndex].Value = EditerLicencie.GetNewPrenom();
                            senderGrid[2, e.RowIndex].Value = EditerLicencie.GetNewDateNaissance();
                            senderGrid[3, e.RowIndex].Value = EditerLicencie.GetNewMail();
                        }
                    }
                }
            }
            catch (Exception ex) { MessageBox.Show(ex.Message); }
        }