public static DataTableReader SelectUserByEmail(string email)
        {
            var attrValue = DB_IO.AttrValue();

            attrValue[UserEnt.email] = email;
            return(DB_IO.SelectReader(DB_IO.DB_Interface.pr_select_users, attrValue));
        }
        // ----------------------------------------------------------------------------------------------
        // LOANS ----------------------------------------------------------------------------------------
        // ----------------------------------------------------------------------------------------------

        public static DataTableReader SelectAccountLoans(int account_id)
        {
            var attrValue = DB_IO.AttrValue();

            attrValue[CategoryEnt.account_id] = account_id;
            return(DB_IO.SelectReader(DB_IO.DB_Interface.pr_select_loans, attrValue));
        }
// ----------------------------------------------------------------------------------------------
// USERS ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------

        public static bool ExistsUser(string email)
        {
            var attrValue = DB_IO.AttrValue();

            attrValue[DB_API.UserEnt.email] = email;
            return(DB_IO.Exists(DB_IO.DB_Interface.pr_exists_user, attrValue));
        }
        public static DataTableReader SelectUserMoneyAccounts(string email)
        {
            var attrValue = DB_IO.AttrValue();

            attrValue[MoneyAccountEnt.user_email] = email;
            return(DB_IO.SelectReader(DB_IO.DB_Interface.pr_select_user_money_accounts, attrValue));
        }
        public static void DeleteMoneyAccount(int account_id)
        {
            var attrValue = DB_IO.AttrValue();

            attrValue[MoneyAccountEnt.account_id] = account_id;
            DB_IO.Delete(DB_IO.DB_Interface.pr_delete_money_account, attrValue);
        }
        public static DataTableReader SelectMoneyAccountUsers(int account_id)
        {
            var attrValue = DB_IO.AttrValue();

            attrValue[MoneyAccountEnt.account_id] = account_id;
            return(DB_IO.SelectReader(DB_IO.DB_Interface.pr_select_user_money_accounts, attrValue));
        }
        // ----------------------------------------------------------------------------------------------
        // MONEY ACCOUNTS -------------------------------------------------------------------------------
        // ----------------------------------------------------------------------------------------------

        public static bool ExistsMoneyAccount(int account_id)
        {
            var attrValue = DB_IO.AttrValue();

            attrValue[DB_API.MoneyAccountEnt.account_id] = account_id;
            return(DB_IO.Exists(DB_IO.DB_Interface.pr_exists_money_account, attrValue));
        }
        public static string SelectCategoryTypeDesignationById(int category_type_id)
        {
            var attrValue = DB_IO.AttrValue();

            attrValue[CategoryTypeEnt.category_type_id] = category_type_id;
            return((string)DB_IO.SelectScalar(DB_IO.DB_Interface.pr_select_category_types, attrValue));
        }
        public static int SelectTransactionTypeIdByName(string designation)
        {
            var attrValue = DB_IO.AttrValue();

            attrValue[TransactionTypeEnt.designation] = designation;
            return((int)DB_IO.SelectScalar(DB_IO.DB_Interface.pr_select_transaction_types, attrValue));
        }
        public static DataTableReader SelectBudget(int budget_id)
        {
            var attrValue = DB_IO.AttrValue();

            attrValue[DB_API.BudgetEnt.budget_id] = budget_id;
            return(DB_IO.SelectReader(DB_IO.DB_Interface.pr_select_budgets, attrValue));
        }
        // ----------------------------------------------------------------------------------------------
        // TRANSACTIONS ---------------------------------------------------------------------------------
        // ----------------------------------------------------------------------------------------------

        public static DataTableReader SelectAccountTransactions(int account_id)
        {
            var attrValue = DB_IO.AttrValue();

            attrValue[DB_API.TransactionEnt.account_id] = account_id;
            return(DB_IO.SelectReader(DB_IO.DB_Interface.pr_select_transactions, attrValue));
        }
        public static string SelectTransactionTypeNameById(int transaction_tpe_id)
        {
            var attrValue = DB_IO.AttrValue();

            attrValue[TransactionTypeEnt.transaction_type_id] = transaction_tpe_id;
            return((string)DB_IO.SelectScalar(DB_IO.DB_Interface.pr_select_transaction_types, attrValue));
        }
        public static DataTableReader SelectWallet(int wallet_id)
        {
            var attrValue = DB_IO.AttrValue();

            attrValue[DB_API.WalletEnt.wallet_id] = wallet_id;
            return(DB_IO.SelectReader(DB_IO.DB_Interface.pr_select_wallets, attrValue));
        }
        // ----------------------------------------------------------------------------------------------
        // STOCKS ---------------------------------------------------------------------------------------
        // ----------------------------------------------------------------------------------------------

        public static DataTableReader SelectAllAccountPurchasedStocks(int account_id)
        {
            var attrValue = DB_IO.AttrValue();

            attrValue[DB_API.StockEnt.account_id] = account_id;
            return(DB_IO.SelectReader(DB_IO.DB_Interface.pr_select_purchased_stocks, attrValue));
        }
        public static DataTableReader SelectAccountGoals(int account_id)
        {
            var attrValue = DB_IO.AttrValue();

            attrValue[DB_API.GoalEnt.account_id] = account_id;
            return(DB_IO.SelectReader(DB_IO.DB_Interface.pr_select_goals, attrValue));
        }
        public static void DeleteUser(string email)
        {
            var attrValue = DB_IO.AttrValue();

            attrValue[UserEnt.email] = email;
            DB_IO.Delete(DB_IO.DB_Interface.pr_delete_user, attrValue);
        }
        public static void DeleteTransaction(int transaction_id)
        {
            var attrValue = DB_IO.AttrValue();

            attrValue[DB_API.TransactionEnt.transaction_id] = transaction_id;
            DB_IO.Delete(DB_IO.DB_Interface.pr_delete_transaction, attrValue);
        }
        public static int SelectCategoryTypeIdByDesignation(string designation)
        {
            var attrValue = DB_IO.AttrValue();

            attrValue[CategoryTypeEnt.designation] = designation;
            return((int)DB_IO.SelectScalar(DB_IO.DB_Interface.pr_select_category_types, attrValue));
        }
        public static DataTableReader SelectCategory(int category_id)
        {
            var attrValue = DB_IO.AttrValue();

            attrValue[CategoryEnt.category_id] = category_id;
            return(DB_IO.SelectReader(DB_IO.DB_Interface.pr_select_categories, attrValue));
        }
        public static DataTableReader SelectWalletByName(int account_id, string name)
        {
            var attrValue = DB_IO.AttrValue();

            attrValue[DB_API.WalletEnt.account_id] = account_id;
            attrValue[DB_API.WalletEnt.name]       = name;
            return(DB_IO.SelectReader(DB_IO.DB_Interface.pr_select_wallets, attrValue));
        }
        public static int SelectRecurenceIdbyDesignation(string designation)
        {
            var attrValue = DB_IO.AttrValue();

            attrValue[RecurrenceEnt.designation] = designation;
            Console.WriteLine(DB_IO.SelectScalar(DB_IO.DB_Interface.pr_select_recurrences, attrValue));
            return((int)DB_IO.SelectScalar(DB_IO.DB_Interface.pr_select_recurrence_id, attrValue));
        }
        public static void MoneyAccountRemoveUser(int account_id, string user_email)
        {
            var attrValue = DB_IO.AttrValue();

            attrValue[MoneyAccountEnt.account_id] = account_id;
            attrValue[MoneyAccountEnt.user_email] = user_email;
            DB_IO.Delete(DB_IO.DB_Interface.pr_money_account_remove_user, attrValue);
        }
        public static void MoneyAccountAddUser(int account_id, string user_email)
        {
            var attrValue = DB_IO.AttrValue();

            attrValue[MoneyAccountEnt.account_id] = account_id;
            attrValue[MoneyAccountEnt.user_email] = user_email;
            DB_IO.Insert(DB_IO.DB_Interface.pr_money_account_add_user, attrValue);
        }
        // ----------------------------------------------------------------------------------------------
        // STATS ----------------------------------------------------------------------------------------
        // ----------------------------------------------------------------------------------------------

        public static DataTableReader SelectAnnualStatistics(int account_id, int year)
        {
            var attrValue = DB_IO.AttrValue();

            attrValue[DB_API.Statistics.account_id] = account_id;
            attrValue[DB_API.Statistics.year]       = year;
            return(DB_IO.SelectFromUDFTable(DB_IO.DB_Interface.udf_annual_statistics, attrValue));
        }
        public static String SelectRecurrenceById(int id)
        {
            var attrValue = DB_IO.AttrValue();

            attrValue[RecurrenceEnt.periodicity] = id;
            var rdr = DB_IO.SelectReader(DB_IO.DB_Interface.pr_select_recurrences, attrValue);

            rdr.Read();
            return(rdr[RecurrenceEnt.designation.ToString()].ToString());
        }
        public static void DeleteStocksByCompany(int accountID, string company, double purchasePrice, double askPrice)
        {
            var attrValue = DB_IO.AttrValue();

            attrValue[DB_API.StockEnt.account_id]     = accountID;
            attrValue[DB_API.StockEnt.company]        = company;
            attrValue[DB_API.StockEnt.purchase_price] = purchasePrice;
            attrValue[DB_API.StockEnt.ask_price]      = askPrice;
            DB_IO.Delete(DB_IO.DB_Interface.pr_delete_purchased_stocks, attrValue);
        }
        public static void DeleteStockByTicker(int accountID, int ticker, double purchasePrice, double askPrice)
        {
            var attrValue = DB_IO.AttrValue();

            attrValue[DB_API.StockEnt.account_id]     = accountID;
            attrValue[DB_API.StockEnt.ticker]         = ticker;
            attrValue[DB_API.StockEnt.purchase_price] = purchasePrice;
            attrValue[DB_API.StockEnt.ask_price]      = askPrice;
            DB_IO.Delete(DB_IO.DB_Interface.pr_delete_purchased_stocks, attrValue);
        }
 public static DataTableReader SelectAllStocks()
 {
     return(DB_IO.SelectReader(DB_IO.DB_Interface.pr_select_stocks, DB_IO.AttrValue()));
 }
 public static DataTableReader SelectAllCategoryTypes()
 {
     return(DB_IO.SelectReader(DB_IO.DB_Interface.pr_select_category_types, DB_IO.AttrValue()));
 }
 public static DataTableReader SelectAllTransactionTypes()
 {
     return(DB_IO.SelectReader(DB_IO.DB_Interface.pr_select_transaction_types, DB_IO.AttrValue()));
 }