Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
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
Shire is currently offline  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 messageGo to next message
unodgs is currently offline  unodgs
Messages: 1366
Registered: November 2005
Location: Poland
Ultimate Contributor

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.
Re: HomeBudget example bug [message #20105 is a reply to message #19788] Tue, 17 February 2009 21:17 Go to previous message
unodgs is currently offline  unodgs
Messages: 1366
Registered: November 2005
Location: Poland
Ultimate Contributor

Patch applied. Thanks!
Previous Topic: Uploading files via FTP
Next Topic: Register new file types under windows
Goto Forum:
  


Current Time: Fri Apr 19 15:33:21 CEST 2024

Total time taken to generate the page: 0.03099 seconds