private void UpdateProductButton_Click(object sender, EventArgs e) { if (MessageBox.Show("Are You Sure You Want to Update this Product?", "Warning", MessageBoxButtons.YesNo) == DialogResult.Yes) { ProduitDAO pdo = new ProduitDAO(); CategorieDAO catd = new CategorieDAO(); int ProductID = Convert.ToInt32(ProductIDBox.Text); string ProductName = ProductNameBox.Text; decimal ProductPrice = Convert.ToDecimal(ProductPriceBox.Text); string ProductCategory = ProductCategoryComboBox.Text; int ProductCategoryID = catd.ReturnCategorieID(ProductCategory); string ProductDescription = ProductDescriptionRBox.Text; /*initializing memory stream class for creating a stream of binary numbers*/ MemoryStream ms = new MemoryStream(); /*saving the image in raw format from picture box*/ ProductPictureBox.Image.Save(ms, ProductPictureBox.Image.RawFormat); /*Array of Binary numbers that have been converted*/ byte[] MyProductPicture = ms.GetBuffer(); /*closing the memory stream*/ ms.Close(); if (pdo.UpdateProduct(ProductID, ProductName, ProductPrice, ProductCategoryID, ProductDescription, MyProductPicture)) { this.Close(); } else { MessageBox.Show("Poduct Not Updated", "Error", MessageBoxButtons.OK); } } }