示例#1
0
        private void btnPTimKiem_Click(object sender, EventArgs e)
        {
            dgvPhong.Rows.Clear();
            string sophong   = cbPSoPhong.Text;
            string succhua   = cbPSucChua.Text;
            string ssvht     = txtPSSVHT.Text;
            string mady      = cbPMaDay.Text;
            string trangthai = cbPTrangThai.Text;
            string tennv     = cbPNhanVienQuanLy.Text;
            string loaiphong = cbPLoaiPhong.Text;
            string masv      = cbPMaSV.Text;

            if (masv == "")
            {
                dtPhong = PBLL.TKPhongAll(sophong, succhua, ssvht, mady, trangthai, tennv, loaiphong);
            }
            else
            {
                dtPhong = PBLL.TKPhongSV(sophong, succhua, ssvht, mady, trangthai, tennv, loaiphong, masv);
            }

            if (dtPhong.Rows.Count > 0)
            {
                dgvPhong.Rows.Clear();
                for (int i = 0; i < dtPhong.Rows.Count; i++)
                {
                    string[] a = { dtPhong.Rows[i][0].ToString(), dtPhong.Rows[i][1].ToString(), dtPhong.Rows[i][2].ToString(), dtPhong.Rows[i][3].ToString(), dtPhong.Rows[i][4].ToString() };
                    dgvPhong.Rows.Add(a);
                }
            }
            else
            {
                MessageBox.Show("Không tìm thấy phòng phù hợp!", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
        }