Home » Extra libraries, Code snippets, applications etc. » U++ users applications in progress and useful code snippets, including reference examples! » HomeBudget example bug
HomeBudget example bug [message #19787] |
Tue, 20 January 2009 02:44 ![Go to next message Go to next message](theme/default/images/down.png) |
Shire
Messages: 41 Registered: September 2006 Location: Russia, Yamal peninsula
|
Member |
|
|
When application setup, months list is correctly initialized by months of current year.
void HomeBudget::Setup()
{
...
Date dt = GetSysDate();
dt.day = 1;
...
GenMonthList(dt.year);
But when selected one of months in month grid, months is reinitialized by year of selection:
void HomeBudget::ChangeDate()
{
dtid = month(ID);
LoadMoney(dtid);
UpdateSummary();
GenMonthList(((Date) month(DT)).year);
}
After new year, DropGrid months will never be initialized by current year.
I made corrections in GenMonthList:
void HomeBudget::GenMonthList(int year)
{
months.Clear();
int curr_year = GetSysDate().year;
int scan_year = min(year,curr_year) - 1;
int max_year = max(year,curr_year);
for(int scan_year = min(year,curr_year) - 1; scan_year <= max_year; scan_year++)
for(int i = 0; i < 12; i++)
months.Add(Date(scan_year, i + 1, 1), Format("%Month %.4d", i + 1, scan_year));
}
Now DropGrid includes months of years from given-1 to current.
Also example does not use table indexes. This is not good.
TABLE_(CATEGORIES)
INT (ID) PRIMARY_KEY
INT_ (GR_ID) INDEX
...
TABLE_(MONEY)
INT (ID) PRIMARY_KEY
INT_ (DT_ID) INDEX
INT_ (CAT_ID) INDEX
Other small changes (russian translation, layout fix, and other) are in attach.
|
|
|
Re: HomeBudget example bug [message #19788 is a reply to message #19787] |
Tue, 20 January 2009 08:41 ![Go to previous message Go to previous message](theme/default/images/up.png) ![Go to next message Go to next message](theme/default/images/down.png) |
|
Shire wrote on Mon, 19 January 2009 20:44 | [/code]
Also example does not use table indexes. This is not good.
TABLE_(CATEGORIES)
INT (ID) PRIMARY_KEY
INT_ (GR_ID) INDEX
...
TABLE_(MONEY)
INT (ID) PRIMARY_KEY
INT_ (DT_ID) INDEX
INT_ (CAT_ID) INDEX
Other small changes (russian translation, layout fix, and other) are in attach.
|
Thanks for the dates fixes! The reason indexes are not there is the size of the database. It's very small and it grows slowly, so I never experienced performance problems. But of course this is agood idea.
I will apply your fixes soon.
|
|
|
|
Goto Forum:
Current Time: Sun Sep 01 07:26:14 CEST 2024
Total time taken to generate the page: 0.00490 seconds
|