Beispiel #1
0
 /// <summary>
 /// Loads all events and puts them in the combobox cbSelectEvents.
 /// </summary>
 private void LoadEvents()
 {
     cbSelectEvent.Items.Clear();
     foreach (Event E in CurrentAccount.GetEvents())
     {
         cbSelectEvent.Items.Add(E);
     }
 }
Beispiel #2
0
        private void btnLogOut_Click(object sender, EventArgs e)
        {
            CurrentAccount.RemovePropertys();
            FormLogin Form = new FormLogin();

            this.Hide();
            Form.ShowDialog();
            this.Close();
        }
Beispiel #3
0
        /// <summary>
        /// Gets a single Account
        /// </summary>
        /// <param name = "AccountFuntion" > The AccountFunction Function</param>
        /// <returns>A list of accounts</returns>
        public static List <Account> GetAccountsFunction(Function AccountFuntion)
        {
            List <Account> AccountList = new List <Account>();

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

                    cmd.CommandText = "SELECT * FROM Account WHERE Functie = @Functie";

                    cmd.Parameters.Add(new SqlParameter("Functie", AccountFuntion.ToString()));
                    SqlDataReader reader = cmd.ExecuteReader();

                    while (reader.Read())
                    {
                        int    ID       = Convert.ToInt32(reader["ID"]);
                        string Username = (reader["Gebruikersnaam"].ToString());
                        string Password = (reader["Wachtwoord"].ToString());
                        string Function = (reader["Functie"].ToString());
                        string Name     = (reader["Naam"].ToString());
                        int?   EventID  = (reader["EventID"] != DBNull.Value) ? Convert.ToInt32(reader["EventID"]) : 0;
                        if (EventID == 0)
                        {
                            EventID = null;
                        }

                        Account Account = new Account(ID, Name, Username, Password, CurrentAccount.TranslateFunction(Function), EventID);
                        AccountList.Add(Account);
                    }
                    return(AccountList);
                }
                catch (SqlException e)
                {
                    Console.WriteLine("Query Failed: " + e.StackTrace + e.Message.ToString());
                }
                finally
                {
                    DatabaseConnectie.CloseConnection();
                }
            }
            return(AccountList);
        }
Beispiel #4
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            string Username = tbUsername.Text;
            string Password = tbPassword.Text;

            if (CurrentAccount.Login(Password, Username))
            {
                HomeForm window = new HomeForm();
                this.Hide();
                window.ShowDialog();
                this.Close();
            }
            else
            {
                lblInlogstatus.Text = "Het inloggen is mislukt probeer het opnieuw";
            }
        }
Beispiel #5
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            Function function;

            if (CurrentAccount.Function == Function.Accountbeheerder)
            {
                function = CurrentAccount.TranslateFunction(cbFunction.Text);
            }
            else
            {
                function = Function.Bezoeker;
            }
            if (tbName.Text != "" && tbUserName.Text != "" && tbNewPassword.Text != "" && tbRepeatPassword.Text != "" && tbRFIDTag.Text != "") // If RFID is filed in
            {
                if (tbNewPassword.Text == tbRepeatPassword.Text)                                                                               //If passwords are the same
                {
                    Account Account = new Account(tbName.Text, tbUserName.Text, tbNewPassword.Text, function);
                    bool    Check   = Account.CreateAccountWithRFID(Account, tbRFIDTag.Text);
                    CheckUserName(Check);
                }
                else
                {
                    MessageBox.Show("Wachtwoorden komen niet overeen");
                }
            }
            else if (tbName.Text != "" && tbUserName.Text != "" && tbNewPassword.Text != "" && tbRepeatPassword.Text != "") //change account and password
            {
                if (tbNewPassword.Text == tbRepeatPassword.Text)                                                            //If passwords are the same
                {
                    Account Account = new Account(tbName.Text, tbUserName.Text, tbNewPassword.Text, function);
                    bool    Check   = Account.CreateAccount(Account);
                    CheckUserName(Check);
                }
                else
                {
                    MessageBox.Show("Wachtwoorden komen niet overeen");
                }
            }
            else
            {
                MessageBox.Show("Niet alle gegevens zijn correct ingevuld");
            }
        }
Beispiel #6
0
        /// <summary>
        /// Get accounts that belong with a reservation
        /// </summary>
        ///  <param name="ReservationID">Reservation ID integer</param>
        /// <returns>A list of al accounts that are in a reservation</returns>
        public static List <Account> GetAccountsReservation(int ReservationID)
        {
            List <Account> AccountList = new List <Account>();

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

                    cmd.CommandText = "select * from Account_Reservering ar join Account a on ar.AccountID = a.ID where ar.ReserveringID = @ReservationID";
                    cmd.Parameters.Add(new SqlParameter("@ReservationID", ReservationID));

                    SqlDataReader reader = cmd.ExecuteReader();

                    while (reader.Read())
                    {
                        int    ID       = Convert.ToInt32(reader["ID"]);
                        string Username = (reader["Gebruikersnaam"].ToString());
                        string Password = (reader["Wachtwoord"].ToString());
                        string Function = (reader["Functie"].ToString());
                        string Name     = (reader["Naam"].ToString());

                        Account Account = new Account(ID, Name, Username, Password, CurrentAccount.TranslateFunction(Function));
                        AccountList.Add(Account);
                    }
                    return(AccountList);
                }
                catch (SqlException e)
                {
                    Console.WriteLine("Query Failed: " + e.StackTrace + e.Message.ToString());
                }
                finally
                {
                    DatabaseConnectie.CloseConnection();
                }
            }
            return(AccountList);
        }
Beispiel #7
0
        /// <summary>
        /// Returns the Account in a list with the RFID. (bestemd voor het uitchecken)
        /// </summary>
        /// <param name="RFID">RFID string.</param>
        ///  <param name="EventID">Gets account that has to be checked out</param>
        /// <returns></returns>
        public static Account GetAccountRFID_Checkuit(string RFID, int EventID)
        {
            Account account = null;

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

                    cmd.CommandText = "Select * from account a where a.RFID = @RFID and a.EventID = @EventID";
                    cmd.Parameters.Add(new SqlParameter("RFID", RFID));
                    cmd.Parameters.Add(new SqlParameter("EventID", EventID));

                    SqlDataReader reader = cmd.ExecuteReader();

                    while (reader.Read())
                    {
                        int    ID       = Convert.ToInt32(reader["ID"]);
                        string Username = (reader["Gebruikersnaam"].ToString());
                        string Password = (reader["Wachtwoord"].ToString());
                        string Function = (reader["Functie"].ToString());
                        string Name     = (reader["Naam"].ToString());

                        account = new Account(ID, Name, Username, Password, CurrentAccount.TranslateFunction(Function));
                    }
                    return(account);
                }
                catch (SqlException e)
                {
                    Console.WriteLine("Query Failed: " + e.StackTrace + e.Message.ToString());
                }
                finally
                {
                    DatabaseConnectie.CloseConnection();
                }
            }
            return(account);
        }
Beispiel #8
0
        /// <summary>
        /// Gets a list of all places that belong to a camping
        /// </summary>
        /// <param name="CampingID">EventID int?</param>
        /// <returns>Returns a list of places</returns>
        public static List <Place> GetPlacesCamping(int?CampingID)
        {
            List <Place> placeList = new List <Place>();

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

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

                    SqlDataReader reader = cmd.ExecuteReader();

                    while (reader.Read())
                    {
                        int    ID        = Convert.ToInt32(reader["ID"]);
                        string Terrain   = (reader["Terrein"].ToString());
                        int    Space     = Convert.ToInt32(reader["Oppervlakte"]);
                        string Categorie = (reader["Categorie"].ToString());

                        Place Place = new Place(ID, Terrain, Space, CurrentAccount.TranslateCategorie(Categorie));
                        placeList.Add(Place);
                    }
                    return(placeList);
                }
                catch (SqlException e)
                {
                    Console.WriteLine("Query Failed: " + e.StackTrace + e.Message.ToString());
                }
                finally
                {
                    DatabaseConnectie.CloseConnection();
                }
            }
            return(placeList);
        }