Exemple #1
0
bool NoteList::createNote(int idx)
{
    SQLiteStatement *q = g_mainWindow->getFoundNote(idx);

    bool ret = false;
    if(q->FetchRow()) {
        NoteItem* noteItem;
        noteItem = new NoteItem(this,q->GetColumnInt(0),true);
        noteItem->autoSize();
        m_notes[idx] = noteItem;
        int delta = noteItem->height() - UNIT_PADDING;
        if(delta) {
            m_heightDelta += delta;
            adjustSize();
        }
        ret = true;
    }
    return ret;
}
Exemple #2
0
//Returns transaction log
void Database::getTransactions(int accountId){

	//Opens database
	SQLiteDatabase *pDatabase = this->connect();
	SQLiteStatement *pStmt = this->createStatement(pDatabase);

	//Holds the number of transactions for this account
	int transactionCount = 0;

	vector<int> transactionIds;

	//Query to poll the database for all transactions by accountId
	pStmt->Sql("Select * FROM Transactions1 where accountId = ?");
	pStmt->BindInt(1, accountId);
	pStmt->Execute();

	//Controls the loop to add all transactions to the vector
	bool moreRows=true;

	//While there are additional rows of transactions, add them to the transaction log
	while (moreRows = pStmt->FetchRow())
	{
		// if transactioncount+1=8, then you got to clear the screen. Want 8 transactions at a time. 
		if (transactionCount == 0 || transactionCount % 8 == 0)
		{
			//if no transactions have been included, place zero.
			if (transactionCount == 0)
			{
				system("cls");
				cout << "Id \t" << "Amount \t" << "Transaction Type \t" << "Transaction Date \t" << endl << endl;
			}

			//Control to Display only 10 transactions at a time.
			if (transactionCount % 8 == 0 && transactionCount > 0)
			{
				int choice = 0;
				if (moreRows == false)
				{
					cout << endl << endl << "1) View Specific Transaction?" << endl;
					cout << endl << endl << "2) Exit Transaction Log?" << endl << endl;
					cout << "Select Option Number: ";
					cin >> choice;

					if (choice == 1)
					{
						int selection;
						cout << "View Transaction Number: ";
						cin >> selection;
						//view specific selection
						getTransaction(transactionIds[selection - 1]);
						//return to base account screen. 
						pStmt->FreeQuery();

						return;
					}

				
				}
				if (moreRows == true)
				{
					cout << endl << "1) View Specific Transaction?";
					cout << endl << "2) View More Transactions?";
					cout << endl << "3) Exit Transaction Log?" << endl << endl;
					cout << "Select Option Number: ";
					cin >> choice;

					if (choice == 1)
					{
						int selection;
						cout << "View Transaction Number: ";
						cin >> selection;
						getTransaction(transactionIds[selection - 1]);
						pStmt->FreeQuery();
						return;//leave loop.
					}