Exemple #1
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);
        }
Exemple #2
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");
            }
        }
Exemple #3
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);
        }
Exemple #4
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);
        }