Ejemplo n.º 1
0
        /// <summary>
        /// Gets every event from the database
        /// </summary>
        /// <returns>A list with all event</returns>
        public static List <Event> GetEvents()
        {
            List <Event> EventList = new List <Event>();

            if (DatabaseConnectie.OpenConnection())
            {
                try
                {
                    DatabaseConnectie.OpenConnection();
                    SqlCommand cmd = new SqlCommand();
                    cmd.Connection = DatabaseConnectie.connect;

                    cmd.CommandText = "SELECT * FROM Event";
                    SqlDataReader reader = cmd.ExecuteReader();

                    while (reader.Read())
                    {
                        int      ID          = Convert.ToInt32(reader["ID"]);
                        string   Name        = (reader["Naam"].ToString());
                        DateTime Date        = Convert.ToDateTime(reader["Datum"]);
                        string   Discription = (reader["Beschrijving"].ToString());
                        string   Location    = (reader["Locatie"].ToString());
                        int      Maxvisitors = Convert.ToInt32(reader["Maxbezoekers"]);
                        int      CampingID   = (reader["CampingID"] != DBNull.Value) ? Convert.ToInt32(reader["CampingID"]) : 0;
                        int      AccountID   = Convert.ToInt32(reader["AccountID"]);

                        TimeLine Timeline = DatabaseGetTimeLine.GetTimeline(ID);

                        Account Account = DatabaseGetAccounts.GetSingleAccountID(AccountID);
                        Camping Camping;

                        if (CampingID != 0)
                        {
                            Camping = DatabaseGetCamping.GetSingleCamping(CampingID);
                        }
                        else
                        {
                            Camping = null;
                        }

                        Event Event = new Event(ID, Name, Discription, Location, Maxvisitors, Date, Account, Camping, Timeline);
                        EventList.Add(Event);
                    }
                    return(EventList);
                }
                catch (SqlException e)
                {
                    Console.WriteLine("Query Failed: " + e.StackTrace + e.Message.ToString());
                }
                finally
                {
                    DatabaseConnectie.CloseConnection();
                }
            }
            return(EventList);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Gets list of reservations that belongs to a specific event
        /// </summary>
        /// <param name="EventID">EventID integer</param>
        /// <returns>A list of reservations</returns>
        public static List <Reservation> GetReservation(int EventID)
        {
            List <Reservation> ReservationList = new List <Reservation>();
            Place Place;

            if (DatabaseConnectie.OpenConnection())
            {
                try
                {
                    DatabaseConnectie.OpenConnection();
                    SqlCommand cmd = new SqlCommand();
                    cmd.Connection = DatabaseConnectie.connect;

                    cmd.CommandText = "SELECT * FROM Reservering Where EventID = @EventID";
                    cmd.Parameters.Add(new SqlParameter("EventID", EventID));

                    SqlDataReader reader = cmd.ExecuteReader();

                    while (reader.Read())
                    {
                        int  ID      = Convert.ToInt32(reader["ID"]);
                        int  PlaceID = (reader["PlaatsID"] != DBNull.Value) ? Convert.ToInt32(reader["PlaatsID"]) : 0;
                        int  Amount  = Convert.ToInt32(reader["BetalingBedrag"]);
                        bool Status  = Convert.ToBoolean(reader["BetalingStatus"]);

                        List <Account> Accountlist = DatabaseGetAccounts.GetAccountsReservation(ID);
                        Event          newEvent    = DatabaseGetEvents.GetSingleEvent(EventID);

                        if (PlaceID == 0)
                        {
                            Place = null;
                        }
                        else
                        {
                            Place = DatabaseGetPlace.GetPlace(PlaceID);
                        }


                        Reservation Reservation = new Reservation(ID, newEvent, new Payment(Amount, Status), Place, Accountlist);
                        ReservationList.Add(Reservation);
                    }
                    return(ReservationList);
                }
                catch (SqlException e)
                {
                    Console.WriteLine("Query Failed: " + e.StackTrace + e.Message.ToString());
                }
                finally
                {
                    DatabaseConnectie.CloseConnection();
                }
            }
            return(ReservationList);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Checks if the new account is allowed in the database
        /// </summary>
        /// <returns>True if changes are allowed false if not</returns>
        public List <Account> GetAccountList()
        {
            List <Account> AccountList = DatabaseGetAccounts.GetAccounts();

            return(AccountList);
        }