Exemple #1
0
        /* Last Commande Inserted
         */
        public static Commande lastCommande()
        {
            int cmd_id = 0;

            try
            {
                //connection à la base de données
                MySqlCommand cmd = new MySqlCommand(Bdd.lastCommande, Bdd.connexion());

                //Execute la commandekkke
                MySqlDataReader msdr = cmd.ExecuteReader();
                while (msdr.Read())
                {
                    cmd_id = Int32.Parse(msdr["cmd_id"].ToString());
                }
                msdr.Dispose();
                Bdd.deconnexion();
                return(CommandeDAO.selectCommandeById(cmd_id, false, false, false));
            }
            catch (Exception Ex)
            {
                MessageBox.Show("ERREUR BDD : lastCommande");
                Bdd.deconnexion();
                return(null);
            }
        }
Exemple #2
0
        /* Selectionner un client à l'aide de l'id
         * @param addCommande : true pour ajouter les commandes dans l'objet client
         * @param cmd_addPaiement : Completer les commandes avec les paiements
         * @param cmd_addArticles : Completer les commandes avec les articles
         */
        public static Client selectClientById(int client_id, Boolean addCommandes, Boolean cmd_addPaiement, Boolean cmd_addArticles)
        {
            Client retour = new Client();
            Client client = new Client();

            try
            {
                //connection à la base de données
                MySqlCommand cmd = new MySqlCommand(Bdd.selectClientById, Bdd.connexion());

                //ajout des parametres
                cmd.Parameters.AddWithValue("clt_id", client_id);

                //Execute la commande
                MySqlDataReader msdr = cmd.ExecuteReader();

                msdr.Read();
                client.id              = Int32.Parse(msdr["clt_id"].ToString());
                client.nom             = msdr["clt_nom"].ToString();
                client.prenom          = msdr["clt_prenom"].ToString();
                client.telfix          = msdr["clt_fix"].ToString();
                client.telmob          = msdr["clt_mob"].ToString();
                client.adresse         = Adresse.Parse(msdr["clt_adresse"].ToString());
                client.dateNaissance   = DateTime.Parse(msdr["clt_dateNaissance"].ToString());
                client.email           = msdr["clt_email"].ToString();
                client.dateInscription = DateTime.Parse(msdr["clt_dateInscription"].ToString());
                client.idCleanWay      = Int32.Parse(msdr["clt_idCleanway"].ToString());

                //client.contactMail = false;// bool.Parse(msdr["clt_contactmail"].ToString());
                //client.contactSms = false;//bool.Parse(msdr["clt_contactsms"].ToString());

                if (msdr["clt_contactmail"].ToString() == "False")
                {
                    client.contactMail = false;
                }
                else
                {
                    client.contactMail = true;
                }

                if (msdr["clt_contactsms"].ToString() == "False")
                {
                    client.contactSms = false;
                }
                else
                {
                    client.contactSms = true;
                }

                if (msdr["clt_type"].ToString() == "False")
                {
                    client.type = 0;
                }
                else
                {
                    client.type = 1;
                }

                msdr.Dispose();
                Bdd.deconnexion();

                #region ajout des commandes
                if (addCommandes)
                {
                    // Attention ! dernier parametre obligatoirement en false afin de ne pas boucler.
                    retour.listCommandes = CommandeDAO.selectCommandesByClient(retour.id, cmd_addPaiement, cmd_addArticles, false);
                }
                #endregion

                return(client);
            }
            catch (Exception Ex)
            {
                MessageBox.Show("ERREUR BDD : selectClientById");
                Bdd.deconnexion();
                return(null);
            }
        }
Exemple #3
0
        /* Selectionner les articles rendu en fonction de la date
         * @Param plage date :
         * 1 : par jour
         * 2 : par semaine
         * 3 : par mois
         * 4 : par année
         */
        public static List <Article> selectArticlePayeeByDateNoCleanWay(int plageDate)
        {
            int test = 0;

            try
            {
                List <Article> requestResult = new List <Article>();
                List <Article> retour        = new List <Article>();
                List <int>     ifpayee       = new List <int>();

                //connection à la base de données
                MySqlCommand cmd = new MySqlCommand(Bdd.selectArticlePayeeByDate, Bdd.connexion());

                #region ajout des parametres
                switch (plageDate)
                {
                //par jour
                case 1:
                    cmd.Parameters.AddWithValue("startTime", new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 0, 0, 0));
                    cmd.Parameters.AddWithValue("endTime", new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 23, 59, 59));
                    break;

                //par semaine
                case 2:
                    cmd.Parameters.AddWithValue("startTime", new DateTime(SecondaryDateTime.GetMonday(DateTime.Now).Year, SecondaryDateTime.GetMonday(DateTime.Now).Month, SecondaryDateTime.GetMonday(DateTime.Now).Day, 0, 0, 0));
                    cmd.Parameters.AddWithValue("endTime", new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 23, 59, 59));
                    break;

                //par mois
                case 3:
                    cmd.Parameters.AddWithValue("startTime", new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1, 0, 0, 0));
                    cmd.Parameters.AddWithValue("endTime", new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 23, 59, 59));
                    break;

                //par année
                case 4:
                    cmd.Parameters.AddWithValue("startTime", new DateTime(DateTime.Now.Year, 1, 1, 0, 0, 0));
                    cmd.Parameters.AddWithValue("endTime", new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 23, 59, 59));
                    break;
                }
                #endregion

                #region récupération depuis la BDD des articles
                //Execute la commande
                MySqlDataReader msdr = cmd.ExecuteReader();
                //Article article;
                while (msdr.Read())
                {
                    Article article = new Article();
                    article.id          = Int32.Parse(msdr["art_id"].ToString());
                    article.photo       = msdr["art_photo"].ToString();
                    article.commentaire = msdr["art_commentaire"].ToString();
                    article.ifRendu     = bool.Parse(msdr["art_rendu"].ToString());
                    article.TVA         = float.Parse(msdr["art_TVA"].ToString());
                    article.TTC         = float.Parse(msdr["art_TTC"].ToString());
                    article.type        = new TypeArticle(Int32.Parse(msdr["art_typ_id"].ToString()), null, 0, 0, 0, null);

                    if (msdr["art_conv_id"].ToString().Equals("") || msdr["art_conv_id"].ToString() == null)
                    {
                        article.convoyeur = new PlaceConvoyeur(0, 0, 0);
                    }
                    else
                    {
                        article.convoyeur = new PlaceConvoyeur(Int32.Parse(msdr["art_conv_id"].ToString()), 0, 0);
                    }

                    article.fk_commande = Int32.Parse(msdr["art_cmd_id"].ToString());
                    if (!msdr["art_date_payee"].ToString().Equals(""))
                    {
                        article.date_payee = DateTime.Parse(msdr["art_date_payee"].ToString());
                    }
                    requestResult.Add(article);
                }
                msdr.Dispose();
                Bdd.deconnexion();
                #endregion

                Commande commande;
                foreach (Article art in requestResult)
                {
                    if (art.id == 564)
                    {
                        test = art.id;
                    }
                    commande = CommandeDAO.selectCommandeById(art.fk_commande, true, false, false);
                    if (commande.listPayements.Count != 0)
                    {
                        if (commande.listPayements[0] != null)
                        {
                            //si l'article n'a pas été payée par cleanWay
                            if (!(commande.listPayements[0].typePaiement.Equals("CleanWay")))
                            {
                                retour.Add(art);
                            }
                        }
                    }
                }



                #region ajout des types, des departements et des places convoyeurs
                foreach (Article art in retour)
                {
                    art.type      = TypeArticleDAO.selectTypesById(art.type.id);
                    art.convoyeur = PlaceConvoyeurDAO.selectConvoyeurById(art.convoyeur.id);
                }
                #endregion

                return(retour);
            }
            catch (Exception Ex)
            {
                MessageBox.Show("ERREUR BDD : selectArticlePayeeByDateNoCleanWay : " + Ex);
                Bdd.deconnexion();
                return(null);
            }
        }