Exemplo n.º 1
0
 private void dataMateriel()
 {
     foreach (Materiel mat in MaterielADO.readAll())
     {
         dGVMateriel.Rows.Add(mat.Id, mat.Nom, mat.Puissance, mat.Dimensions, mat.Masse, mat.Stock, mat.PrixAchat, mat.PrixLocation, mat.PrixVente); //, mat.Image
     }
 }
Exemplo n.º 2
0
        private void LblValider_Click(object sender, EventArgs e)
        {
            int    i = 0;
            string idM;
            string nom          = txtBoxNom.Text;
            int    puissance    = Int32.Parse(txtBoxPuissance.Text);
            string dimensions   = txtBoxDimensions.Text;
            float  masse        = float.Parse(txtBoxMasse.Text);
            int    stock        = Int32.Parse(txtBoxStock.Text);
            float  prixAchat    = float.Parse(txtBoxPA.Text);
            float  prixLocation = float.Parse(txtBoxPL.Text);
            float  prixVente    = float.Parse(txtBoxPV.Text);
            string image        = txtBoxImage.Text;

            foreach (Materiel mat in MaterielADO.readAll())
            {
                idM = i.ToString();
                if (mat.Nom != nom && mat.Id != idM)
                {
                    Materiel mat2 = new Materiel(idM, nom, puissance, dimensions, masse, stock, prixAchat, prixLocation, prixVente, image);
                    MaterielADO.create(mat2);
                    MessageBox.Show("Enregistré");
                }
                i++;
            }
        }
Exemplo n.º 3
0
        private void DétailsCommande_Load(object sender, EventArgs e)
        {
            if (this.locAchat == "Location")
            {
                gBAchat.Visible = false;
                foreach (Materiel mat in MaterielADO.readAll())
                {
                    dGVLocation.Rows.Add(mat.Nom);
                }

                foreach (Location loc in LocationADO.readAll())
                {
                    dGVLocation.Rows.Add(loc.DateD, loc.DateF, loc.DemandeI, loc.EffectifMT, loc.PrixTotal);
                }
            }

            else
            {
                gBLocation.Visible = false;
                foreach (Materiel mat in MaterielADO.readAll())
                {
                    dGVLocation.Rows.Add(mat.Nom);
                }
                foreach (Achat achat in AchatADO.readAll())
                {
                    dGVLocation.Rows.Add(achat.DateAchat, achat.DemandeL, achat.EffectifMT, achat.PrixTotal);
                }
            }
        }
Exemplo n.º 4
0
        public static List <Contenir> readAll()
        {
            List <Contenir> res  = new List <Contenir>();
            Contenir        ctnr = null;

            MySqlCommand cmd = new MySqlCommand();

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

            try
            {
                MySqlDataReader reader = cmd.ExecuteReader();

                while (reader.Read())
                {
                    Materiel idM        = MaterielADO.findById(reader["idM"].ToString());
                    Commande idCo       = CommandeADO.findById(reader["idCo"].ToString());
                    string   nbMateriel = reader["nbMateriel"].ToString();
                    ctnr = new Contenir(idM, idCo, nbMateriel);
                    res.Add(ctnr);
                }
                cmd = null;
                reader.Close();
                reader = null;
            }
            catch (Exception ex)
            {
                Console.WriteLine("Erreur de dataReader : " + ex.Message);
            }
            return(res);
        }
Exemplo n.º 5
0
        private void loadgrid()
        {
            if (this.locAchat == "Location")
            {
                gBAchat.Visible    = false;
                gBLocation.Visible = true;
                foreach (Materiel mat in MaterielADO.readAll())
                {
                    if (mat.PrixVente.Equals(0))
                    {
                        dGVLocation.Rows.Add(mat.Nom, mat.Puissance, mat.Dimensions, mat.Masse, mat.PrixLocation); //, mat.Image
                    }
                }
            }

            else if (this.locAchat == "Achat")
            {
                gBLocation.Visible = false;
                gBAchat.Visible    = true;
                foreach (Materiel mat2 in MaterielADO.readAll())
                {
                    if (!mat2.PrixVente.Equals(0))
                    {
                        dGVAchat.Rows.Add(mat2.Nom, mat2.Puissance, mat2.Dimensions, mat2.Masse, mat2.PrixVente); //, mat.Image
                    }
                }
            }
        }
Exemplo n.º 6
0
        public static Contenir findById(string id)
        {
            Contenir ctnr = null;

            MySqlCommand cmd = new MySqlCommand();

            cmd.CommandText = "SELECT * FROM contenir 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())
                {
                    Materiel idM        = MaterielADO.findById(reader["idM"].ToString());
                    Commande idCo       = CommandeADO.findById(reader["idCo"].ToString());
                    string   nbMateriel = reader["nbMateriel"].ToString();
                    ctnr = new Contenir(idM, idCo, nbMateriel);
                }
                cmd = null;
                reader.Close();
                reader = null;
            }
            catch (Exception ex)
            {
                Console.WriteLine("Erreur de dataReader : " + ex.Message);
            }

            connexion.Close();
            connexion = null;
            return(ctnr);
        }
Exemplo n.º 7
0
        // **************************************** RECHERCHE **************************************
        public static List <Contenir> findByRecherche(string recherche)
        {
            List <Contenir> res  = new List <Contenir>();
            Contenir        ctnr = null;

            MySqlCommand cmd = new MySqlCommand();

            cmd.CommandText = "SELECT * FROM contenir 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())
                {
                    Materiel idM        = MaterielADO.findById(reader["idM"].ToString());
                    Commande idCo       = CommandeADO.findById(reader["idCo"].ToString());
                    string   nbMateriel = reader["nbMateriel"].ToString();
                    ctnr = new Contenir(idM, idCo, nbMateriel);
                    res.Add(ctnr);
                }
                cmd = null;
                reader.Close();
                reader = null;
            }
            catch (Exception ex)
            {
                Console.WriteLine("Erreur de dataReader : " + ex.Message);
            }
            connexion.Close();
            connexion = null;
            return(res);
        }