private void dataGridView1_CellDoubleClick(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_Gems myFormg = new S_Gems(); myFormg.btnrefresh.Visible = false; myFormg.btnsave.Visible = false; myFormg.Stock_Type.Text = "Gems"; myFormg.txtstock_no.Text = this.dataGridView1.CurrentRow.Cells[0].Value.ToString(); myFormg.txtno_of_peices.Text = this.dataGridView1.CurrentRow.Cells[2].Value.ToString(); myFormg.txt_gems.Text = this.dataGridView1.CurrentRow.Cells[1].Value.ToString(); myFormg.txt_weight.Text = this.dataGridView1.CurrentRow.Cells[3].Value.ToString(); myFormg.cmbStockType.Enabled = false; myFormg.txtstock_no.Enabled = false; // Today 2 string currentImagePath = ""; using (var cmd = new SqlCommand("SELECT currentImagePath 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); currentImagePath = reader.GetString(0); } } } myFormg.txt_cost.Text = this.dataGridView1.CurrentRow.Cells[4].Value.ToString(); myFormg.stockId = stockId; myFormg.ShowDialog(); }
private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { S_Gems myFormg = new S_Gems(); myFormg.btnrefresh.Visible = false; myFormg.btnsave.Visible = false; myFormg.Stock_Type.Text = "Gems"; myFormg.txtstock_no.Text = this.dataGridView1.CurrentRow.Cells[0].Value.ToString(); myFormg.txtno_of_peices.Text = this.dataGridView1.CurrentRow.Cells[2].Value.ToString(); myFormg.txt_gems.Text = this.dataGridView1.CurrentRow.Cells[1].Value.ToString(); myFormg.txt_weight.Text = this.dataGridView1.CurrentRow.Cells[3].Value.ToString(); //myFormg.pb1.Image = this.dataGridView1.CurrentRow.Cells[5].Value; //byte[] pic = this.dataGridView1.CurrentRow.Cells[12].Value as byte[]; //if (pic != null) //{ // MemoryStream stream = new MemoryStream(pic); // myFormg.pb1.Image = Image.FromStream(stream); //} //else // myFormg.pb1.Image = null; myFormg.txt_cost.Text = this.dataGridView1.CurrentRow.Cells[4].Value.ToString(); /* String path = (TB_File_Path.Text + txtstock_no.Text + "\\" + pictureBox1.Image);*/ /* string imgdir = this.dataGridView1.CurrentRow.Cells[17].Value.ToString(); * * * Image image = Image.FromFile(imgdir + ".JPG"); * this.pictureBox1.Image = image;*/ /* string imgdir = this.dataGridView1.CurrentRow.Cells[17].Value.ToString(); * * string[] files = Directory.GetFiles(imgdir); * * foreach (string f in files) * { * //MemoryStream mstream = new MemoryStream(f); * MessageBox.Show(f); * //myFormg.pb1.Image = Image.FromFile(f); * * // mstream.Dispose(); * } */ /* byte[] pic = this.dataGridView1.CurrentRow.Cells[18].Value as byte[]; * if (pic != null) * { * MemoryStream stream = new MemoryStream(pic); * myFormg.pb1.Image = Image.FromStream(stream); * } * else * myFormg.pb1.Image = null;*/ // myForm.hello.Text = this.dataGridView1.CurrentRow.Cells[10].Value.ToString(); myFormg.ShowDialog(); }
private void dataGridView1_CellDoubleClick(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_Gems myFormg = new S_Gems(); myFormg.btnrefresh.Visible = false; myFormg.btnsave.Visible = false; myFormg.Stock_Type.Text = "Gems"; myFormg.txtstock_no.Text = this.dataGridView1.CurrentRow.Cells[0].Value.ToString(); myFormg.txtno_of_peices.Text = this.dataGridView1.CurrentRow.Cells[2].Value.ToString(); myFormg.txt_gems.Text = this.dataGridView1.CurrentRow.Cells[1].Value.ToString(); myFormg.txt_weight.Text = this.dataGridView1.CurrentRow.Cells[3].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.txt_cost.Text = this.dataGridView1.CurrentRow.Cells[4].Value.ToString(); myFormg.ShowDialog(); // myFormg.pb1.Image = this.dataGridView1.CurrentRow.Cells[5].Value; //MemoryStream ms = new MemoryStream(reader["Image"] as byte[]); //row.Cells[5].Value = Image.FromStream(ms); //myFormg.txt_cost.Text = this.dataGridView1.CurrentRow.Cells[13].Value.ToString(); //myFormg.TB_File_Path.Text = this.dataGridView1.CurrentRow.Cells[18].Value.ToString(); /* String path = (TB_File_Path.Text + txtstock_no.Text + "\\" + pictureBox1.Image);*/ /* string imgdir = this.dataGridView1.CurrentRow.Cells[17].Value.ToString(); * * Image image = Image.FromFile(imgdir + ".JPG"); * this.pictureBox1.Image = image;*/ /* string imgdir = this.dataGridView1.CurrentRow.Cells[17].Value.ToString(); * * string[] files = Directory.GetFiles(imgdir); * * foreach (string f in files) * { * //MemoryStream mstream = new MemoryStream(f); * MessageBox.Show(f); * //myFormg.pb1.Image = Image.FromFile(f); * * // mstream.Dispose(); * } */ /* byte[] pic = this.dataGridView1.CurrentRow.Cells[18].Value as byte[]; * if (pic != null) * { * MemoryStream stream = new MemoryStream(pic); * myFormg.pb1.Image = Image.FromStream(stream); * } * else * myFormg.pb1.Image = null;*/ // myForm.hello.Text = this.dataGridView1.CurrentRow.Cells[10].Value.ToString(); }