Esempio n. 1
0
        public static List <Achat> readAll()
        {
            List <Achat> res   = new List <Achat>();
            Achat        achat = null;

            MySqlCommand cmd = new MySqlCommand();

            cmd.CommandText = "SELECT * FROM locations";
            cmd.Connection  = Connexion.getInstance();

            try
            {
                MySqlDataReader reader = cmd.ExecuteReader();

                while (reader.Read())
                {
                    Commande idCo       = CommandeADO.findById(reader["idCo"].ToString());
                    bool     demandeL   = bool.Parse(reader["demandeLivraison"].ToString());
                    float    prixTotal  = float.Parse(reader["prixTotal"].ToString());
                    int      effectifMT = Int32.Parse(reader["effectifMaterielTotal"].ToString());
                    Clients  idCl       = ClientsADO.findById(reader["idCl"].ToString());
                    achat = new Achat(idCo, demandeL, prixTotal, effectifMT, idCl);
                    res.Add(achat);
                }
                cmd = null;
                reader.Close();
                reader = null;
            }
            catch (Exception ex)
            {
                Console.WriteLine("Erreur de dataReader : " + ex.Message);
            }
            return(res);
        }
Esempio n. 2
0
        public static List <Commande> readAll()
        {
            List <Commande> res      = new List <Commande>();
            Commande        commande = null;

            MySqlCommand cmd = new MySqlCommand();

            cmd.CommandText = "SELECT * FROM materiels";
            cmd.Connection  = Connexion.getInstance();

            try
            {
                MySqlDataReader reader = cmd.ExecuteReader();

                while (reader.Read())
                {
                    float   prixTotal    = float.Parse(reader["prixTotal"].ToString());
                    int     effectifMT   = Int32.Parse(reader["effectifMaterielTotal"].ToString());
                    string  typeCommande = reader["typeCommande"].ToString();
                    Clients idCl         = ClientsADO.findById(reader["idCl"].ToString());
                    commande = new Commande(prixTotal, effectifMT, typeCommande, idCl);
                    res.Add(commande);
                }
                cmd = null;
                reader.Close();
                reader = null;
            }
            catch (Exception ex)
            {
                Console.WriteLine("Erreur de dataReader : " + ex.Message);
            }
            return(res);
        }
Esempio n. 3
0
        public static Location findById(string id)
        {
            Location loc = null;

            MySqlCommand cmd = new MySqlCommand();

            cmd.CommandText = "SELECT * FROM locations WHERE idCo = @idCo";
            cmd.Parameters.AddWithValue("@idCo", id);

            //Connexion temporaire !
            string          chaineDeConnexion = "server=localhost; database=projet dj; username=root; Pooling=true; charset=utf8";
            MySqlConnection connexion         = null;

            try
            {
                connexion = new MySqlConnection(chaineDeConnexion);
                connexion.Open();
            }
            catch (Exception ex)
            {
                Console.WriteLine("Erreur de connexion : " + ex.Message);
            }
            cmd.Connection = connexion;

            try
            {
                MySqlDataReader reader = cmd.ExecuteReader();

                if (reader.Read())
                {
                    Commande idCo       = CommandeADO.findById(reader["idCo"].ToString());
                    DateTime dateD      = DateTime.Parse(reader["dateDebut"].ToString());
                    DateTime dateF      = DateTime.Parse(reader["dateFin"].ToString());
                    bool     demandeI   = bool.Parse(reader["demandeInstallation"].ToString());
                    float    prixTotal  = float.Parse(reader["prixTotal"].ToString());
                    int      effectifMT = Int32.Parse(reader["effectifMaterielTotal"].ToString());
                    Clients  idCl       = ClientsADO.findById(reader["idCl"].ToString());
                    loc = new Location(idCo, dateD, dateF, demandeI, prixTotal, effectifMT, idCl);
                }
                cmd = null;
                reader.Close();
                reader = null;
            }
            catch (Exception ex)
            {
                Console.WriteLine("Erreur de dataReader : " + ex.Message);
            }

            connexion.Close();
            connexion = null;
            return(loc);
        }
Esempio n. 4
0
        // **************************************** RECHERCHE **************************************
        public static List <Achat> findByRecherche(string recherche)
        {
            List <Achat> res   = new List <Achat>();
            Achat        achat = null;

            MySqlCommand cmd = new MySqlCommand();

            cmd.CommandText = "SELECT * FROM achats WHERE idCo LIKE '" + recherche + "%'";

            //Connexion temporaire !
            string          chaineDeConnexion = "server=localhost; database=projet dj; username=root; Pooling=true; charset=utf8";
            MySqlConnection connexion         = null;

            try
            {
                connexion = new MySqlConnection(chaineDeConnexion);
                connexion.Open();
            }
            catch (Exception ex)
            {
                Console.WriteLine("Erreur de connexion : " + ex.Message);
            }
            cmd.Connection = connexion;

            try
            {
                MySqlDataReader reader = cmd.ExecuteReader();

                while (reader.Read())
                {
                    Commande idCo       = CommandeADO.findById(reader["idCo"].ToString());
                    DateTime dateA      = DateTime.Parse(reader["dateAchat"].ToString());
                    bool     demandeL   = bool.Parse(reader["demandeLivraison"].ToString());
                    float    prixTotal  = float.Parse(reader["prixTotal"].ToString());
                    int      effectifMT = Int32.Parse(reader["effectifMaterielTotal"].ToString());
                    Clients  idCl       = ClientsADO.findById(reader["idCl"].ToString());
                    achat = new Achat(idCo, dateA, demandeL, prixTotal, effectifMT, idCl);
                    res.Add(achat);
                }
                cmd = null;
                reader.Close();
                reader = null;
            }
            catch (Exception ex)
            {
                Console.WriteLine("Erreur de dataReader : " + ex.Message);
            }
            connexion.Close();
            connexion = null;
            return(res);
        }
Esempio n. 5
0
        public static Commande findById(string id)
        {
            Commande mat = null;

            MySqlCommand cmd = new MySqlCommand();

            cmd.CommandText = "SELECT * FROM commandes WHERE idCo = @idCo";
            cmd.Parameters.AddWithValue("@idCo", id);

            //Connexion temporaire !
            string          chaineDeConnexion = "server=localhost; database=projet dj; username=root; Pooling=true; charset=utf8";
            MySqlConnection connexion         = null;

            try
            {
                connexion = new MySqlConnection(chaineDeConnexion);
                connexion.Open();
            }
            catch (Exception ex)
            {
                Console.WriteLine("Erreur de connexion : " + ex.Message);
            }
            cmd.Connection = connexion;

            try
            {
                MySqlDataReader reader = cmd.ExecuteReader();

                if (reader.Read())
                {
                    float   prixTotal    = float.Parse(reader["prixTotal"].ToString());
                    int     effectifMT   = Int32.Parse(reader["effectifMaterielTotal"].ToString());
                    string  typeCommande = reader["typeCommande"].ToString();
                    Clients idCl         = ClientsADO.findById(reader["idCl"].ToString());
                    mat = new Commande(prixTotal, effectifMT, typeCommande, idCl);
                }
                cmd = null;
                reader.Close();
                reader = null;
            }
            catch (Exception ex)
            {
                Console.WriteLine("Erreur de dataReader : " + ex.Message);
            }

            connexion.Close();
            connexion = null;
            return(mat);
        }
Esempio n. 6
0
        // **************************************** RECHERCHE **************************************
        public static List <Commande> findByRecherche(string recherche)
        {
            List <Commande> res      = new List <Commande>();
            Commande        commande = null;

            MySqlCommand cmd = new MySqlCommand();

            cmd.CommandText = "SELECT * FROM commandes WHERE idCo LIKE '" + recherche + "%'";

            //Connexion temporaire !
            string          chaineDeConnexion = "server=localhost; database=projet dj; username=root; Pooling=true; charset=utf8";
            MySqlConnection connexion         = null;

            try
            {
                connexion = new MySqlConnection(chaineDeConnexion);
                connexion.Open();
            }
            catch (Exception ex)
            {
                Console.WriteLine("Erreur de connexion : " + ex.Message);
            }
            cmd.Connection = connexion;

            try
            {
                MySqlDataReader reader = cmd.ExecuteReader();

                while (reader.Read())
                {
                    float   prixTotal    = float.Parse(reader["prixTotal"].ToString());
                    int     effectifMT   = Int32.Parse(reader["effectifMaterielTotal"].ToString());
                    string  typeCommande = reader["typeCommande"].ToString();
                    Clients idCl         = ClientsADO.findById(reader["idCl"].ToString());
                    commande = new Commande(prixTotal, effectifMT, typeCommande, idCl);
                    res.Add(commande);
                }
                cmd = null;
                reader.Close();
                reader = null;
            }
            catch (Exception ex)
            {
                Console.WriteLine("Erreur de dataReader : " + ex.Message);
            }
            connexion.Close();
            connexion = null;
            return(res);
        }