private void btnAddPro_Click(object sender, EventArgs e) { AddProduct_Form ob = new AddProduct_Form(); ob.ShowDialog(); dataGridView1.DataSource = BL.Products.GetProduct(); }
private void btnModifyPro_Click(object sender, EventArgs e) { AddProduct_Form ob = new AddProduct_Form(); ob.txtProId.Text = dataGridView1.CurrentRow.Cells[0].Value.ToString(); ob.txtProName.Text = dataGridView1.CurrentRow.Cells[1].Value.ToString(); ob.txtProQty.Text = dataGridView1.CurrentRow.Cells[2].Value.ToString(); ob.txtProPrice.Text = dataGridView1.CurrentRow.Cells[3].Value.ToString(); // the value of the combobox doesn't change beacause it was overriten by the values that we give to it in the form load event in addproduct form // so we solve that issue by moving that values to the form constructor ob.comboBox1.Text = dataGridView1.SelectedRows[0].Cells[4].Value.ToString(); // to use the selectedRow property we should make the selectionMode = FullRowSelect byte[] img = (byte[])BL.Products.GetImage(ob.txtProId.Text).Rows[0][0]; MemoryStream ms = new MemoryStream(img); ob.pictureBox1.Image = Image.FromStream(ms); ob.Text = "Update Product (" + dataGridView1.CurrentRow.Cells[1].Value.ToString() + ")"; ob.btnAdd.Text = "Update"; ob.type = "update"; ob.lblModify.Text = "No Modify"; ob.ShowDialog(); dataGridView1.DataSource = BL.Products.GetProduct(); }
private void addProductToolStripMenuItem_Click(object sender, EventArgs e) { AddProduct_Form ob = new AddProduct_Form(); ob.ShowDialog(); }