コード例 #1
0
        public List <Commande> GetListeCommandeAnnule(string dateDebut, string dateFin)
        {
            Connexion connexion = new Connexion();
            string    query     = "";

            if (dateDebut == "" && dateFin == "")
            {
                query = "select * from commande where ETAT = '000' and CLIENT='1'";
            }
            else
            {
                query = "select * from commande where ETAT = '000' and CLIENT='1' and date_commande<='" + dateFin + "' and date_commande>='" + dateDebut + "'";
            }
            MySqlCommand    command      = new MySqlCommand(query, connexion.GetConnection());
            AccesSageDAO    accesSageDAO = new AccesSageDAO();
            MySqlDataReader dataReader;
            //Creation d'une liste
            List <Commande> reponse = new List <Commande>();

            try
            {
                //Ouverture connexion
                if (connexion.OpenConnection() == true)
                {
                    //Excecution de la commande
                    dataReader = command.ExecuteReader();

                    //Lecture des donnees et stockage dans la liste
                    while (dataReader.Read())
                    {
                        Comptoir comptoir = accesSageDAO.GetComptoirById(dataReader["ID_COMPTOIR"].ToString());
                        Commande commande = new Commande(Int32.Parse(dataReader["id_commande"].ToString()), dataReader["DATE_COMMANDE"].ToString(), dataReader["NUMERO"].ToString(), comptoir, Int32.Parse(dataReader["CLIENT"].ToString()), dataReader["ETAT"].ToString());
                        List <DetailCommande> detailCommandes = GetArticlesCommandes(commande.Numero);
                        for (int i = 0; i < detailCommandes.Count; i++)
                        {
                            int quantite = detailCommandes[i].Quantite;
                            detailCommandes[i].Article  = accesSageDAO.GetArticleByReferences(detailCommandes[i].Article.References);
                            detailCommandes[i].Quantite = quantite;
                        }
                        commande.ListeDetailCommande = detailCommandes;
                        reponse.Add(commande);
                    }
                    dataReader.Close();
                }
                //return
                return(reponse);
            }
            catch (Exception exception)
            {
                throw exception;
            }
            finally
            {
                connexion.CloseAll(command, null, connexion.GetConnection());
            }
        }
コード例 #2
0
        public List <Commande> GetListeCommande(string dateDebut, string dateFin)
        {
            Connexion connexion = new Connexion();
            string    query     = "";

            if (dateDebut == "" && dateFin == "")
            {
                query = "select * from commande join duree on duree.id_commande =commande.id_commande join sortie on sortie.id_commande=commande.id_commande where commande.ETAT = '111' and commande.CLIENT='1' group by sortie.id_commande";
            }
            else
            {
                query = "select * from commande join duree on duree.id_commande =commande.id_commande join sortie on sortie.id_commande=commande.id_commande where commande.ETAT = '111' and commande.CLIENT='1' and commande.date_commande<='" + dateFin + "' and commande.date_commande>='" + dateDebut + "' group by sortie.id_commande";
            }
            MySqlCommand    command        = new MySqlCommand(query, connexion.GetConnection());
            AccesSageDAO    accesSageDAO   = new AccesSageDAO();
            UtilisateurDAO  utilisateurDAO = new UtilisateurDAO();
            MySqlDataReader dataReader;
            //Creation d'une liste
            List <Commande> reponse = new List <Commande>();

            try
            {
                //Ouverture connexion
                if (connexion.OpenConnection() == true)
                {
                    //Excecution de la commande
                    dataReader = command.ExecuteReader();

                    //Lecture des donnees et stockage dans la liste
                    while (dataReader.Read())
                    {
                        Comptoir comptoir = accesSageDAO.GetComptoirById(dataReader["ID_COMPTOIR"].ToString());
                        Commande commande = new Commande(Int32.Parse(dataReader["id_commande"].ToString()), dataReader["DATE_COMMANDE"].ToString(), dataReader["NUMERO"].ToString(), comptoir, Int32.Parse(dataReader["CLIENT"].ToString()), dataReader["ETAT"].ToString());
                        List <DetailCommande> detailCommandes = GetArticlesCommandes(commande.Numero);
                        for (int i = 0; i < detailCommandes.Count; i++)
                        {
                            int quantite = detailCommandes[i].Quantite;
                            detailCommandes[i].Article  = accesSageDAO.GetArticleByReferences(detailCommandes[i].Article.References);
                            detailCommandes[i].Quantite = quantite;
                        }
                        commande.ListeDetailCommande = detailCommandes;
                        Duree duree = new Duree();
                        duree.HeureCommandeString = dataReader["HEURE_COMMANDE"].ToString();
                        duree.HeureSortieString   = dataReader["HEURE_LIVRAISON"].ToString();
                        commande.Duree            = duree;
                        Utilisateur binome     = utilisateurDAO.GetUtilisateurById(dataReader["ID_BINOME"].ToString());
                        Utilisateur magasinier = utilisateurDAO.GetUtilisateurById(dataReader["ID_MAGASINIER"].ToString());
                        Commande    test       = new Commande();
                        test.IdCommande = Int32.Parse(dataReader["id_commande"].ToString());
                        SortieCommande sortie = new SortieCommande(dataReader["ID_SORTIE"].ToString(), test, binome, magasinier);
                        commande.SortieCommande = sortie;
                        reponse.Add(commande);
                    }
                    dataReader.Close();
                }
                return(reponse);
            }
            catch (Exception exception)
            {
                throw exception;
            }
            finally
            {
                connexion.CloseAll(command, null, connexion.GetConnection());
            }
        }