Exemple #1
0
        private void tsbSearch_Click(object sender, EventArgs e)
        {
            DataTable dt = new DataTable();

            if (txtCondition.Text == "")
            {
                this.showErrorMessage("ป้อนข้อมูลที่จะค้นหาก่อน");
                return;
            }
            BookType booktype  = new BookType();
            bool     isnumeric = int.TryParse(txtCondition.Text, out int BookTypeID);

            if (isnumeric)
            {
                booktype.BookTypeID = BookTypeID;
                dt = booktype.searchByID();
            }
            else // ไม่ใช่ตัวเลข
            {
                booktype.BookTypeName = txtCondition.Text;
                dt = booktype.searchByName();
            }
            dgvBookType.DataSource = dt;
        }