public bool DeleteAccount(Account account)
 {
     return dbm.DeleteAccount(account);
 }
 // Properties
 // Methods
 /// <summary>
 /// Adds an account to the DB
 /// </summary>
 /// <param name="account">account to add</param>
 /// <returns>true if success</returns>
 public bool AddAccount(Account account)
 {
     return dbm.AddAccount(account);
 }
        /// <summary>
        /// Deletes a user from the database
        /// </summary>
        /// <param name="usertodelete"></param>
        /// <returns></returns>
        public bool DeleteAccount(Account accounttodelete)
        {
            try
            {
                User foo;
                if (accounttodelete is User)
                {
                    foo = accounttodelete as User;
                    Connect();

                    cmd = new OracleCommand();
                    cmd.Connection = con;
                    cmd.CommandType = CommandType.Text;
                    cmd.CommandText = "UPDATE TGEBRUIKER SET UITSCHRIJVINGSDATUM = :newUnsubscribedDate where id= :newUserID";
                    cmd.Parameters.Add("newUnsubscribedDate", DateTime.Now);
                    cmd.Parameters.Add("newUserID", foo.UserID);
                    cmd.ExecuteNonQuery();

                    if (foo is Client)
                    {
                        cmd = new OracleCommand();
                        cmd.Connection = con;
                        cmd.CommandType = CommandType.Text;
                        cmd.CommandText = "DELETE FROM THULPBEHOEVENDE WHERE GEBRUIKERID = :gebruikerid";
                        cmd.Parameters.Add("gebruikerid", foo.UserID);
                        cmd.ExecuteNonQuery();
                        return true;
                    }

                    if (foo is Volunteer)
                    {
                        cmd = new OracleCommand();
                        cmd.Connection = con;
                        cmd.CommandType = CommandType.Text;
                        cmd.CommandText = "DELETE FROM TVRIJWILLIGER WHERE GEBRUIKERID = :gebruikerid";
                        cmd.Parameters.Add("gebruikerid", foo.UserID);
                        cmd.ExecuteNonQuery();
                        return true;
                    }
                }
                return false;
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
                return false;
            }
            finally
            {
                Disconnect();
            }
        }
 /// <summary>
 /// Add a account, not compatible with admins
 /// </summary>
 /// <param name="newaccount">account to add</param>
 /// <returns></returns>
 public bool AddAccount(Account newaccount)
 {
     return accm.AddAccount(newaccount);
 }
        /// <summary>
        /// Adds a new account to the database.
        /// Adding of admins is not support this way.
        /// Email for account has to be unique
        /// </summary>
        /// <param name="newaccount">Account to be added</param>
        /// <returns>true if success, otherwise false</returns>
        public bool AddAccount(Account newaccount)
        {
            try
            {
                Connect();
                using (cmd = new OracleCommand())
                {
                    cmd.Connection = con;
                    cmd.CommandType = CommandType.Text;
                    cmd.CommandText = "SELECT EMAIL FROM TACCOUNT WHERE LOWER(EMAIL) = LOWER(:newEmail)";
                    cmd.Parameters.Add("newEmail", newaccount.Email);
                    dr = cmd.ExecuteReader();
                    if (dr.HasRows)
                    {
                        return false;
                    }
                }
                // Account
                using (cmd = new OracleCommand())
                {
                    cmd.Connection = con;
                    cmd.CommandType = CommandType.Text;
                    cmd.CommandText = "INSERT INTO TACCOUNT(EMAIL, WACHTWOORD, GEBRUIKERSNAAM) VALUES(lower(:newEmail), :newPassword, :newUserName)";
                    cmd.Parameters.Add("newEmail", newaccount.Email);
                    cmd.Parameters.Add("newPassword", newaccount.Password);
                    cmd.Parameters.Add("newUserName", newaccount.Username);
                    cmd.ExecuteNonQuery();
                }

                // User
                if (newaccount is User)
                {
                    User newuser = newaccount as User;
                    int accountid = -1;
                    using (cmd = new OracleCommand())
                    {
                        cmd.Connection = con;
                        cmd.CommandType = CommandType.Text;
                        cmd.CommandText = "SELECT ID FROM TACCOUNT WHERE LOWER(EMAIL) = LOWER(:newEmail)";
                        cmd.Parameters.Add("newEmail", newuser.Email);
                        dr = cmd.ExecuteReader();

                        while (dr.Read())
                        {
                            accountid = SafeReadInt(dr, 0);
                        }
                    }
                    if (accountid != -1)
                    {
                        using (cmd = new OracleCommand())
                        {
                            cmd.Connection = con;
                            cmd.CommandType = CommandType.Text;
                            cmd.CommandText = "INSERT INTO TGEBRUIKER(NAAM,ADRES,WOONPLAATS,TELEFOONNUMMER,HEEFTRIJBEWIJS,HEEFTAUTO,UITSCHRIJVINGSDATUM,ACCOUNTID) VALUES (:newName, :newAdress, :newLocation, :newPhoneNr, :newLicense, :newCar,NULL,:newAccountID)";
                            cmd.Parameters.Add("newName", newuser.Name);
                            cmd.Parameters.Add("newAdress", newuser.Adress);
                            cmd.Parameters.Add("newLocation", newuser.Location);
                            cmd.Parameters.Add("newPhoneNr", newuser.Phonenumber);
                            cmd.Parameters.Add("newLicense", newuser.License);
                            cmd.Parameters.Add("newCar", newuser.Hascar);
                            cmd.Parameters.Add("newAccountID", accountid);
                            cmd.ExecuteNonQuery();
                        }

                        // Fetch UserID
                        int userid = -1;
                        using (cmd = new OracleCommand())
                        {
                            cmd.Connection = con;
                            cmd.CommandType = CommandType.Text;
                            cmd.CommandText = "SELECT ID FROM TGEBRUIKER WHERE NAAM = :Name AND ADRES = :Adress AND WOONPLAATS = :Location AND TELEFOONNUMMER = :Phonenumber AND ROWNUM = 1";
                            cmd.Parameters.Add("Name", newuser.Name);
                            cmd.Parameters.Add("Adress", newuser.Adress);
                            cmd.Parameters.Add("Location", newuser.Location);
                            cmd.Parameters.Add("Phonenumber", newuser.Phonenumber);
                            dr = cmd.ExecuteReader();

                            while (dr.Read())
                            {
                                userid = SafeReadInt(dr, 0);
                            }
                        }
                        if (userid != -1)
                        {

                            // Client
                            if (newuser is Client)
                            {
                                Client newclient = newuser as Client;
                                using (cmd = new OracleCommand())
                                {
                                    cmd.Connection = con;
                                    cmd.CommandType = CommandType.Text;
                                    cmd.CommandText = "INSERT INTO THULPBEHOEVENDE(OVMOGELIJK,GEBRUIKERID) VALUES (:newOvPossible,:newUserID)";
                                    cmd.Parameters.Add("newOvPossible", newclient.OVpossible);
                                    cmd.Parameters.Add("newUserID", userid);
                                    cmd.ExecuteNonQuery();

                                    return true;
                                }
                            }
                            // Volunteer
                            if (newuser is Volunteer)
                            {
                                Volunteer newvoluntuur = newuser as Volunteer;
                                using (cmd = new OracleCommand())
                                {
                                    cmd.Connection = con;
                                    cmd.CommandType = CommandType.Text;
                                    cmd.CommandText = "INSERT INTO TVRIJWILLIGER(GEBOORTEDATUM, FOTO, VOG, GEBRUIKERID) VALUES(:newDoB, :newPhoto, :newVOG, :newUserID)";
                                    cmd.Parameters.Add("newDoB", newvoluntuur.DateOfBirth);
                                    cmd.Parameters.Add("newPhoto", newvoluntuur.Photo);
                                    cmd.Parameters.Add("newVOG", newvoluntuur.VOG);
                                    cmd.Parameters.Add("newUserID", userid);
                                    cmd.ExecuteNonQuery();
                                    return true;
                                }
                            }
                            return false;
                        }
                        return false;
                    }
                    return false;
                }
                return false;
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
                return false;
            }
            finally
            {
                Disconnect();
            }
        }