Esempio n. 1
0
        private void button4_Click(object sender, EventArgs e)
        {
            Depot dp = new Depot();


            dataGridView1.DataSource = dp.RecupAllDepot();
        }
Esempio n. 2
0
        private void button6_Click(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(textBox3.Text) == true)
            {
                MessageBox.Show("Quantite vide");
            }
            else if (String.IsNullOrEmpty(textBox2.Text) == true)
            {
                MessageBox.Show("Lieu vide");
            }


            else if (dataGridView1.CurrentRow.Cells[2].Value.ToString().All(char.IsDigit))
            {
                Depot dp = new Depot();
                dp._Quantite = Int32.Parse(textBox3.Text);
                dp._Lieu     = textBox2.Text.ToString();
                dp.updateDepot(dp, Int32.Parse(dataGridView1.CurrentRow.Cells[2].Value.ToString()));
                dataGridView1.DataSource = dp.RecupAllDepot();
            }
            else
            {
                MessageBox.Show("Ce n'est pas un chiffre");
            }
        }
Esempio n. 3
0
        private void button2_Click(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(textBox3.Text) == true)
            {
                MessageBox.Show("Quantite vide");
            }
            if (String.IsNullOrEmpty(textBox2.Text) == true)
            {
                MessageBox.Show("Depot vide");
            }



            if ((String.IsNullOrEmpty(textBox3.Text) == false) && (String.IsNullOrEmpty(textBox2.Text) == false))
            {
                Depot dep = new Depot();
                dep._Quantite = Int32.Parse(textBox3.Text);
                dep._Lieu     = textBox2.Text.ToString();
                dep.insertdepot(dep);
                MessageBox.Show("Depot ajoute Quantite: " + textBox3.Text + " Lieu " + textBox2.Text);



                //DataTable dt = new DataTable();
                //dt = cli.RecupAllClient();
                dataGridView1.DataSource = dep.RecupAllDepot();
                textBox3.Clear();
                textBox2.Clear();
            }
        }
Esempio n. 4
0
        public int updateDepot(Depot depot, int DepotId)
        {
            using (MySqlConnection con = DbCon.GetDBConnection())
            {
                con.Open();
                MySqlCommand dCmd = new MySqlCommand("UPDATE Depot set Quantite=@Quantite, Lieu=@Lieu where id_depot=@id_depot", con);
                dCmd.CommandType = CommandType.Text;
                try
                {
                    dCmd.Parameters.AddWithValue("@id_depot", DepotId);
                    dCmd.Parameters.AddWithValue("@Quantite", depot._Quantite);
                    dCmd.Parameters.AddWithValue("@Lieu", depot._Lieu);
                    return(dCmd.ExecuteNonQuery());
                }



                catch (Exception e)
                {
                    throw e;
                }

                finally
                {
                    dCmd.Dispose();

                    con.Close();

                    con.Dispose();
                }
            }
        }
Esempio n. 5
0
        public int insertdepot(Depot depot)
        {
            using (MySqlConnection con = DbCon.GetDBConnection())
            {
                con.Open();
                MySqlCommand dCmd = new MySqlCommand("INSERT INTO Depot (Quantite, Lieu)  Values (@Quantite,@Lieu)", con);
                dCmd.CommandType = CommandType.Text;
                try
                {
                    dCmd.Parameters.AddWithValue("@Quantite", depot._Quantite);
                    dCmd.Parameters.AddWithValue("@Lieu", depot._Lieu);
                    return(dCmd.ExecuteNonQuery());
                }



                catch (Exception e)
                {
                    throw e;
                }

                finally
                {
                    dCmd.Dispose();

                    con.Close();

                    con.Dispose();
                }
            }
        }
Esempio n. 6
0
        private void FormListDepot_Load(object sender, EventArgs e)
        {
            // TODO: cette ligne de code charge les données dans la table 'instadbDataSet.depot'. Vous pouvez la déplacer ou la supprimer selon les besoins.
            //this.depotTableAdapter.Fill(this.instadbDataSet.depot);
            Depot dep = new Depot();

            dataGridView1.DataSource = dep.RecupAllDepot();
        }
Esempio n. 7
0
        public Depot RecupProduit(int DepotId)
        {
            Depot Dep = new Depot();
            //traitement code

            //creer l'objet de connexion
            MySqlConnection conn = DbCon.GetDBConnection();

            conn.Open();
            // ouvrir la connection


            //preparer la commande

            string sql = "SELECT Quantite, Lieu  FROM depot where(id_depot=" + DepotId + ") ";

            // creer un objet command



            MySqlCommand cmd = new MySqlCommand();

            cmd.Connection  = conn;
            cmd.CommandText = sql;

            //
            try
            {
                using (DbDataReader reader = cmd.ExecuteReader())
                {
                    if (reader.HasRows)
                    {
                        while (reader.Read())
                        {
                            //prod.ProduitId = Convert.ToInt32(reader.GetString(1));
                            Dep._Quantite = reader.GetInt32(0);
                            Dep._Lieu     = reader.GetString(1);

                            //prod.Prix = reader.GetDecimal(2);
                            //prod.Prix = Convert.ToDecimal(reader.GetString(2));
                        }
                    }
                }
                return(Dep);
            }

            finally

            {
                conn.Close();
                conn.Dispose();
            }
        }
Esempio n. 8
0
        private void button1_Click(object sender, EventArgs e)
        {
            Depot dep = new Depot();

            var lisprod = new List <Depot>();

            lisprod.Add(dep.RecupProduit(1));

            foreach (var article in lisprod)
            {
                MessageBox.Show(article._Quantite.ToString());
                //MessageBox.Show(prod.ProduitId.ToString());
                MessageBox.Show(article._Lieu);
            }
        }
Esempio n. 9
0
 private void button5_Click(object sender, EventArgs e)
 {
     if (String.IsNullOrEmpty(dataGridView1.CurrentRow.Cells[2].Value.ToString()) == true)
     {
         MessageBox.Show("Id vide");
     }
     else if (dataGridView1.CurrentRow.Cells[2].Value.ToString().All(char.IsDigit))
     {
         Depot dp = new Depot();
         dp.DeleteDepot(Int32.Parse(dataGridView1.CurrentRow.Cells[2].Value.ToString()));
         dataGridView1.DataSource = dp.RecupAllDepot();
     }
     else
     {
         MessageBox.Show("Ce n'est pas un chiffre");
     }
 }