private void button2_Click(object sender, EventArgs e) { listView1.Clear(); TaiLieuu tl = new TaiLieuu(); string matailieu = tl.laymatailieu(cbbtimkiemtheotheloai.Text); string conn = @"Data Source=LAPTOP-VA3QE2VM\SQLEXPRESS;Initial Catalog=LTWNC;Integrated Security=True"; SqlConnection con = new SqlConnection(conn); con.Open(); SqlDataAdapter adapter = new SqlDataAdapter(); adapter.SelectCommand = new SqlCommand("select * from QL_ChiTietTaiLieu where TenChiTiet LIKE N'%" + txttimkiem.Text + "%'", con); DataTable dt = new DataTable(); adapter.Fill(dt); //dataGridView1.DataSource = dt; int imageindex = 0; for (int i = 0; i < dt.Rows.Count; i++) { imageList1.Images.Add(byteArrayToImage((byte[])dt.Rows[i][8])); var viewitem = new ListViewItem(dt.Rows[i][12].ToString()); { }; viewitem.ImageIndex = imageindex; listView1.Items.Add(viewitem); imageindex++; } }
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { TaiLieuu tl = new TaiLieuu(); string matailieu = tl.laymatailieu(comboBox1.Text); // TODO: This line of code loads data into the 'DataSet1.QL_ChiTietTaiLieu' table. You can move, or remove it, as needed. this.QL_ChiTietTaiLieuTableAdapter.Fill(this.DataSet1.QL_ChiTietTaiLieu, matailieu); this.reportViewer1.RefreshReport(); this.reportViewer1.RefreshReport(); this.reportViewer1.RefreshReport(); }
void load() { TaiLieuu tl = new TaiLieuu(); string matailieu = tl.laymatailieu(comboBox1.Text); // TODO: This line of code loads data into the 'DataSet1.QL_ChiTietTaiLieu' table. You can move, or remove it, as needed. // this.QL_ChiTietTaiLieuTableAdapter.Fill(this.DataSet1.QL_ChiTietTaiLieu, matailieu); this.QL_ChiTietTaiLieuTableAdapter.FillBy(this.DataSet1.QL_ChiTietTaiLieu); this.reportViewer1.RefreshReport(); this.reportViewer1.RefreshReport(); this.reportViewer1.RefreshReport(); comboBox1.Enabled = false; }
private void btnloc_Click(object sender, EventArgs e) { if (rbtntheloai.Checked) { cbbtimkiemtheotheloai.Enabled = true; listView1.Clear(); TaiLieuu tl = new TaiLieuu(); string matailieu = tl.laymatailieu(cbbtimkiemtheotheloai.Text); string conn = @"Data Source=LAPTOP-VA3QE2VM\SQLEXPRESS;Initial Catalog=LTWNC;Integrated Security=True"; SqlConnection con = new SqlConnection(conn); con.Open(); SqlDataAdapter adapter = new SqlDataAdapter(); adapter.SelectCommand = new SqlCommand("select * from QL_ChiTietTaiLieu where MaTaiLieu = '" + matailieu + "' ", con); DataTable dt = new DataTable(); adapter.Fill(dt); //dataGridView1.DataSource = dt; int imageindex = 0; for (int i = 0; i < dt.Rows.Count; i++) { imageList1.Images.Add(byteArrayToImage((byte[])dt.Rows[i][8])); var viewitem = new ListViewItem(dt.Rows[i][12].ToString()); { }; viewitem.ImageIndex = imageindex; listView1.Items.Add(viewitem); imageindex++; } } else if (rbtntatca.Checked) { listView1.Clear(); loadListView(); } else { MessageBox.Show("Chưa có dữ liệu!"); } }