Diffstat (limited to 'noncore/apps/qashmoney/budget.cpp') (more/less context) (show whitespace changes)
-rwxr-xr-x | noncore/apps/qashmoney/budget.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/noncore/apps/qashmoney/budget.cpp b/noncore/apps/qashmoney/budget.cpp index 42f7eca..9f74078 100755 --- a/noncore/apps/qashmoney/budget.cpp +++ b/noncore/apps/qashmoney/budget.cpp @@ -1,27 +1,28 @@ #include "budget.h" #include "transaction.h" #include <stdlib.h> +#include <iostream.h> extern Transaction *transaction; Budget::Budget () { bdb = sqlite_open ( "qmbudgets.db", 0, NULL ); } Budget::~Budget () { sqlite_close ( bdb ); } int Budget::addBudget ( QString name, int type, QString description, QString currency, int startday, int startmonth, int startyear, int endday, int endmonth, int endyear, int defaultview ) { sqlite_exec_printf ( bdb, "insert into budgets values ( '%q', %i, '%q', '%q', %i, %i, %i, %i, %i, %i, %i, NULL );", 0, 0, 0, ( const char * ) name, type, ( const char * ) description, ( const char * ) currency, startday, startmonth, startyear, endday, endmonth, endyear, defaultview ); char **results; sqlite_get_table ( bdb, "select last_insert_rowid() from budgets;", &results, NULL, NULL, NULL ); QString tablename = "table"; tablename.append ( results [ 1 ] ); sqlite_exec_printf ( bdb, "create table '%q' ( name, lineitemamount, type, lineitemid integer primary key );", 0, 0, 0, ( const char* ) tablename ); return atoi ( results [ 1 ] ); } @@ -41,49 +42,49 @@ void Budget::deleteBudget ( int budgetid ) } } int Budget::getNumberOfBudgets () { char **results; sqlite_get_table ( bdb, "select count() from budgets;", &results, NULL, NULL, NULL ); return atoi ( results [ 1 ] ); } int Budget::getNumberOfLineItems ( int budgetid ) { QString tablename = "table"; tablename.append ( QString::number ( budgetid ) ); char **results; sqlite_get_table_printf ( bdb, "select count() from '%q';", &results, NULL, NULL, NULL, ( const char * ) tablename ); return atoi ( results [ 1 ] ); } QStringList* Budget::getBudgetNames () { QStringList *names = new QStringList (); char **results; int rows, counter; - sqlite_get_table ( bdb, "select name from budgets order by name asc;", &results, &rows, NULL, NULL ); + sqlite_get_table ( bdb, "select name from budgets;", &results, &rows, NULL, NULL ); names->append ( "None" ); for ( counter = 0; counter < rows; counter++ ) names->append ( results [ counter+1 ] ); return names; } QString Budget::getBudgetName ( int budgetid ) { char **results; sqlite_get_table_printf ( bdb, "select name from budgets where budgetid= %i;", &results, NULL, NULL, NULL, budgetid ); return ( QString ) results [ 1 ]; } QString Budget::getBudgetDescription ( int budgetid ) { char **results; sqlite_get_table_printf ( bdb, "select description from budgets where budgetid= %i;", &results, NULL, NULL, NULL, budgetid ); return ( QString ) results [ 1 ]; } QString Budget::getCurrency ( int budgetid ) { char **results; sqlite_get_table_printf ( bdb, "select currency from budgets where budgetid= %i;", &results, NULL, NULL, NULL, budgetid ); |