Exemplo n.º 1
0
        /// <summary>
        /// Lire un utilisateur sur son ID
        /// </summary>
        /// <param name="numCli">N° de l'utilisateur à lire</param>
        public static Clientel getClient(String numCli)
        {
            String    mysql;
            DataTable dt;
            Serreurs  er = new Serreurs("Erreur sur recherche d'un client.", "Client.RechercheUnClient()");

            try
            {
                mysql  = "SELECT SOCIETE, NOM_CL, PRENOM_CL,";
                mysql += "ADRESSE_CL, VILLE_CL, CODE_POST_CL ";
                mysql += "FROM clientel WHERE NO_CLIENT='" + numCli + "'";
                dt     = DBInterface.Lecture(mysql, er);

                if (dt.IsInitialized && dt.Rows.Count > 0)
                {
                    Clientel client  = new Clientel();
                    DataRow  dataRow = dt.Rows[0];
                    client.NoClient   = numCli;
                    client.NomCl      = dataRow[1].ToString();
                    client.Societe    = dataRow[0].ToString();
                    client.PrenomCl   = dataRow[2].ToString();
                    client.AdresseCl  = dataRow[3].ToString();
                    client.VilleCl    = dataRow[4].ToString();
                    client.CodePostCl = dataRow[5].ToString();

                    return(client);
                }
                else
                {
                    return(null);
                }
            }
            catch (MySqlException e)
            {
                throw new MonException(er.MessageUtilisateur(), er.MessageApplication(), e.Message);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Fonction qui retourne un manga
        /// </summary>
        /// <returns></returns>
        public static Manga GetunManga(String id)
        {
            DataTable dt;
            Manga     unManga = null;
            Serreurs  er      = new Serreurs("Erreur sur lecture des Mangas", "ServiceManga.getunManag()");

            try
            {
                String mysql = "Select  id_manga,id_genre,id_dessinateur,id_scenariste,titre,dateParution,prix,couverture ";
                mysql += " from Manga ";
                mysql += " where id_manga = " + id;
                dt     = DBInterface.Lecture(mysql, er);
                if (dt.IsInitialized && dt.Rows.Count > 0)
                {
                    unManga = new Manga();
                    DataRow dataRow = dt.Rows[0];
                    unManga.Id_manga       = int.Parse(dataRow[0].ToString());
                    unManga.Id_genre       = int.Parse(dataRow[1].ToString());
                    unManga.Id_dessinateur = int.Parse(dataRow[2].ToString());
                    unManga.Id_scenariste  = int.Parse(dataRow[3].ToString());
                    unManga.Titre          = dataRow[4].ToString();
                    unManga.DateParution   = DateTime.Parse(dataRow[5].ToString());
                    unManga.Prix           = Double.Parse(dataRow[6].ToString());
                    unManga.Couverture     = dataRow[7].ToString();
                    return(unManga);
                }
                else
                {
                    return(null);
                }
            }
            catch (MonException e)
            {
                throw new MonException(er.MessageUtilisateur(), er.MessageApplication(), e.Message);
            }
        }
Exemplo n.º 3
0
        public static void AddComm(Commande comm)
        {
            Serreurs er      = new Serreurs("Erreur sur l'insertion d'une commande.", "CommandeDao.AddComm()");
            String   requete = "INSERT INTO commandes VALUES " +
                               "NO_COMMAND ='" + comm.NuComm + "'" +
                               ", NO_VENDEUR ='" + comm.NuVendeur + "'" +
                               ", NO_CLIENT ='" + comm.NuClient + "'" +
                               ", DATE_CDE ='" + comm.DateComm + "' " +
                               ", FACTURE ='" + comm.Fact + "'" +
                               " WHERE NO_COMMAND ='" + comm.NuComm + "'";

            try
            {
                DBInterface.Insertion_Donnees(requete);
            }
            catch (MonException erreur)
            {
                throw erreur;
            }
            catch (MySqlException e)
            {
                throw new MonException(er.MessageUtilisateur(), er.MessageApplication(), e.Message);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Lire un utilisateur sur son ID
        /// </summary>
        /// <param name="noCom">N° de l'utilisateur à lire</param>
        public static Commande getCommande(int noCom)
        {
            String    mysql;
            DataTable dt;
            Serreurs  er = new Serreurs("Erreur sur recherche d'un article.", "Article.RechercheUnArticle()");

            try
            {
                mysql  = "SELECT NO_VENDEUR,";
                mysql += "NO_CLIENT, DATE_CDE, FACTURE ";
                mysql += "FROM commandes WHERE NO_COMMAND = " + noCom;
                dt     = DBInterface.Lecture(mysql, er);

                if (dt.IsInitialized && dt.Rows.Count > 0)
                {
                    Commande commande = new Commande();
                    DataRow  dataRow  = dt.Rows[0];
                    commande.noCommande = noCom;
                    commande.noVendeur  = int.Parse(dataRow[0].ToString());
                    commande.noClient   = int.Parse(dataRow[1].ToString());
                    commande.dateCde    = DateTime.Parse(dataRow[2].ToString());
                    commande.facture    = dataRow[3].ToString();
                    commande.articles   = getArticlesFromCommande(noCom);

                    return(commande);
                }
                else
                {
                    return(null);
                }
            }
            catch (MySqlException e)
            {
                throw new MonException(er.MessageUtilisateur(), er.MessageApplication(), e.Message);
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Lire un utilisateur sur son ID
        /// </summary>
        /// <param name="numCo">N° de la commande à lire</param>
        public static Commandes getCommande(String numCo)
        {
            String    mysql;
            DataTable dt;
            Serreurs  er = new Serreurs("Erreur sur recherche d'une commande.", "Commande.RechercheUnClient()");

            try
            {
                mysql  = "SELECT NO_VENDEUR, NO_CLIENT, DATE_CDE,";
                mysql += "FACTURE ";
                mysql += "FROM commandes WHERE NO_COMMAND='" + numCo + "'";
                dt     = DBInterface.Lecture(mysql, er);

                if (dt.IsInitialized && dt.Rows.Count > 0)
                {
                    Commandes comm    = new Commandes();
                    DataRow   dataRow = dt.Rows[0];
                    comm.NoCommande = numCo;
                    comm.NoVendeur  = dataRow[0].ToString();
                    comm.NoClient   = dataRow[1].ToString();
                    comm.DateCde    = dataRow[2].ToString();
                    comm.Facture    = dataRow[3].ToString();


                    return(comm);
                }
                else
                {
                    return(null);
                }
            }
            catch (MySqlException e)
            {
                throw new MonException(er.MessageUtilisateur(), er.MessageApplication(), e.Message);
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Lire un utilisateur sur son ID
        /// </summary>
        /// <param name="noArt">N° de l'utilisateur à lire</param>
        public static Article getArticle(int noArt)
        {
            String    mysql;
            DataTable dt;
            Serreurs  er = new Serreurs("Erreur sur recherche d'un article.", "Article.RechercheUnArticle()");

            try
            {
                mysql  = "SELECT LIB_ARTICLE, QTE_DISPO,";
                mysql += "VILLE_ART, PRIX_ART, INTERROMPU ";
                mysql += "FROM articles WHERE NO_ARTICLE = " + noArt;
                dt     = DBInterface.Lecture(mysql, er);

                if (dt.IsInitialized && dt.Rows.Count > 0)
                {
                    Article article = new Article();
                    DataRow dataRow = dt.Rows[0];
                    article.noArticle = noArt;
                    article.libelle   = dataRow[0].ToString();
                    article.qte       = int.Parse(dataRow[1].ToString());
                    article.villeArt  = dataRow[2].ToString();
                    article.prix      = float.Parse(dataRow[3].ToString());
                    article.interr    = dataRow[4].ToString();

                    return(article);
                }
                else
                {
                    return(null);
                }
            }
            catch (MySqlException e)
            {
                throw new MonException(er.MessageUtilisateur(), er.MessageApplication(), e.Message);
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// Permet de récupérer une commande
        /// </summary>
        /// <param name="nuComm"></param>
        /// <returns>Une commande</returns>
        public static Commande GetCommande(String nuComm)
        {
            DataTable dt;
            Commande  comm;
            Serreurs  er = new Serreurs("Erreur sur recherche d'une commande.", "Commande.RechercheUneCommande()");

            try
            {
                String mysql = "SELECT * FROM commandes WHERE NO_COMMAND ='" + nuComm + "'";

                dt = DBInterface.Lecture(mysql, er);

                if (dt.IsInitialized && dt.Rows.Count > 0)
                {
                    comm = new Commande();
                    DataRow dataRow = dt.Rows[0];
                    comm.NuComm    = dataRow[0].ToString();
                    comm.NuVendeur = dataRow[1].ToString();
                    comm.NuClient  = dataRow[2].ToString();
                    Match  match = Regex.Match(dataRow[3].ToString(), pattern);
                    String temp  = match.Groups[3].Value + "-" + match.Groups[2].Value + "-" + match.Groups[1].Value;
                    comm.DateComm = temp;
                    comm.Fact     = dataRow[4].ToString();

                    try
                    {
                        String mysqlNbArticles = "SELECT count(*) ";
                        mysqlNbArticles += "FROM commandes c, detail_cde d WHERE c.NO_COMMAND='" + nuComm + "'";
                        mysqlNbArticles += " AND c.NO_COMMAND=d.NO_COMMAND GROUP BY c.NO_COMMAND";

                        DataTable tempDt;
                        Commande  tempComm;
                        tempDt = DBInterface.Lecture(mysqlNbArticles, er);

                        if (tempDt.IsInitialized && tempDt.Rows.Count > 0)
                        {
                            tempComm = new Commande();
                            DataRow tempDataRow = dt.Rows[0];
                            comm.NbArticles = Int16.Parse(tempDataRow[0].ToString());
                            return(comm);
                        }
                        else
                        {
                            return(null);
                        }
                    }
                    catch (MonException e)
                    {
                        throw new MonException(er.MessageUtilisateur(), er.MessageApplication(), e.Message);
                    }
                    catch (MySqlException e)
                    {
                        throw new MonException(er.MessageUtilisateur(), er.MessageApplication(), e.Message);
                    }
                }
                else
                {
                    return(null);
                }
            }
            catch (MonException e)
            {
                throw new MonException(er.MessageUtilisateur(), er.MessageApplication(), e.Message);
            }
            catch (MySqlException e)
            {
                throw new MonException(er.MessageUtilisateur(), er.MessageApplication(), e.Message);
            }
        }
Exemplo n.º 8
0
        /// <summary>
        /// Permet de récupérer les commandes
        /// </summary>
        /// <returns>List de commandes</returns>
        public static IEnumerable <Commande> GetCommandes()
        {
            IEnumerable <Commande> commandes = new List <Commande>();
            String    tempNoComm;
            DataTable dt;
            Commande  comm;
            Serreurs  er = new Serreurs("Erreur sur lecture des commandes.", "CommandesList.getCommandes()");

            try
            {
                String mysql = "SELECT * FROM commandes ORDER BY NO_COMMAND";

                dt = DBInterface.Lecture(mysql, er);

                foreach (DataRow dataRow in dt.Rows)
                {
                    comm           = new Commande();
                    comm.NuComm    = dataRow[0].ToString();
                    tempNoComm     = comm.NuComm;
                    comm.NuVendeur = dataRow[1].ToString();
                    comm.NuClient  = dataRow[2].ToString();
                    Match  match = Regex.Match(dataRow[3].ToString(), pattern);
                    String temp  = match.Groups[3].Value + "-" + match.Groups[2].Value + "-" + match.Groups[1].Value;
                    comm.DateComm = temp;
                    comm.Fact     = dataRow[4].ToString();

                    try
                    {
                        //Peut etre optimisé
                        String mysqlNbArticles = "SELECT count(*) ";
                        mysqlNbArticles += "FROM commandes c, detail_cde d WHERE c.NO_COMMAND='" + tempNoComm + "'";
                        mysqlNbArticles += " AND c.NO_COMMAND=d.NO_COMMAND GROUP BY c.NO_COMMAND";

                        DataTable tempDt;
                        Commande  tempComm;
                        tempDt = DBInterface.Lecture(mysqlNbArticles, er);

                        if (tempDt.IsInitialized && tempDt.Rows.Count > 0)
                        {
                            tempComm = new Commande();
                            DataRow tempDataRow = tempDt.Rows[0];
                            comm.NbArticles = Int16.Parse(tempDataRow[0].ToString());
                        }
                    }
                    catch (MonException e)
                    {
                        throw new MonException(er.MessageUtilisateur(), er.MessageApplication(), e.Message);
                    }
                    catch (MySqlException e)
                    {
                        throw new MonException(er.MessageUtilisateur(), er.MessageApplication(), e.Message);
                    }

                    ((List <Commande>)commandes).Add(comm);
                }

                return(commandes);
            }
            catch (MonException e)
            {
                throw new MonException(er.MessageUtilisateur(), er.MessageApplication(), e.Message);
            }
            catch (MySqlException e)
            {
                throw new MonException(er.MessageUtilisateur(), er.MessageApplication(), e.Message);
            }
        }