private void metroButton_enregistrer_Click(object sender, EventArgs e) { try { Class_product updated_one = new Class_product(); updated_one.name = metroTextBox_nom.Text; updated_one.barcode = metroTextBox_barcode.Text; updated_one.price = float.Parse(metroTextBox_prix.Text); updated_one.category = int.Parse(metroComboBox_categorie.SelectedValue.ToString()); updated_one.image = my_image; Boolean is_updated = Database.update_product_by_id(id_product_to_modify, updated_one); if (is_updated) { MessageBox.Show("updated"); add_items_products(); } else { MessageBox.Show("Oops Error"); } } catch (Exception p) { MessageBox.Show(p.ToString()); } }
public void change_product_selected() { try { product_selected = Database.get_products_by_id(id_product_to_modify); metroTextBox_nom.Text = product_selected.name; metroTextBox_prix.Text = product_selected.price.ToString(); metroTextBox_barcode.Text = product_selected.barcode; metroComboBox_categorie.SelectedValue = product_selected.category; MemoryStream m = new MemoryStream((byte[])product_selected.image); my_image = (byte[])product_selected.image; pictureBox_image.Image = Image.FromStream(m); } catch (Exception n) { MessageBox.Show(n.ToString()); } }
private void metroButton_save_Click(object sender, EventArgs e) { Class_product p = new Class_product(); p.name = metroTextBox_product_name.Text; p.price = float.Parse(metroTextBox_product_price.Text); p.barcode = metroTextBoxBarCode.Text; p.category = int.Parse(metroComboBox_Categorie.SelectedValue.ToString()); p.image = bimage; Boolean is_saved = Database.save_new_product(p); if (is_saved) { MessageBox.Show("Le produit a été enregistré"); } else { MessageBox.Show("Oops Error"); } }