private void button2_Click(object sender, EventArgs e) { int categorieId = int.Parse(this.categorieID.Text.Trim()); String categorieNom = this.categorie.Text.Trim(); try { if (categorieNom == "") { MessageBox.Show("Please Type a New Category Name to be added."); Cnx.populateTable(sqliteCon, "select * from categories", this.dataGridView1); } else { String query = "update categories set id=" + categorieId + ", nom_cat='" + categorieNom + "' where id=" + categorieId + ";"; Cnx.InsertData(sqliteCon, query); Cnx.populateTable(sqliteCon, "select * from categories", this.dataGridView1); setNeWCatId(); this.categorie.Text = ""; } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); } }
private void GestionDeCategorie_Load(object sender, EventArgs e) { setNeWCatId(); String query = "select * from categories"; Cnx.populateTable(sqliteCon, query, this.dataGridView1); }
private void button1_Click(object sender, EventArgs e) { int catId = int.Parse(catID.Text); int productId = int.Parse(ID.Text); string productName = this.nom_du_produit.Text.Trim(); double prix = double.Parse(this.prix.Text); string description = this.description.Text.Trim(); string query = "insert into produit values(" + productId + ",'" + productName + "'," + prix + " ," + catId + " ,'" + description + "')"; Cnx.InsertData(sqliteCon, query); Cnx.populateTable(sqliteCon, "select * from produit", this.dataGridView1); SQLiteDataReader maxId = Cnx.getData(sqliteCon, "select MAX(id) from produit"); if (maxId.Read()) { int newId = maxId.GetInt32(0) + 1; this.ID.Text = newId.ToString(); } this.ID.Text = ""; this.nom_du_produit.Text = ""; this.prix.Text = ""; this.description.Text = ""; MessageBox.Show("Product Successfully Added"); }
private void button3_Click(object sender, EventArgs e) { int productId = int.Parse(ID.Text); String query = "Delete from produit where id=" + productId + ";"; Cnx.InsertData(sqliteCon, query); Cnx.populateTable(sqliteCon, "select * from produit", this.dataGridView1); this.ID.Text = ""; this.nom_du_produit.Text = ""; this.prix.Text = ""; this.description.Text = ""; MessageBox.Show("Product Successfully Deleted"); }
private void ManageProducts_Load(object sender, EventArgs e) { SQLiteDataReader dr = Cnx.getData(sqliteCon, "select * from categories"); SQLiteDataReader maxId = Cnx.getData(sqliteCon, "select MAX(id) from produit"); while (dr.Read()) { this.comboBox1.Items.Add(dr.GetString(1)); } Cnx.populateTable(sqliteCon, "select * from produit", this.dataGridView1); if (maxId.Read()) { int newId = maxId.GetInt32(0) + 1; this.ID.Text = newId.ToString(); } }
private void button3_Click(object sender, EventArgs e) { int categorieId = int.Parse(this.categorieID.Text.Trim()); try { String query = "Delete from categories where id=" + categorieId + ";"; Cnx.InsertData(sqliteCon, query); Cnx.populateTable(sqliteCon, "select * from categories", this.dataGridView1); setNeWCatId(); this.categorie.Text = ""; } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); } }