private void newStudentToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.Hide();
            var studentInsertForm = new StudentInsertForm();

            studentInsertForm.Show();
        }
        private void BookReservationButton_Click_1(object sender, EventArgs e)
        {
            if (StudentIdTextBox.Text == "")
            {
                label6.Show();
            }
            if (StudentIdTextBox.Text != "")
            {
                label6.Hide();
            }

            if (BookIdTextBox.Text == "")
            {
                label8.Show();
            }
            if (BookIdTextBox.Text != "")
            {
                label8.Hide();
            }

            if (DepartmentComboBox.Text == "")
            {
                label7.Show();
            }
            if (DepartmentComboBox.Text != "")
            {
                label7.Hide();
            }



            if (BorrowDatePicker.Text == "")
            {
                label9.Show();
            }
            if (BorrowDatePicker.Text != "")
            {
                label9.Hide();
            }

            if (ReturnDatePicker.Text == "")
            {
                label10.Show();
            }
            if (ReturnDatePicker.Text != "")
            {
                label10.Hide();
            }

            if (StudentIdTextBox.Text == "" || DepartmentComboBox.Text == "" || BookIdTextBox.Text == "")
            {
                return;
            }


            if (CheckIsStudentIsRegistered())
            {
                if (CheckIsIsbnExist())
                {
                    if (!CheckIsCurrentStudentHasAlreadyAnyResetvationOfBook())
                    {
                        if (IsCurrentBookAvailable())
                        {
                            int studentId;
                            int bookId;
                            int departmentId;
                            using (var connection =
                                       new SqlConnection(Connection)
                                   )
                            {
                                var sqlCommand1 =
                                    new SqlCommand(
                                        "select BookId from Book where Isbn=@Isbn ",
                                        connection);
                                sqlCommand1.Parameters.AddWithValue("@Isbn", BookIdTextBox.Text);

                                var sqlCommand2 =
                                    new SqlCommand(
                                        "select DepartmentId from Department where DepartmentShortName=@Department or DepartmentFullName=@Department ",
                                        connection);
                                sqlCommand2.Parameters.AddWithValue("@Department", DepartmentComboBox.Text);

                                var sqlCommand3 =
                                    new SqlCommand(
                                        "select Id from Student where StudentId=@IStudentId ",
                                        connection);
                                sqlCommand3.Parameters.AddWithValue("@IStudentId", StudentIdTextBox.Text);


                                connection.Open();
                                var reader1 = sqlCommand1.ExecuteReader();
                                reader1.Read();
                                bookId = reader1.GetInt32(0);
                                connection.Close();
                                connection.Open();
                                var reader2 = sqlCommand2.ExecuteReader();
                                reader2.Read();
                                departmentId = reader2.GetInt32(0);

                                connection.Close();
                                connection.Open();
                                var reader3 = sqlCommand3.ExecuteReader();
                                reader3.Read();
                                studentId = reader3.GetInt32(0);
                            }

                            using (var connection =
                                       new SqlConnection(Connection)
                                   )
                            {
                                var sqlCommand =
                                    new SqlCommand(
                                        "insert into Borrow(StudentId,DayOfBorrowed,DayOfReturn,BookId,DepartmentId) values(@StudentId,@BorrowDate,@ReturnDate,@BookId,@DepartmentId) ",
                                        connection);
                                sqlCommand.Parameters.AddWithValue("@StudentId", studentId);
                                sqlCommand.Parameters.AddWithValue("@BorrowDate",
                                                                   Convert.ToDateTime(BorrowDatePicker.Text));
                                sqlCommand.Parameters.AddWithValue("@ReturnDate", Convert.ToDateTime(ReturnDatePicker.Text));
                                sqlCommand.Parameters.AddWithValue("@BookId", bookId);
                                sqlCommand.Parameters.AddWithValue("@DepartmentId", departmentId);

                                connection.Open();
                                sqlCommand.ExecuteNonQuery();
                                MessageBox.Show(@"Book Reservation has been completed successfully.", "",
                                                MessageBoxButtons.OK,
                                                MessageBoxIcon.Information);
                            }
                        }
                        else
                        {
                            MessageBox.Show(@"Sorry, this book of ISBN  '" + BookIdTextBox.Text + @"' is not available now.", "", MessageBoxButtons.OK,
                                            MessageBoxIcon.Information);
                        }
                    }
                    else
                    {
                        MessageBox.Show(@"There is already a Reservation for this Student.This time no more reservation is allowed.", "", MessageBoxButtons.OK,
                                        MessageBoxIcon.Error);
                    }
                }
                else
                {
                    MessageBox.Show(@"Book's ISBN not found", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                var result = MessageBox.Show(@"It seems that Id " + StudentIdTextBox.Text + @" not registered yet. Would you like to registered it now?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                if (result == DialogResult.Yes)
                {
                    this.Hide();
                    var studentInsertForm = new StudentInsertForm(3);
                    studentInsertForm.Closed += (s, args) => this.Close();
                    studentInsertForm.Show();
                }
            }
        }