예제 #1
0
        //Unavailable Radio Button click

        /*****************************************************
         * Title: DataGridView Sorting and Filtering
         * Author: raps mk
         * Site owner/sponsor: net-informations.com
         * Date: 2016
         * Availability: http://csharp.net-informations.com/datagridview/csharp-datagridview-filter.htm (Accessed 06 APRIL 2017)
         * Modified: Identifiers rename
         * *****************************************************/
        private void radUnavailable_Click(object sender, EventArgs e)
        {
            //Variable to store OrderByValue by Calling getOrderByValue()
            String strOrderByValue = getOrderByValue();

            //Display DataView in grdBookList
            dv = new DataView(ds.Tables["book"], "Book_Status = 'U'", strOrderByValue, DataViewRowState.CurrentRows);
            grdBookList.DataSource = dv;

            //Check if any data source return, if no data return display message
            if (grdBookList.DataSource == null || grdBookList.RowCount == 0)
            {
                //Display Error Message
                MessageBox.Show("No details found", "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);

                //Reload Data onto grid view
                grdBookList.DataSource = Books.getAllBook(ds).Tables["book"];

                //Reset search box
                txtTitle.Text = "";
                txtTitle.Focus();
                radBookID.Checked = true;
                radAll.Checked    = true;
            }
            //End of [non-original or refactored] code
        }
예제 #2
0
        } //End Form Load

        //Search Button
        private void btnSearch_Click(object sender, EventArgs e)
        {
            //Get Search Book Title
            String strTitle = txtTitle.Text;

            //Validate Search Title if is empty
            if (strTitle.Equals(""))
            {
                //Display error message
                MessageBox.Show("Search field must not be empty", "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtTitle.Focus();
            }
            else
            {
                //Instantiate DataSet Object
                ds = new DataSet();

                //Declare Variable
                String strOrder = "";

                //Check if Radio Button is checked
                if (radBookID.Checked)
                {
                    strOrder = "BookID";
                }
                else if (radSubject.Checked)
                {
                    strOrder = "SubjectCode";
                }
                else if (radTitle.Checked)
                {
                    strOrder = "Title";
                }

                //Search Title and Load Data onto data grid
                grdBookList.DataSource = Books.getBook(ds, strTitle, strOrder).Tables["book"];

                //Check if any data source return, if no data return display message
                if (grdBookList.DataSource == null || grdBookList.RowCount == 0)
                {
                    //Display Error Message
                    MessageBox.Show("No details found", "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);

                    //Reload Data onto grid view
                    grdBookList.DataSource = Books.getAllBook(ds).Tables["book"];

                    //Reset search box
                    txtTitle.Text = "";
                    txtTitle.Focus();
                    radBookID.Checked = true;
                }
            } //End Validate Search Title
        }     //End Search
예제 #3
0
        }     //End Search

        //Reset UI
        private void btnClear_Click(object sender, EventArgs e)
        {
            //Reset UI
            txtTitle.Text = "";
            txtTitle.Focus();
            radBookID.Checked = true;
            radAll.Checked    = true;

            //Display all Books
            //Instantiate DataSet Object
            DataSet ds = new DataSet();

            //Load Data onto grid view
            grdBookList.DataSource = Books.getAllBook(ds).Tables["book"];
        } //End Clear Event
예제 #4
0
        //Form Load
        private void frmSearchBook_Load(object sender, EventArgs e)
        {
            //Instantiate DataSet Object
            ds = new DataSet();

            //Load Data onto grid view
            grdBookList.DataSource = Books.getAllBook(ds).Tables["book"];

            //Display Error Message if no details was found
            if (grdBookList.DataSource == null || grdBookList.RowCount == 0)
            {
                //Display error message
                MessageBox.Show("No details found", "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            //Calling method to set style of the BookList GridView
            setBookListStyle();
        } //End Form Load