Exemplo n.º 1
0
        }     //End Search

        private void grdBookList_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            //Extract BookID from column 0 of selected row
            Books aBook = new Books();

            //Retrieve details from this member item from DB
            aBook.getBook(Convert.ToInt32(grdBookList.Rows[grdBookList.CurrentCell.RowIndex].Cells[0].Value));

            //Load instance variable values onto form
            txtBookID.Text  = aBook.getBookID().ToString("0000");
            txtISBN.Text    = aBook.getISBN();
            txtClassNo.Text = aBook.getClassNo();

            //Subject
            //Declare Variable to hold Subject Name
            strSubjectName          = Books.getSubjectName(aBook.getSubjectCode());
            cmbSubject.SelectedItem = strSubjectName;

            txtTitle.Text    = aBook.getTitle();
            txtAuthor.Text   = aBook.getAuthor();
            nudEdition.Value = aBook.getEdition();
            txtPrice.Text    = aBook.getPrice().ToString();
            txtPages.Text    = aBook.getPage().ToString();
            txtPName.Text    = aBook.getPubName();

            //Country
            //Declare Variable to hold Country Name
            strCountryName          = Books.getCountryName(aBook.getCountry());
            cmbCountry.SelectedItem = strCountryName;

            txtYearPub.Text = aBook.getYearPub();

            //Display Member details
            grpBookInfo.Visible = true;
        } //End Cell Click Event
Exemplo n.º 2
0
        } //End Search Method

        private void grdBookList_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            //Extract BookID from column 0 of selected row
            aBook = new Books();

            //Retrieve details from this member item from DB
            aBook.getBook(Convert.ToInt32(grdBookList.Rows[grdBookList.CurrentCell.RowIndex].Cells[0].Value));

            //Variables to Store Book ID, ISBN, and Book Title
            int    intBookID = aBook.getBookID();
            String strISBN   = aBook.getISBN();
            String strTitle  = aBook.getTitle();

            //Join All Variables
            String strValue = intBookID.ToString("0000") + " " + strISBN + " " + strTitle;

            //Add Details to List
            //Prevent Duplicates entries into ListBox
            if (lstCart.Items.Contains(strValue))
            {
                //Display error message to indicates that no duplicates allow
                String strErrorMessage = "'" + strTitle + "' has been added, no duplicates";
                MessageBox.Show(strErrorMessage, "Error Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            else
            {
                lstCart.Items.Add(strValue);
            }
        } //End Book List
Exemplo n.º 3
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
Exemplo n.º 4
0
        } //End Cell Click

        //Remove
        private void btnRemove_Click(object sender, EventArgs e)
        {
            //Dereg Book
            //Instance of Books
            Books aBook = new Books();

            //Retrieve details from this book item from DB
            aBook.getBook(Convert.ToInt32(grdBookList.Rows[grdBookList.CurrentCell.RowIndex].Cells[0].Value));

            aBook.rmvBook();

            //Display Confirmation Message
            MessageBox.Show("Book " + txtBookID.Text + " Removed", "Confirmation", MessageBoxButtons.OK, MessageBoxIcon.Information);

            //Reset UI
            grpBookInfo.Visible = false;
            grdBookList.Visible = false;
            txtSTitle.Text      = "";
            txtSTitle.Focus();
        } //End Remove
Exemplo n.º 5
0
        private void btnSearch_Click(object sender, EventArgs e)
        {
            //Get Search Book Title
            String strTitle = txtSTitle.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);
                txtSTitle.Focus();
            }
            else
            {
                DataSet ds = new DataSet();

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

                //Check if any data source return, if no data return display message
                if (grdBookList.DataSource == null || grdBookList.RowCount == 0)
                {
                    MessageBox.Show("No record found. It is either 'Unavailable' or 'No such record in DB'", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    txtSTitle.Text = "";
                    txtSTitle.Focus();
                }
                else
                {
                    //Set Visibility
                    grdBookList.Visible = true;

                    //Disable Sorting when clicking Column Header
                    foreach (DataGridViewColumn column in grdBookList.Columns)
                    {
                        column.SortMode = DataGridViewColumnSortMode.NotSortable;
                    }
                }
            } //End Validate Search Title
        }     //End Search
Exemplo n.º 6
0
        } //End Clear Button

        //Search Book Button Event
        private void btnSearchBook_Click(object sender, EventArgs e)
        {
            //Validate Title Search Box
            if (txtSTitle.Text == "")
            {
                MessageBox.Show("Book Title Search Field must not be empty!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtSTitle.Focus();
            }
            else
            {
                DataSet ds = new DataSet();

                //Load Data onto data grid
                grdBookList.DataSource = Books.getBook(ds, txtSTitle.Text).Tables["book"];

                //Check if any data source return, if no data return display message
                if (grdBookList.DataSource == null || grdBookList.RowCount == 0)
                {
                    MessageBox.Show("No details found, Either all books is on loan or invalid ISBN entered", "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    txtSTitle.Text = "";
                    txtSTitle.Focus();
                }
                else
                {
                    //Set Visibility of DataGridView BookList
                    grdBookList.Visible = true;

                    //Disable Sorting when clicking Column Header
                    foreach (DataGridViewColumn column in grdBookList.Columns)
                    {
                        column.SortMode = DataGridViewColumnSortMode.NotSortable;
                    }

                    //Calling SetVisibility Method
                    setVisibility();
                }
            }
        } //End Search Method