Esempio n. 1
0
// transact with the current active account and profile
void TransactionMenu(){
	
	if(ActiveAccountID < 1){
		cout << "No active account has been selected.";
		return;
	}

	if(ActiveUserID < 1){
		cout << "No active profile has been selected.";
		return;
	}

	stringstream AAID(""); // active account id
	stringstream AUID(""); // active user id

	AAID << ActiveAccountID;
	AUID << ActiveUserID;

	if(DB.FieldExists(USER_TABLE, "UserID", (char*)AUID.str().c_str()) == false){
		ActiveUserID = -1;
		cout << "User ID selected does not exist.";
		return;
	}
	else if(DB.FieldExists(ACCOUNT_TABLE, "AcctID", (char*)AAID.str().c_str()) == false){
		ActiveAccountID = -1;
		cout << "Account ID selected does not exist.";
		return;
	}

	string MenuOptions[] = {
		"exit this menu",
		"add money",
		"withdraw money",
		"view transactions"
	};

	switch(Menu(MenuOptions, "Transactions Menu")){
		case 0: return;
		case 1:  TransactAmount(true); break;
		case 2:  TransactAmount(false); break;
		case 3:  ViewTransactions(); break;
		default: return;
	}
}
Esempio n. 2
0
void ReportMenu(){
	if(ActiveAccountID < 1){
		cout << "No active account has been selected.";
		return;
	}

	if(ActiveUserID < 1){
		cout << "No active profile has been selected.";
		return;
	}

	stringstream AAID(""); // active account id
	stringstream AUID(""); // active user id

	AAID << ActiveAccountID;
	AUID << ActiveUserID;

	if(DB.FieldExists(USER_TABLE, "UserID", (char*)AUID.str().c_str()) == false){
		ActiveUserID = -1;
		cout << "User ID selected does not exist.";
		return;
	}
	else if(DB.FieldExists(ACCOUNT_TABLE, "AcctID", (char*)AAID.str().c_str()) == false){
		ActiveAccountID = -1;
		cout << "Account ID selected does not exist.";
		return;
	}

	string MenuOptions[] = {
		"exit this menu",
		"view all",
		"view last 24 hours",
		"view last 7 days"
	};

	switch(Menu(MenuOptions, "Transactions Menu")){
		case 0: return;
		case 1:  ViewReport(); break;
		case 2:  ViewReport(86400); break;
		case 3:  ViewReport(604800); break;
		default: return;
	}
}
Esempio n. 3
0
// delete an account
void DeleteAccount(){
	
	TableDataSet NewDataSet;
	
	stringstream is("");
	
	ViewAccounts();
	
	is << GetUserInput("Select an ID to delete", DB.GetMaxField(ACCOUNT_TABLE, "AcctID"));
	
	NewDataSet.push_back(make_pair("AcctID", is.str()));
	DB.Delete(ACCOUNT_TABLE, NewDataSet);
	
	// delete transactions matching this user and account id
	TableDataSet TransactionTableDataSet;
	stringstream AAID(""); // active account id
	stringstream AUID(""); // active user id

	AAID << ActiveAccountID;
	AUID << ActiveUserID;

	if(DB.FieldExists(USER_TABLE, "UserID", (char*)AUID.str().c_str()) == false){
		ActiveUserID = -1;
		cout << "User ID selected does not exist.";
		return;
	}
	else if(DB.FieldExists(ACCOUNT_TABLE, "AcctID", (char*)AAID.str().c_str()) == false){
		ActiveAccountID = -1;
		cout << "Account ID selected does not exist.";
		return;
	}
	
	TransactionTableDataSet.push_back(make_pair("AcctID", AAID.str().c_str()));
	TransactionTableDataSet.push_back(make_pair("UserID", AUID.str().c_str()));

	DB.Delete(TRANSACTION_TABLE, TransactionTableDataSet);

	ActiveAccountID = -1;
}
Esempio n. 4
0
// view transactions for the current account id and user id
void ViewTransactions(){

	TableDataSet TransactionTableDataSet;
	stringstream AAID(""); // active account id
	stringstream AUID(""); // active user id

	AAID << ActiveAccountID;
	AUID << ActiveUserID;

	if(!validate::string::numeric(AAID.str())){
		cout << "invalid  account id";
		return;
	}

	if(!validate::string::numeric(AUID.str())){
		cout << "invalid user id";
		return;
	}

	if(DB.FieldExists(USER_TABLE, "UserID", (char*)AUID.str().c_str()) == false){
		ActiveUserID = -1;
		cout << "User ID selected does not exist.";
		return;
	}
	else if(DB.FieldExists(ACCOUNT_TABLE, "AcctID", (char*)AAID.str().c_str()) == false){
		ActiveAccountID = -1;
		cout << "Account ID selected does not exist.";
		return;
	}

	
	TransactionTableDataSet.push_back(make_pair("AcctID", AAID.str().c_str()));
	TransactionTableDataSet.push_back(make_pair("UserID", AUID.str().c_str()));

	DB.ShowTable(TRANSACTION_TABLE, TransactionTableDataSet, 2);
}