private void dgvCTHD_CellClick(object sender, DataGridViewCellEventArgs e) { try { lblTenSP.Text = dgvCTHD.Rows[e.RowIndex].Cells[2].Value.ToString(); picSP.Image = null; picSP.Image = Image.FromFile(@"image/LapTop//" + sp.LayAnh(dgvCTHD.Rows[e.RowIndex].Cells[1].Value.ToString())); picSP.SizeMode = PictureBoxSizeMode.StretchImage; } catch { } }
public void Init() { if (dataGridView1.RowCount > 1) { try { txtMaSP.Text = dataGridView1.Rows[0].Cells[1].Value.ToString(); txtTenSP.Text = dataGridView1.Rows[0].Cells[2].Value.ToString(); txtLoiNhuan.Text = dataGridView1.Rows[0].Cells[4].Value.ToString(); txtGN.Text = dataGridView1.Rows[0].Cells[5].Value.ToString(); txtGB.Text = dataGridView1.Rows[0].Cells[6].Value.ToString(); txtMoTa.Text = dataGridView1.Rows[0].Cells[7].Value.ToString(); txtNSX.Text = dataGridView1.Rows[0].Cells[8].Value.ToString(); cboLH.Text = dataGridView1.Rows[0].Cells[9].Value.ToString(); tenAnh = sp.LayAnh(txtMaSP.Text); pictureBox1.Image = Image.FromFile(@"image//laptop//" + tenAnh); } catch { } } }
public void TimKiem(string DieuKien) { if (cboTK.SelectedIndex != 2) { dgvSP.DataSource = sp.ShowSanPham("AND " + DieuKien + " LIKE N'%" + txtTK.Text + "%'"); } else { dgvSP.DataSource = sp.ShowSanPham("AND " + DieuKien + " = " + txtTK.Text); } for (int i = 0; i < dgvSP.RowCount - 1; i++) { dgvSP.Rows[i].Cells[0].Value = (i + 1).ToString(); } pictureBox1.Image = Image.FromFile(@"image//laptop//" + sp.LayAnh(dgvSP.Rows[0].Cells[1].Value.ToString())); }