private void btnTimKiemHangHoa_Click(object sender, EventArgs e)
        {
            HangHoaDTO hhTam = new HangHoaDTO();
            string     tenHH = txtTimKiemHangHoa.Text;

            hhTam = hangBUS.TimKiemHH(tenHH);

            if (hhTam != null)
            {
                foreach (DataGridViewRow row in dtgvHangHoa.Rows)
                {
                    if (Convert.ToInt32(row.Cells["colMaHH"].Value.ToString()) == hhTam.Mahh)
                    {
                        row.Selected            = true;
                        dtgvHangHoa.CurrentCell = dtgvHangHoa.Rows[row.Index].Cells[0];
                        txtTenHangHoa.Text      = hhTam.Tenhh;
                        txtDonViTinh.Text       = hhTam.Dvt;
                        txtSoLuongTon.Text      = hhTam.Slton.ToString();
                    }
                }
            }
            else
            {
                MessageBox.Show("Không tìm thấy!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Ejemplo n.º 2
0
 private void btnTimKiem_Click(object sender, EventArgs e)
 {
     if (cmbTimKiem.Text == "Theo Mã Hàng Hóa")
     {
         dgvHH.DataSource = bus.TimKiemHH("select * from HangHoa where MaHH like '%" + txtTimKiem.Text + "%'");
     }
     if (cmbTimKiem.Text == "Theo Tên Hàng Hóa")
     {
         dgvHH.DataSource = bus.TimKiemHH("select * from HangHoa where TenHH like '%" + txtTimKiem.Text + "%'");
     }
     if (cmbTimKiem.Text == "Theo Giá")
     {
         dgvHH.DataSource = bus.TimKiemHH("select * from HangHoa where Gia like '%" + txtTimKiem.Text + "%'");
     }
     if (cmbTimKiem.Text == "Theo Mã Loại Hàng Hóa")
     {
         dgvHH.DataSource = bus.TimKiemHH("select * from HangHoa where MaLHH like '%" + txtTimKiem.Text + "%'");
     }
     if (cmbTimKiem.Text == "Theo Ghi Chú")
     {
         dgvHH.DataSource = bus.TimKiemHH("select * from HangHoa where GhiChu like '%" + txtTimKiem.Text + "%'");
     }
     if (cmbTimKiem.Text == "Theo Ngày Sản Xuất")
     {
         dgvHH.DataSource = bus.TimKiemHH("select * from HangHoa where NSX like '%" + txtTimKiem.Text + "%'");
     }
     if (cmbTimKiem.Text == "Theo Hạn Sử Dụng")
     {
         dgvHH.DataSource = bus.TimKiemHH("select * from HangHoa where HSD like '%" + txtTimKiem.Text + "%'");
     }
 }