Fix some bugs and resize images

This commit is contained in:
Grégory Soutadé 2010-07-01 21:13:14 +02:00
parent 1d1164ef02
commit 7bdf6bd1e4
6 changed files with 26 additions and 13 deletions

View File

@ -448,7 +448,25 @@ void Database::SetAccountAmount(int month, int year, wxString accountId, double
req += _(" AND year='") + wxString::Format(_("%d"), year) + _("'");
req += _(" AND month='") + wxString::Format(_("%d"), month) + _("'");
EXECUTE_SQL_UPDATE(req, );
try
{
if (!_db.ExecuteUpdate(req))
{
req = _("INSERT INTO account_amount ('account', 'year', 'month', 'amount') VALUES ('") ;
req += accountId + _("'");
req += _(" ,'") + wxString::Format(_("%d"), year) + _("'");
req += _(" ,'") + wxString::Format(_("%d"), month) + _("'");
req += _(" ,'") + DoubleToString(amount) + _("'");
req += _(")");
EXECUTE_SQL_UPDATE(req, );
}
}
catch (wxSQLite3Exception e)
{
std::cerr << req.mb_str() << "\n" ;
std::cerr << e.GetMessage().mb_str() << "\n" ;
return ;
}
}
wxString Database::AddAccount(User* user, struct Account ac)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 52 KiB

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 16 KiB

View File

@ -355,8 +355,6 @@ void AccountPanel::ShowMonth(int month, int year)
InitAccountsGrid(user, month, year);
UpdateStats();
_calendar->EnableMonthChange(true);
_calendar->EnableYearChange(true);
if (curDate.GetMonth() == month && curDate.GetYear() == year)
@ -370,6 +368,8 @@ void AccountPanel::ShowMonth(int month, int year)
_calendar->EnableYearChange(false);
_calendar->SetSize(_calendar->GetMinSize());
UpdateStats();
// Fit();
// SetMinSize(GetSize());
}
@ -489,8 +489,8 @@ void AccountPanel::InitAccountsGrid(User* user, int month, int year)
_accountsGrid->SetCellValue(curLine, ACCOUNT_NUMBER, it->number);
_accountsGrid->SetCellValue(curLine, ACCOUNT_NAME, it->name);
value = _kiss->GetAccountAmount(it->id, month, year);
_accountsGrid->SetCellValue(curLine, ACCOUNT_INIT, wxString::Format(wxT("%.2lf"), value));
_accountsGrid->SetCellEditor(curLine, ACCOUNT_INIT, new wxGridCellFloatEditor(-1, 2));
_accountsGrid->SetCellValue(curLine, ACCOUNT_INIT, wxString::Format(wxT("%.2lf"), value));
for (a=0; a<NUMBER_COLS_ACCOUNTS; a++)
_accountsGrid->SetReadOnly(curLine, a, a != ACCOUNT_INIT);
_accountsGrid->SetCellFont(curLine, ACCOUNT_CUR, font);
@ -510,18 +510,13 @@ void AccountPanel::UpdateStats()
User* user = _kiss->GetUser();
std::vector<operation>::iterator it;
double curCredit, curDebit, totalCredit, totalDebit, remains, value;
wxDateTime date;
std::map<wxString, double> curAccountAmount, finalAccountAmount;
std::map<wxString, double>::iterator doubleIt;
std::map<wxString, int>::iterator intIt;
std::vector<Account>::iterator accountIt;
unsigned int day, month, year ;
date = _calendar->GetDate();
day = date.GetDay()-1;
month = date.GetMonth();
year = date.GetYear();
unsigned int day;
day = _calendar->GetDate().GetDay()-1;
curCredit = curDebit = totalCredit = totalDebit = 0.0;
for (i=0; i<user->GetCategoriesNumber(); i++)
@ -537,7 +532,7 @@ void AccountPanel::UpdateStats()
{
if (it->amount > 0)
{
if (day >= it->day && month >= it->month && year >= it->year)
if (day >= it->day)
{
curCredit += it->amount;
curAccountAmount[it->account] += it->amount;
@ -548,7 +543,7 @@ void AccountPanel::UpdateStats()
else
{
_categoriesValues[_categoriesIndexes[user->GetCategoryName(it->category)]] += -it->amount ;
if (day >= it->day && month >= it->month && year >= it->year)
if (day >= it->day)
{
curDebit += -it->amount;
curAccountAmount[it->account] += it->amount;