Example #1
0
        private void issueBookToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (this.ActiveMdiChild != null)
            {
                this.ActiveMdiChild.Close();
            }
            IssueForm frm = new IssueForm();

            frm.Show();
            frm.MdiParent = this;
        }
Example #2
0
        private void btnReserve_Click(object sender, EventArgs e)
        {
            try
            {
                if (ValidateInputs() == false)
                {
                    return;
                }
                Book ToReserveBook = new Book();
                ToReserveBook.BookID = int.Parse(txtBookID.Text);

                string ConditionQuery;

                ConditionQuery = "select noOfAvailableBooks from Book where bookID=(" + int.Parse(txtBookID.Text) + ")";



                SqlConnection conn = ConnectionManager.DBConnection();
                SqlDataReader rdr  = null;
                try
                {
                    conn.Open();
                    SqlCommand cmd = new SqlCommand(ConditionQuery, conn);
                    rdr = cmd.ExecuteReader();
                    while (rdr.Read())
                    {
                        ToReserveBook.AvailableBooks = int.Parse(rdr["noOfAvailableBooks"].ToString());

                        if (ToReserveBook.AvailableBooks <= 0)
                        {
                            ReserveBook ReserveBook = new ReserveBook();
                            ReserveBook.BookID      = int.Parse(txtBookID.Text);
                            ReserveBook.StudentID   = int.Parse(txtStudentID.Text);
                            ReserveBook.RSD         = DateTime.Parse(txtRSD.Text);
                            ReserveBook.LibrarianID = int.Parse(txtLibrarianID.Text);
                            ReserveBook.AddNewReserve();
                            MessageBox.Show(" Book Reservation Complete.", "Reserve");
                        }
                        else
                        {
                            DialogResult dialogResult = MessageBox.Show("Book Requested is available at moment." + Environment.NewLine + "Do you want Issue this book now?", "Hey The Book is Available.", MessageBoxButtons.YesNo);
                            if (dialogResult == DialogResult.Yes)
                            {
                                this.Hide();
                                IssueForm Procede = new IssueForm();
                                Procede.Show();
                            }
                            else if (dialogResult == DialogResult.No)
                            {
                                MessageBox.Show(" It's not allowed to reserve book , unless they are not Available.", "Sorry NOT ALLOWED");
                                txtBookID.Text      = "";
                                txtStudentID.Text   = "";
                                txtRSD.Text         = "";
                                txtLibrarianID.Text = "";
                                txtBookID.Focus();
                            }
                        }
                    }
                }
                catch
                {
                    MessageBox.Show("Please make sure the follow details are inserted in the right format as in this example:" + Environment.NewLine + "BookiD : 1" + Environment.NewLine + "Student ID : 1001" + Environment.NewLine + "Date of Reserve: MM-DD-YYYY" + Environment.NewLine + "LibrarianID : 2");
                }
            }
            catch
            {
                MessageBox.Show("Please make sure the follow details are inserted in the right format as in this example:" + Environment.NewLine + "BookiD : 1" + Environment.NewLine + "Student ID : 1001" + Environment.NewLine + "Date of Reserve: MM-DD-YYYY" + Environment.NewLine + "LibrarianID : 2");
            }
        }