private void btnOk_Click(object sender, EventArgs e) { if (state == "add") { MemoryStream ms = new MemoryStream(); pbox.Image.Save(ms, pbox.Image.RawFormat); byte[] byteImage = ms.ToArray(); prd.ADD_PRUDUCT(Convert.ToInt32(cmbCategories.SelectedValue), txtDes.Text , txtRef.Text, Convert.ToInt32(txtQte.Text), txtPrice.Text, byteImage, photo_path); MessageBox.Show("تمت الإضافة بنجاح", "عملية الإضافة", MessageBoxButtons.OK, MessageBoxIcon.Information); txtDes.Clear(); txtPrice.Clear(); txtQte.Clear(); txtRef.Clear(); pbox.Image = Final_Project.Properties.Resources._00; cmbCategories.Focus(); FRM_PRODUCTS.getMainForm.dataGridView1.DataSource = prd.GET_ALL_PRODUCTS(); } else { MemoryStream ms = new MemoryStream(); pbox.Image.Save(ms, pbox.Image.RawFormat); byte[] byteImage = ms.ToArray(); if (photo_path == null) { MessageBox.Show("قم بتحديد الصورة من جديد", "عملية التعديل", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { prd.UPDATE_PRODUCT(Convert.ToInt32(cmbCategories.SelectedValue), txtDes.Text , txtRef.Text, Convert.ToInt32(txtQte.Text), txtPrice.Text, byteImage, photo_path); MessageBox.Show("تم التعديل بنجاح", "عملية التعديل", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } } FRM_PRODUCTS.getMainForm.dataGridView1.DataSource = prd.GET_ALL_PRODUCTS(); }