MyMoneyJournal

This software records your daily expense and income. I use several Microsoft Access database files (*.mdb) to store data. To prevent an oversize database file, I split the database into several parts.

Futures:

  • Easy to track your income and expenses
  • Display pie chart and column chart illustrate cash flow
  • Password protect

Next version futures:

  • It will provide you with up-to-date exchange rates.

MyMoneyJournal1MyMoneyJournal2MyMoneyJournal3

void __fastcall TForm1::LoadDB()
{
    chart_change_flag = 0;
    ADOTable_DB->TableName = Now().FormatString("yyyymm");
    ADOTable_DB->Active = true;
    TStrings *List = new TStringList;
    ADOConnection_DB->GetTableNames(List);
    ADOConnection_DB->Open();

    DBGrid_Main->Visible = false;
    CalcMoney(); 
    DBGrid_Main->Visible = true;

    ADOQuery_DB->Close();
    ADOQuery_DB->SQL->Text = "select * from " + ADOTable_DB->TableName +
        "     order by Date,ID";

    ADOQuery_DB->Open();

    ADOQuery_DB->Last();

    GridSize(0);

    delete List;
}

   

void __fastcall TForm1::ListAllYear()
{
    TStringList *sList;
    AnsiString dir_path = ex_path + "\\data\\" + Edit1->Text;
    LoadAllFiles(dir_path, sList);
    // TMenuItem *ClickedItem = dynamic_cast<TMenuItem *>;
    AnsiString pop_db;
    sel_other_table = new AnsiString*[allYear.Length() / 4];
    AllYearCount = allYear.Length() / 4;
    EachYearMonthCount = new int[allYear.Length() / 4];
    for (int i = 0; i < allYear.Length() / 4; i++)
    {
        TMenuItem *m = new TMenuItem(this);
        m->Caption = allYear.SubString(1 + i * 4, 4);
        pop_db = ex_path + "\\data\\" + Edit1->Text + "\\" + Edit1->Text +
            "(" + allYear.SubString(1 + i * 4, 4) + ").mdb";

        ADOConnection_DB->Close();
        ADOQuery_DB->Active = false;
        ADOConnection_DB->ConnectionString =
            "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + pop_db +
            ";Persist Security Info=False";
        sel_db_path = pop_db;
        sel_db_month = Now().FormatString("yyyymm");
        ADOConnection_DB->Connected = true;
        m->Tag = i;
        PopupMenu_DynamicMonth->Items->Add(m);

        TStrings *List = new TStringList;
        ADOConnection_DB->GetTableNames(List);
        sel_other_table[i] = new AnsiString[List->Count];

        EachYearMonthCount[i] = List->Count;
        for (int j = 0; j < List->Count; j++)
        {
            TMenuItem *subm = new TMenuItem(this);
            sel_other_table[i][j] = List->Strings[j];
            AnsiString table_name = List->Strings[j];
            subm->Caption = table_name;
            PopupMenu_DynamicMonth->Items->Items[i]->Add(subm);
            subm->Tag = j;
            subm->OnClick = PopupMenuItemsClick;
        }
        delete List;
    }
}

 

AnsiString __fastcall TForm1::GetMoneyByDay(AnsiString year, AnsiString month,AnsiString day)
{
    Application->ProcessMessages();
    AnsiString returnMoney = "";
    ADOConnection_NoGrid->Close(); // new_db
    ADOConnection_NoGrid->ConnectionString =
        "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + sel_db_path +
        ";Persist Security Info=False";

    ADOQuery_NoGrid->Close();
    ADOTable_NoGrid->TableName = year + month; // Now().FormatString("yyyymm");
    TStrings *List = new TStringList;
    ADOConnection_NoGrid->GetTableNames(List);
    ADOQuery_NoGrid->Close(); // Now().FormatString("yyyymm")
    ADOQuery_NoGrid->SQL->Text = "select " + all_table + " from " +
        ADOTable_NoGrid->TableName + " where IO='income' and date='" + year + "/" +
        month + "/" + day + "'";
    ADOQuery_NoGrid->ExecSQL();
    ADOQuery_NoGrid->Open();

    int total_IncomeMoney = 0;
    for (int k = 0; k < ADOQuery_NoGrid->RecordCount; k++) {
        total_IncomeMoney = total_IncomeMoney +
            DataSource_NoGrid->DataSet->Fields->Fields[8]->Text.ToDouble();
        DataSource_NoGrid->DataSet->Next();
    }
    returnMoney = returnMoney + IntToStr(total_IncomeMoney) + "\n";

    ADOQuery_NoGrid->Close();
    ADOTable_NoGrid->TableName = year + month; // Now().FormatString("yyyymm");
    TStrings *ListOutcome = new TStringList;
    ADOConnection_NoGrid->GetTableNames(ListOutcome);
    ADOQuery_NoGrid->Close(); // Now().FormatString("yyyymm")
    ADOQuery_NoGrid->SQL->Text = "select " + all_table + " from " +
        ADOTable_NoGrid->TableName + " where io='ougoing' and date='" + year + "/" +
        month + "/" + day + "'";
    ADOQuery_NoGrid->ExecSQL();
    ADOQuery_NoGrid->Open();

    int total_OutcomeMoney = 0;
    for (int k = 0; k < ADOQuery_NoGrid->RecordCount; k++) {
        total_OutcomeMoney = total_OutcomeMoney +
            DataSource_NoGrid->DataSet->Fields->Fields[8]->Text.ToDouble();
        DataSource_NoGrid->DataSet->Next();
    }
    if (total_OutcomeMoney != 0)
        returnMoney = returnMoney + "-" + IntToStr(total_OutcomeMoney) + "\n";
    if (total_OutcomeMoney == 0)
        returnMoney = returnMoney + IntToStr(total_OutcomeMoney) + "\n";

    return returnMoney;
}