Esempio n. 1
0
        private bool AjoutDeJeu()
        {
            // 1 Réupérer les données.
            // 2 Vérifier les infos rentrées par l'utilisateur.
            // 3 Si ok -> requete SQL
            //   Sinon -> message d'erreur et on ne fait rien.
            // 3.1 Verifier le retour de la requete
            //     Si ok -> Message "bien enregistré"
            //     Sinon -> message d'erreur et on ne fait rien.
            string genre        = dataGridView1.Rows[0].Cells[0].Value.ToString();
            string nom          = dataGridView1.Rows[0].Cells[1].Value.ToString();
            string auteur       = dataGridView1.Rows[0].Cells[2].Value.ToString();
            string anneeEdition = dataGridView1.Rows[0].Cells[3].Value.ToString();
            string editeur      = dataGridView1.Rows[0].Cells[4].Value.ToString();


            string nbJoueurMini = dataGridView2.Rows[0].Cells[0].Value.ToString();
            string nbJoueurMaxi = dataGridView2.Rows[0].Cells[1].Value.ToString();
            string ageMini      = dataGridView2.Rows[0].Cells[2].Value.ToString();
            string ageMaxi      = dataGridView2.Rows[0].Cells[3].Value.ToString();
            string tempsJeu     = dataGridView2.Rows[0].Cells[4].Value.ToString();

            string regleJeu = dataGridView3.Rows[0].Cells[0].Value.ToString();

            estAjoute = true;

            if (!String.IsNullOrEmpty(genre) && !String.IsNullOrEmpty(nom) &&
                !String.IsNullOrEmpty(auteur) && !String.IsNullOrEmpty(anneeEdition) && !String.IsNullOrEmpty(editeur) && !String.IsNullOrEmpty(nbJoueurMini) && !String.IsNullOrEmpty(nbJoueurMaxi) &&
                !String.IsNullOrEmpty(ageMini) || !String.IsNullOrEmpty(ageMaxi) || !String.IsNullOrEmpty(tempsJeu) || !String.IsNullOrEmpty(regleJeu))
            {
                SqlCommand bdd = Connexion.GetInstance().CreateCommand();

                if (bdd != null)
                {
                    // Ajout du jeu dans la base de données
                    _ = AjouterJeuDB(bdd, genre, nom, auteur, anneeEdition, editeur, nbJoueurMini, nbJoueurMaxi, ageMini, ageMaxi, tempsJeu, regleJeu);
                    string idJeu = GetIdJeu(bdd, genre, nom, auteur, anneeEdition, editeur, nbJoueurMini, nbJoueurMaxi, ageMini, ageMaxi, tempsJeu, regleJeu);



                    // Définition des paramètres de la requête


                    // Exécution de la requête
                    try
                    {
                        bdd.ExecuteNonQuery();
                    }
                    catch (Exception e)
                    {
                        estAjoute = false;
                        MessageBox.Show("Requete invalide: " + e.Message, "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                else
                {
                    estAjoute = false;
                    MessageBox.Show("La connexion à la bdd a échoué. Merci de réessayer ultérieurement.", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                estAjoute = false;
                MessageBox.Show("Les informations sont incomplètes.", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            return(estAjoute);
        }
Esempio n. 2
0
        private bool AjouterAdherents()
        {
            // 1 Réupérer les données.
            // 2 Vérifier les infos rentrées par l'utilisateur.
            // 3 Si ok -> requete SQL
            //   Sinon -> message d'erreur et on ne fait rien.
            // 3.1 Verifier le retour de la requete
            //     Si ok -> Message "bien enregistré"
            //     Sinon -> message d'erreur et on ne fait rien.
            string nom        = dataGridAdherentPrincipal.Rows[0].Cells[0].Value.ToString();
            string prenom     = dataGridAdherentPrincipal.Rows[0].Cells[1].Value.ToString();
            string rue        = dataGridAdherentPrincipal.Rows[0].Cells[2].Value.ToString();
            string codePostal = dataGridAdherentPrincipal.Rows[0].Cells[3].Value.ToString();
            string ville      = dataGridAdherentPrincipal.Rows[0].Cells[4].Value.ToString();
            string email      = dataGridAdherentPrincipal.Rows[0].Cells[5].Value.ToString();
            string telephone  = dataGridAdherentPrincipal.Rows[0].Cells[6].Value.ToString();

            string adherent1 = dataGridAdherentsSecondaires.Rows[0].Cells[0].Value.ToString();
            string adherent2 = dataGridAdherentsSecondaires.Rows[0].Cells[1].Value.ToString();
            string adherent3 = dataGridAdherentsSecondaires.Rows[0].Cells[2].Value.ToString();
            string adherent4 = dataGridAdherentsSecondaires.Rows[0].Cells[3].Value.ToString();

            string dateDebut = dataGridAdhesion.Rows[0].Cells[0].Value.ToString();

            estAjoute = true;

            if (!String.IsNullOrEmpty(nom) && !String.IsNullOrEmpty(prenom) &&
                !String.IsNullOrEmpty(rue) && !String.IsNullOrEmpty(codePostal) && !String.IsNullOrEmpty(ville) && !String.IsNullOrEmpty(email) && !String.IsNullOrEmpty(telephone) &&
                !String.IsNullOrEmpty(adherent1) || !String.IsNullOrEmpty(adherent2) || !String.IsNullOrEmpty(adherent3) || !String.IsNullOrEmpty(adherent4) &&
                !String.IsNullOrEmpty(dateDebut))
            {
                SqlCommand bdd = Connexion.GetInstance().CreateCommand();

                if (bdd != null)
                {
                    // Ajout de l'adresse dans la base de donnée + adhérent + date adhésion
                    _ = AjouterAdresseBDD(bdd, rue, codePostal, ville);
                    string idAdresse = GetIdAdresse(bdd, rue, codePostal, ville);

                    //string idAdherent = GetIdAdherent(bdd);
                    string adherentsSecondaires = (adherent1 + " " + adherent2 + " " + adherent3 + " " + adherent4);
                    _ = AjouterAdherentBDD(bdd, idAdresse, nom, prenom, email, telephone, adherentsSecondaires);


                    string idAdherent = GetIdAdherent(bdd, nom, prenom);

                    estAjoute = AjouterAdhesionBDD(bdd, idAdherent, cotisation, caution, dateDebut);


                    // Définition des paramètres de la requête



                    // Exécution de la requête
                    try
                    {
                        bdd.ExecuteNonQuery();
                    }
                    catch (Exception e)
                    {
                        estAjoute = false;
                        MessageBox.Show("Requete invalide: " + e.Message, "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                else
                {
                    estAjoute = false;
                    MessageBox.Show("La connexion à la bdd a échoué. Merci de réessayer ultérieurement.", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                // requeste SQL
            }
            else
            {
                estAjoute = false;
                MessageBox.Show("Les informations sont incomplètes.", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            return(estAjoute);
        }
Esempio n. 3
0
        private bool AjouterAdministration()
        {
            // 1 Réupérer les données.
            // 2 Vérifier les infos rentrées par l'utilisateur.
            // 3 Si ok -> requete SQL
            //   Sinon -> message d'erreur et on ne fait rien.
            // 3.1 Verifier le retour de la requete
            //     Si ok -> Message "bien enregistré"
            //     Sinon -> message d'erreur et on ne fait rien.
            string prixCotisation    = dataGridAdminF.Rows[0].Cells[0].Value.ToString();
            string prixCaution       = dataGridAdminF.Rows[0].Cells[1].Value.ToString();
            string dureeAdhesion     = dataGridAdminF.Rows[0].Cells[2].Value.ToString();
            string nbJeuxEmpruntable = dataGridAdminF.Rows[0].Cells[3].Value.ToString();
            string dureeEmprunt      = dataGridAdminF.Rows[0].Cells[4].Value.ToString();
            string dateDebut         = dataGridAdminF.Rows[0].Cells[5].Value.ToString();
            string dateFin           = dataGridAdminF.Rows[0].Cells[6].Value.ToString();



            estAjoute = true;

            if (!String.IsNullOrEmpty(prixCotisation) && !String.IsNullOrEmpty(prixCaution) &&
                !String.IsNullOrEmpty(dureeAdhesion) && !String.IsNullOrEmpty(nbJeuxEmpruntable) && !String.IsNullOrEmpty(dureeEmprunt) && !String.IsNullOrEmpty(dateDebut) && !String.IsNullOrEmpty(dateFin))
            {
                SqlCommand bdd = Connexion.GetInstance().CreateCommand();

                if (bdd != null)
                {
                    // Ajout de l'adresse dans la base de donnée + adhérent + date adhésion
                    _ = AjouterAdministrationBDD(bdd, Convert.ToInt32(prixCotisation), Convert.ToInt32(prixCaution), Convert.ToInt32(dureeAdhesion), Convert.ToInt32(nbJeuxEmpruntable), Convert.ToInt32(dureeEmprunt), dateDebut, dateFin);
                    string idAbonnement = GetAdministration(bdd, Convert.ToInt32(prixCotisation), Convert.ToInt32(prixCaution), Convert.ToInt32(dureeAdhesion), Convert.ToInt32(nbJeuxEmpruntable), Convert.ToInt32(dureeEmprunt), dateDebut, dateFin);



                    estAjoute = AjouterAdministrationBDD(bdd, Convert.ToInt32(prixCotisation), Convert.ToInt32(prixCaution), Convert.ToInt32(dureeAdhesion), Convert.ToInt32(nbJeuxEmpruntable), Convert.ToInt32(dureeEmprunt), dateDebut, dateFin);


                    // Définition des paramètres de la requête



                    // Exécution de la requête
                    try
                    {
                        bdd.ExecuteNonQuery();
                    }
                    catch (Exception e)
                    {
                        estAjoute = false;
                        MessageBox.Show("Requete invalide: " + e.Message, "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                else
                {
                    estAjoute = false;
                    MessageBox.Show("La connexion à la bdd a échoué. Merci de réessayer ultérieurement.", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                // requeste SQL
            }
            else
            {
                estAjoute = false;
                MessageBox.Show("Les informations sont incomplètes.", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            return(estAjoute);
        }