private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { S_Jewelry myForm = new S_Jewelry(); myForm.btn_Refresh.Visible = false; myForm.btnsave.Visible = false; // myForm.txt_ID.Text = this.dataGridView1.CurrentRow.Cells[0].Value.ToString(); myForm.Stock_Type.Text = this.dataGridView1.CurrentRow.Cells[1].Value.ToString(); myForm.txtstock_no.Text = this.dataGridView1.CurrentRow.Cells[2].Value.ToString(); myForm.txt_qty.Text = this.dataGridView1.CurrentRow.Cells[3].Value.ToString(); myForm.txt_gem_type.Text = this.dataGridView1.CurrentRow.Cells[4].Value.ToString(); myForm.txt_gem_weight.Text = this.dataGridView1.CurrentRow.Cells[5].Value.ToString(); myForm.combo_itemk_description.Text = this.dataGridView1.CurrentRow.Cells[6].Value.ToString(); myForm.combo_item_type.Text = this.dataGridView1.CurrentRow.Cells[7].Value.ToString(); myForm.txt_no_of_gems.Text = this.dataGridView1.CurrentRow.Cells[8].Value.ToString(); myForm.txt_no_of_other_gems.Text = this.dataGridView1.CurrentRow.Cells[9].Value.ToString(); myForm.txt_other_gems.Text = this.dataGridView1.CurrentRow.Cells[10].Value.ToString(); myForm.txt_weight_of_other_gems.Text = this.dataGridView1.CurrentRow.Cells[11].Value.ToString(); byte[] pic = this.dataGridView1.CurrentRow.Cells[12].Value as byte[]; if (pic != null) { MemoryStream stream = new MemoryStream(pic); myForm.pb1.Image = Image.FromStream(stream); } else { myForm.pb1.Image = null; } // myForm.pb1.Text = this.dataGridView1.CurrentRow.Cells[8].Value.ToString(); myForm.txt_cost.Text = this.dataGridView1.CurrentRow.Cells[13].Value.ToString(); myForm.ShowDialog(); /*S_Gems myFormg = new S_Gems(); * myFormg.Stock_Type.Text = this.dataGridView1.CurrentRow.Cells[1].Value.ToString(); * myFormg.txtstock_no.Text = this.dataGridView1.CurrentRow.Cells[2].Value.ToString(); * myFormg.txtno_of_peices.Text = this.dataGridView1.CurrentRow.Cells[3].Value.ToString(); * myFormg.txt_gems.Text = this.dataGridView1.CurrentRow.Cells[4].Value.ToString(); * myFormg.txt_weight.Text = this.dataGridView1.CurrentRow.Cells[5].Value.ToString(); * * byte[] picg = this.dataGridView1.CurrentRow.Cells[12].Value as byte[]; * if (picg != null) * { * MemoryStream stream = new MemoryStream(picg); * myFormg.pb1.Image = Image.FromStream(stream); * } * else * myFormg.pb1.Image = null; * * myFormg.txt_cost.Text = this.dataGridView1.CurrentRow.Cells[13].Value.ToString(); * // myForm.hello.Text = this.dataGridView1.CurrentRow.Cells[10].Value.ToString(); * myFormg.Hide();*/ }
private void dataGridView1_CellContentDoubleClick(object sender, DataGridViewCellEventArgs e) { Match m = Regex.Match(dataGridView1.CurrentRow.Cells[0].Value.ToString(), "([A-Za-z]+)([0-9]+)"); if (m.Groups.Count != 3) { return; } string stockId = m.Groups[2].Value; string stockNo = m.Groups[1].Value; S_Jewelry myFormg = new S_Jewelry(); myFormg.radioButton1.Checked = false; myFormg.radioButton1.Enabled = false; myFormg.btn_Refresh.Visible = false; myFormg.btnsave.Visible = false; myFormg.Stock_Type.Text = "Jewellery"; myFormg.txtstock_no.Text = this.dataGridView1.CurrentRow.Cells[0].Value.ToString(); myFormg.txt_qty.Text = "1"; myFormg.combo_itemk_description.Text = this.dataGridView1.CurrentRow.Cells[2].Value.ToString(); myFormg.combo_item_type.Text = this.dataGridView1.CurrentRow.Cells[3].Value.ToString(); myFormg.txt_no_of_gems.Text = this.dataGridView1.CurrentRow.Cells[4].Value.ToString(); myFormg.txt_gem_type.Text = this.dataGridView1.CurrentRow.Cells[5].Value.ToString(); myFormg.txt_gem_weight.Text = this.dataGridView1.CurrentRow.Cells[6].Value.ToString(); myFormg.txt_cost.Text = this.dataGridView1.CurrentRow.Cells[7].Value.ToString(); myFormg.txt_no_of_other_gems.Text = this.dataGridView1.CurrentRow.Cells[13].Value.ToString(); myFormg.txt_other_gems.Text = this.dataGridView1.CurrentRow.Cells[14].Value.ToString(); myFormg.txt_weight_of_other_gems.Text = this.dataGridView1.CurrentRow.Cells[15].Value.ToString(); // myFormg.cmbStockType.Enabled = false; // myFormg.txtstock_no.Enabled = false; using (var cmd = new SqlCommand("SELECT Image FROM Stock_Entry WHERE Stock_ID=@Stock_ID AND Stock_No= @Stock_No", conn)) { cmd.Parameters.AddWithValue("Stock_ID", stockId); cmd.Parameters.AddWithValue("Stock_No", stockNo); using (var Reader = cmd.ExecuteReader()) { if (Reader.Read()) { MemoryStream ms = new MemoryStream(Reader["Image"] as byte[]); myFormg.pb1.Image = Image.FromStream(ms); } } } myFormg.ShowDialog(); }