Looking at the Details for an Invoicing Application in Delphi (Page 1 of 6 )
In the previous article we discussed the requirements and purpose of the invoicing application that we are creating. We also listed the main application code. In this part of the article we are going to look at how to connect the database that we created earlier to the application code. We will also look at some of the code in detail.
A
downloadable .rar file is available for this article.
How the application works

The invoice application works by storing and retrieving its information in the database that we created earlier. When the application is first started, it loads certain application-specific settings from an ini file. See the code below:
procedure TForm1.FormCreate(Sender: TObject);
var
settings : TINIFile;
begin
settings := TINIFile.Create(ExtractFilePath(Application.EXEName) + 'settings.ini');
try
con:=settings.ReadString('Settings', 'con','');
//showmessage(con);
vat:=settings.ReadFloat('Settings', 'vat',8.5);
// showmessage(floattostr(vat));
rav:=settings.ReadString('Settings', 'rav','');
finally
settings.Free;
end;
end;
The code shows the oncreate event of the first form in the application. This code loads the following information:
- con – This string contains the path to the database and will be used throughout the application to connect to the database tables.
- vat - This is the VAT rate that the application will use when it calculates the totals.
- rav – This variable stores the path to the rave report file that contains the output designs of the invoice.
This method of storing and retrieving data increases the application’s portability. You can change these values in the ini file by clicking on the settings menu item, which will bring up a window for you to set new values. The next page has a screen shot of what that form looks like and also the code listing for the settings unit.
Next: Settings Unit >>
More Delphi-Kylix Articles
More By Chris Neeman