private void AddProductButton_Click(object sender, EventArgs e) { FoodRepository _DataAccess = new FoodRepository(); /*THIS IS THE MAIN CODE FOR HASHING*/ /*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[] ProductPicture = ms.GetBuffer(); /*closing the memory stream*/ ms.Close(); /*HASHING END HERE*/ if (_DataAccess.AddNewProductToDatabase(ProductNameBox.Text, Convert.ToDecimal(ProductPriceBox.Text), _DataAccess.ReturnCategoryID(ProductCategoryComboBox.SelectedItem.ToString()), ProductDescriptionRBox.Text, ProductPicture)) { MessageBox.Show("Product Added"); } else { MessageBox.Show("Product Not Added"); } }