Ejemplo n.º 1
0
        private void btnSearch_Click(object sender, EventArgs e)
        {
            string key = this.txtSearch.Text;

            if (key == "".Trim())
            {
                MessageBox.Show("Please enter keyword!", "Notice");
                return;
            }
            string catalog = "";

            //MessageBox.Show(this.cboSearch.SelectedItem.ToString());
            if (this.cboTimtheo.SelectedItem.ToString() == "Reader Name")
            {
                catalog += "docgia.tendocgia";
                //MessageBox.Show(catalog);
            }
            else if (this.cboTimtheo.SelectedItem.ToString() == "Reader Id")
            {
                catalog += "docgia.madocgia";
                //MessageBox.Show(catalog);
            }
            else if (this.cboTimtheo.SelectedItem.ToString() == "Phone Number")
            {
                catalog += "docgia.sdtdocgia";
                //MessageBox.Show(catalog);
            }
            else if (this.cboTimtheo.SelectedItem.ToString() == "E-mail")
            {
                catalog += "docgia.emaildocgia";
                //MessageBox.Show(catalog);
            }
            ReaderBLL        readerBLL = new ReaderBLL();
            List <ReaderBLL> readerArr = new List <ReaderBLL>();

            readerArr = ReaderDAL.search(key, catalog);
            this.dgvReader.Rows.Clear();
            if (readerArr != null)
            {
                //MessageBox.Show("ok");
                foreach (ReaderBLL row in readerArr)
                {
                    this.dgvReader.Rows.Add(row.Code, row.Name, row.Address, row.Phone, row.Email, row.Allocateddate.ToShortDateString(), row.Enddate.ToShortDateString(), row.Birthday.ToShortDateString(), row.IsStaff, row.Granduation);
                }
            }
            else
            {
                MessageBox.Show("Sorry! Can't find this reader");
                return;
            }
            this.dgvReader.SelectionChanged += new EventHandler(dgvReader_SelectionChanged);
            this.GetSelectedValue();
        }