/// <summary>
        /// Reserves a rail for a tram.
        /// </summary>
        /// <param name="sender">Contains a reference to the pressed button.</param>
        /// <param name="e">contains nothing useful</param>
        private void BtnOk_Click(object sender, EventArgs e)
        {
            if (this.rtbxTram.Text.Trim().Length > 0)
            {
                string tramNumber = this.rtbxTram.Text.Trim();
                Tram tram = this.tramDepotManagementSystem.GetTram(tramNumber);

                Reservation reservation = new Reservation(tram, this.rail);

                try
                {
                    this.tramDepotManagementSystem.AddReservation(reservation);
                    this.DialogResult = DialogResult.OK;
                    this.Close();
                }
                catch (Exception ex)
                {
                    this.ShowErrorMessage("The reservation could not be added:" + System.Environment.NewLine + ex.Message);
                }
            }
        }
        /// <summary>
        /// Removes a reservation
        /// </summary>
        /// <param name="reservation">The reservation which is tot be removed.</param>
        public void RemoveReservation(Reservation reservation)
        {
            DatabaseManager.RemoveReservation(reservation);

            this.Reservations.Remove(reservation);
        }
        /// <summary>
        /// Adds a reservation. If the reservation already exists, the reservation will not be added and this method will return false.
        /// </summary>
        /// <param name="reservation">The reservation that is to be added.</param>
        /// <returns>A boolean indicating if the reservation already existed.</returns>
        public bool AddReservation(Reservation reservation)
        {
            if (!this.Reservations.Exists(r => r == reservation))
            {
                DatabaseManager.AddReservation(reservation);

                this.Reservations.Add(reservation);
                return true;
            }

            return false;
        }
        /// <summary>
        /// Adds the reservation for the tram and the rail to the database, which are both supplied in the given Reservation.
        /// At least one sector of the rail will be kept free for the tram the reservation is made for.
        /// </summary>
        /// <param name="reservation">The reservation containing the details of the tram and rail the reservation is made for.</param>
        /// <param name="closeConnection">If true, closes the database connection at the end of this method.</param>
        /// <returns>Succession of the insert. False when the row wasn't inserted, due to the reservation already existing, the tram not existing or the rail not existing.</returns>
        public static bool AddReservation(Reservation reservation, bool closeConnection = true)
        {
            try
            {
                OracleCommand command = CreateOracleCommand("INSERT INTO RESERVERING(SPOOR_ID, WAGEN_ID) VALUES(:RailID, :TramID)");

                command.Parameters.Add(":RailID", reservation.Rail.ID);
                command.Parameters.Add(":TramID", reservation.Tram.ID);

                return ExecuteNonQuery(command);
            }
            finally
            {
                if (closeConnection)
                {
                    connection.Close();
                }
            }
        }
        /// <summary>
        /// Removes the given reservation from the database.
        /// </summary>
        /// <param name="reservation">The reservation to remove.</param>
        /// <param name="closeConnection">If true, closes the database connection at the end of this method.</param>
        /// <returns>Value indicating whether the removal succeeded or not.</returns>
        public static bool RemoveReservation(Reservation reservation, bool closeConnection = true)
        {
            try
            {
                OracleCommand command = CreateOracleCommand("DELETE FROM RESERVERING WHERE SPOOR_ID = :RailID AND WAGEN_ID = :TramID");

                command.Parameters.Add(":RailID", reservation.Rail.ID);
                command.Parameters.Add(":TramID", reservation.Tram.ID);

                return ExecuteNonQuery(command);
            }
            finally
            {
                if (closeConnection)
                {
                    connection.Close();
                }
            }
        }