private void btn_OK_Click(object sender, EventArgs e)
 {
     if (txtb_Label.Text == string.Empty || txtb_Price.Text == string.Empty || txtb_ProductID.Text == string.Empty || txtb_Quantity.Text == string.Empty)
     {
         MessageBox.Show("Error : Incomplete Data, Please fill all missing data.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
     //For Control (Allowed/Banned) ProductID Replication Validate
     //False = Replication Banned In case Of Adding/True = Replication Allowed in case of Editing
     if (IDReplicationState == false)
     {
         //restore Pic into Array
         MemoryStream MS = new MemoryStream();
         pictureB_ProductImage.Image.Save(MS, pictureB_ProductImage.Image.RawFormat);
         byte[] PicArr = MS.ToArray();
         Pro.AddProduct(txtb_ProductID.Text, txtb_Label.Text, Convert.ToInt32(txtb_Quantity.Text), txtb_Price.Text, PicArr, Convert.ToInt32(cmbb_CategoryID.SelectedValue));
         MessageBox.Show("New Product Added Successfully", "Add", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     else
     {
         //restore Pic into Array
         MemoryStream MS = new MemoryStream();
         pictureB_ProductImage.Image.Save(MS, pictureB_ProductImage.Image.RawFormat);
         byte[] PicArr = MS.ToArray();
         Pro.UpdateProduct(txtb_ProductID.Text, txtb_Label.Text, Convert.ToInt32(txtb_Quantity.Text), txtb_Price.Text, PicArr, Convert.ToInt32(cmbb_CategoryID.SelectedValue));
         MessageBox.Show("Product Updated Successfully", "Update", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     //refresh DataGridView
     frm_Products.GetProductForm.dataGridV_Product.DataSource = Pro.GetAllProducts();
     this.Close();
 }
Beispiel #2
0
 //Method
 //This Method GetAllProducts Names to fill the dataGridView or(as A Refresher)
 private void ViewAllProducts()
 {
     dataGridV_Product.DataSource = Pro.GetAllProducts();
 }
        public frm_AllProducts()
        {
            InitializeComponent();

            this.dataGridView_Products.DataSource = Prod.GetAllProducts();
        }