public void stock_Click(object sender, EventArgs e) { mysql.Connexion1.Open(); DataTable print = new DataTable(); print.Columns.Add("Référence"); print.Columns.Add("Désignation"); print.Columns.Add("Emplacement"); string req = "SELECT * FROM stock WHERE idEntrepot = '" + entrepot.IdenEntrepot + "'"; mysql.Command1 = new MySqlCommand(req, mysql.Connexion1); Reader = mysql.Command1.ExecuteReader(); do { while (Reader.Read()) { DataRow row = print.NewRow(); row["Référence"] = Reader.GetValue(1); row["Désignation"] = Reader.GetValue(2); row["Emplacement"] = Reader.GetValue(3); print.Rows.Add(row); } }while (Reader.NextResult()); Reader.Close(); mysql.CommandeClose(); this.Hide(); form3.Show(); foreach (DataRow row in print.Rows) { int num = form3.dataGridView1.Rows.Add(); form3.dataGridView1.Rows[num].Cells[0].Value = row["Référence"].ToString(); form3.dataGridView1.Rows[num].Cells[1].Value = row["Désignation"].ToString(); form3.dataGridView1.Rows[num].Cells[2].Value = row["Emplacement"].ToString(); } }
public void supprimerProduit(string emplacement, string entrepot) { ClassConnexionMySQL mysql = new ClassConnexionMySQL("entrepot"); string req = "DELETE FROM stock WHERE idEntrepot = '" + entrepot + "' AND emplacement='" + emplacement + "'"; mysql.CommandeInsertion(req); this.ProduitsEnStock.Remove(emplacement); this.PlacesDisponibles.Add(emplacement); mysql.CommandeClose(); }
public CEntrepot(string identEntrepot) { this.idenEntrepot = identEntrepot; this.produitsEnStock = new ArrayList(); this.placesDisponibles = new ArrayList(); List <char> travee = new List <char>() { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q' }; foreach (char rang in travee) { for (int num = 0; num < 100; num++) { this.PlacesDisponibles.Add(string.Concat(rang.ToString(), num.ToString())); } } ClassConnexionMySQL mysql = new ClassConnexionMySQL("entrepot"); string req = "SELECT count(*) FROM entrepot WHERE id = '" + this.IdenEntrepot + "'"; int count = mysql.rowCount(req); if (count == 0) { req = string.Format("INSERT INTO `entrepot`(`id`) VALUES('{0}')", idenEntrepot); mysql.CommandeInsertion(req); } else { req = "SELECT * FROM stock WHERE idEntrepot = '" + this.IdenEntrepot + "'"; mysql.Command1 = new MySqlCommand(req, mysql.Connexion1); MySqlDataReader Reader = mysql.Command1.ExecuteReader(); ArrayList places_occ = new ArrayList(); do { while (Reader.Read()) { CProduitEnStock produit = new CProduitEnStock(Reader.GetValue(3).ToString(), Reader.GetValue(1).ToString(), Reader.GetValue(2).ToString()); this.produitsEnStock.Add(produit.Emplacement); places_occ.Add(Reader.GetValue(3).ToString()); } }while (Reader.NextResult()); Reader.Close(); foreach (string i in places_occ) { this.PlacesDisponibles.Remove(i); } } mysql.CommandeClose(); }
public void stockerProduit(CProduitEnStock produit) { string place = this.donnerPlace(); produit.Emplacement = place; this.ProduitsEnStock.Add(place); this.placesDisponibles.Remove(place); ClassConnexionMySQL mysql = new ClassConnexionMySQL("entrepot"); mysql.Connexion1.Open(); string req = string.Format("INSERT INTO `stock`(`refProduit`,`designation`,`emplacement`,`idEntrepot`) VALUES('{0}','{1}','{2}','{3}')", produit.RefProduit, produit.DesignationProduit, produit.Emplacement, this.idenEntrepot); mysql.Command1 = new MySqlCommand(req, mysql.Connexion1); mysql.Command1.ExecuteNonQuery(); mysql.CommandeClose(); }
public string chercheProduit(string refProduit) { ClassConnexionMySQL mysql = new ClassConnexionMySQL("entrepot"); mysql.Connexion1.Open(); string req = "SELECT * FROM stock WHERE idEntrepot='" + this.IdenEntrepot + "' AND refProduit='" + refProduit + "'"; mysql.Command1 = new MySqlCommand(req, mysql.Connexion1); MySqlDataReader Reader = mysql.Command1.ExecuteReader(); do { while (Reader.Read()) { return(Reader.GetValue(3).ToString()); } }while (Reader.NextResult()); Reader.Close(); mysql.CommandeClose(); return(null); }