예제 #1
0
        private void btnLamlai_Click(object sender, EventArgs e)
        {
            frmMain formMain = (frmMain)frmMain.ActiveForm;

            formMain.panelKetquaTimKiem.Controls.Clear();
        }
예제 #2
0
        private void BtnSearch_Click(object sender, EventArgs e)
        {
            DataTable dt = B_HangHoa.getDataForSearch();

            if (cbxFindChatLieu.SelectedIndex == -1 && cbxFindCongDung.SelectedIndex == -1 && cbxFindNhom.SelectedIndex == -1)
            {
                MessageBox.Show("Chưa Chọn Hạng Mục Tìm Kiếm", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                dgvResult.DataSource = dt;
            }
            else
            {
                IEnumerable <DataRow> rows =
                    dt.AsEnumerable().Where
                    (
                        r =>
                        (
                            cbxFindChatLieu.SelectedIndex == -1 ? true :
                            r.Field <string>("TenChatLieu").Contains(cbxFindChatLieu.SelectedValue.ToString())
                        )
                        &&
                        (
                            cbxFindNhom.SelectedIndex == -1 ? true :
                            r.Field <string>("TenNhom").Contains(cbxFindNhom.SelectedValue.ToString())
                        )
                        &&
                        (
                            cbxFindCongDung.SelectedIndex == -1 ? true :
                            r.Field <string>("TenCongDung").Contains(cbxFindCongDung.SelectedValue.ToString())
                        )
                    );

                /*try
                 * {
                 *  DataTable t = rows.CopyToDataTable();
                 *  dgvResult.DataSource = t;
                 *  dgvResult.Refresh();
                 * }
                 * catch
                 * {
                 * }*/
                if (rows.Any() == false)
                {
                    MessageBox.Show("Không Có Kết Quả Hợp Lệ", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    BtnLamlai_Click_1(sender, e);
                    dgvResult.DataSource = B_HangHoa.getDataForSearch();
                }
                else
                {
                    DataTable t = rows.CopyToDataTable();
                    dgvResult.DataSource = t;
                    dgvResult.Refresh();
                }
            }

            //Show ket qua
            frmMain formMain = (frmMain)frmMain.ActiveForm;

            formMain.panelKetquaTimKiem.Controls.Clear();
            this.gbxKetqua.Dock = DockStyle.Fill;
            formMain.panelKetquaTimKiem.Controls.Add(this.gbxKetqua);
        }