public FRM_Products() { InitializeComponent(); //TO control from FRM add product if (frm == null) { frm = this; } this.DGV_Data.DataSource = cl.GET_ALL_PRODUCTS(); }
private void btn_ADD_Click(object sender, EventArgs e) { try { if (FRMstate == "add") { //this to convert image to byte data 01010101010101 MemoryStream ms = new MemoryStream(); PICBOX.Image.Save(ms, PICBOX.Image.RawFormat); byte[] byteImage = ms.ToArray(); PL.ADD_PRODUCT(Convert.ToInt32(CMD_CATEGERORIES.SelectedValue), txt_ID.Text, Convert.ToInt32(txt_QUT.Text), txt_Description.Text, Convert.ToInt32(txt_PRICE.Text), byteImage); MessageBox.Show("تمت الاضافه بنجاح", "عمليه الاضافه", MessageBoxButtons.OK, MessageBoxIcon.Information); this.dataGridView1.DataSource = PL.GET_ALL_PRODUCTS(); } else { MemoryStream ms = new MemoryStream(); PICBOX.Image.Save(ms, PICBOX.Image.RawFormat); byte[] byteImage = ms.ToArray(); PL.UPDATE_PRODUCT(Convert.ToInt32(CMD_CATEGERORIES.SelectedValue), txt_ID.Text, Convert.ToInt32(txt_QUT.Text), txt_Description.Text, Convert.ToInt32(txt_PRICE.Text), byteImage); MessageBox.Show("تمت التحديث بنجاح", "عمليه التعديل", MessageBoxButtons.OK, MessageBoxIcon.Information); this.dataGridView1.DataSource = PL.GET_ALL_PRODUCTS(); FRM_Products frm = new FRM_Products(); this.Close(); } // to updae data in data grid view FRM_Products.getMainForm.DGV_Data.DataSource = PL.GET_ALL_PRODUCTS(); } catch (Exception) { MessageBox.Show("يرجى الادخال بطريقه صحيحه", "عمليه الاضافه", MessageBoxButtons.OK, MessageBoxIcon.Warning); } txt_Description.Clear(); txt_PRICE.Clear(); txt_QUT.Clear(); txt_PRICE.Clear(); PICBOX.Image = null; }
static void frm_formClosed(object sender, FormClosedEventArgs e) { frm = null; }
private void ادارهالمنتوجاتToolStripMenuItem_Click(object sender, EventArgs e) { FRM_Products frm = new FRM_Products(); frm.ShowDialog(); }