Example #1
0
        private void BTN_PRODUCT_PRODUCT_Click(object sender, EventArgs e)
        {
            FORM_UPDATE_PRODUCT fup = new FORM_UPDATE_PRODUCT();

            fup.LBL_PID.Text          = DGV_PRODUCTS.CurrentRow.Cells[0].Value.ToString();
            fup.TB_NAME.Text          = DGV_PRODUCTS.CurrentRow.Cells[1].Value.ToString();
            fup.TB_QUANTITY.Text      = DGV_PRODUCTS.CurrentRow.Cells[2].Value.ToString();
            fup.TB_PRICE.Text         = DGV_PRODUCTS.CurrentRow.Cells[3].Value.ToString();
            fup.TB_DESCRIPTION.Text   = DGV_PRODUCTS.CurrentRow.Cells[5].Value.ToString();
            fup.COMBO_CATEGORIES.Text = DGV_PRODUCTS.CurrentRow.Cells[6].Value.ToString();

            byte[]       img = (byte[])DGV_PRODUCTS.CurrentRow.Cells[4].Value;
            MemoryStream ms  = new MemoryStream(img);

            fup.PB_BROWSE_IMAGE.Image = Image.FromStream(ms);
            fup.ShowDialog();
            DGV_PRODUCTS.DataSource = product.getProducts();
        }
        private void BTN_PRODUCT_PRODUCT_Click(object sender, EventArgs e)
        {
            try
            {
                if (DGV_PRODUCTS.CurrentRow.Cells[4].Value == System.DBNull.Value)
                {
                    FORM_UPDATE_PRODUCT fup = new FORM_UPDATE_PRODUCT();
                    fup.LBL_PID.Text          = DGV_PRODUCTS.CurrentRow.Cells[0].Value.ToString();
                    fup.TB_NAME.Text          = DGV_PRODUCTS.CurrentRow.Cells[1].Value.ToString();
                    fup.TB_QUANTITY.Text      = DGV_PRODUCTS.CurrentRow.Cells[2].Value.ToString();
                    fup.TB_PRICE.Text         = DGV_PRODUCTS.CurrentRow.Cells[3].Value.ToString();
                    fup.TB_DESCRIPTION.Text   = DGV_PRODUCTS.CurrentRow.Cells[5].Value.ToString();
                    fup.COMBO_CATEGORIES.Text = DGV_PRODUCTS.CurrentRow.Cells[6].Value.ToString();
                    ////////khasso ykmal
                }
                else
                {
                    FORM_UPDATE_PRODUCT fup = new FORM_UPDATE_PRODUCT();
                    fup.LBL_PID.Text          = DGV_PRODUCTS.CurrentRow.Cells[0].Value.ToString();
                    fup.TB_NAME.Text          = DGV_PRODUCTS.CurrentRow.Cells[1].Value.ToString();
                    fup.TB_QUANTITY.Text      = DGV_PRODUCTS.CurrentRow.Cells[2].Value.ToString();
                    fup.TB_PRICE.Text         = DGV_PRODUCTS.CurrentRow.Cells[3].Value.ToString();
                    fup.TB_DESCRIPTION.Text   = DGV_PRODUCTS.CurrentRow.Cells[5].Value.ToString();
                    fup.COMBO_CATEGORIES.Text = DGV_PRODUCTS.CurrentRow.Cells[6].Value.ToString();

                    byte[]       img = (byte[])DGV_PRODUCTS.CurrentRow.Cells[4].Value;
                    MemoryStream ms  = new MemoryStream(img);
                    fup.PB_BROWSE_IMAGE.Image = Image.FromStream(ms);
                    fup.ShowDialog();
                    DGV_PRODUCTS.DataSource = product.getProducts();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        private void BTN_PRODUCT_PRODUCT_Click(object sender, EventArgs e)
        {
            FORM_UPDATE_PRODUCT fup = new FORM_UPDATE_PRODUCT();

            fup.LBL_PID.Text          = DGV_PRODUCTS.CurrentRow.Cells[0].Value.ToString();
            fup.TB_NAME.Text          = DGV_PRODUCTS.CurrentRow.Cells[1].Value.ToString();
            fup.TB_QUANTITY.Text      = DGV_PRODUCTS.CurrentRow.Cells[2].Value.ToString();
            fup.TB_PRICE.Text         = DGV_PRODUCTS.CurrentRow.Cells[3].Value.ToString();
            fup.TB_DESCRIPTION.Text   = DGV_PRODUCTS.CurrentRow.Cells[4].Value.ToString();
            fup.COMBO_CATEGORIES.Text = DGV_PRODUCTS.CurrentRow.Cells[5].Value.ToString();
            fup.txtBarcode.Text       = DGV_PRODUCTS.CurrentRow.Cells[6].Value.ToString();
            fup.cmbUnit.Text          = DGV_PRODUCTS.CurrentRow.Cells[7].Value.ToString();
            fup.txtMinimum.Text       = DGV_PRODUCTS.CurrentRow.Cells[8].Value.ToString();
            fup.txtbrand.Text         = DGV_PRODUCTS.CurrentRow.Cells[9].Value.ToString();
            fup.txtWholesale.Text     = DGV_PRODUCTS.CurrentRow.Cells[10].Value.ToString();
            fup.txtPurchase.Text      = DGV_PRODUCTS.CurrentRow.Cells[11].Value.ToString();
            fup.txtlocations.Text     = DGV_PRODUCTS.CurrentRow.Cells[12].Value.ToString();



            if (fup.PB_BROWSE_IMAGE.Image == null)
            {
                fup.Show();
                //fup.ShowDialog();
                //this is used to avoid exception
            }
            else
            {
                byte[]       img = (byte[])DGV_PRODUCTS.CurrentRow.Cells[4].Value;
                MemoryStream ms  = new MemoryStream(img);
                fup.PB_BROWSE_IMAGE.Image = Image.FromStream(ms);
                // fup.ShowDialog();
                fup.Show();
                DGV_PRODUCTS.DataSource = product.getProducts();
            }
        }