Have you been looking for a way to tame the invoices in your small business? In this article, the first of two parts, we are going to create a fully functioning invoicing system that can be used in almost any environment and situation. Interested? Keep reading.
Invoicing in Delphi: Show Me the Money - Building the Application Interface (Page 3 of 5 )
Start a new project in Delphi and add seven forms to it. Save the units with the following names:
Unit Name Save as... unit1 invmain unit2 newinv unit3 settings unit4 stats unit5 viewchange unit6 viewclients unit7 about
Finally save the project as: invoicing. Now close all other forms except the one saved as invmain, because that is the one that we need to start developing first. Once you have Form1 in front of you, from the Standard tab drop the Mainmenu component on the form. Double click on it and add the following menu items:
A file with a submenu item called Exit. Double click on the exit submenu item and add the following code:
procedure TForm1.Exit1Click(Sender: TObject); begin close; end;
Now create the second menu item, called Clients, with a submenu item called Manage Clients. Double click on it and add the following code:
procedure TForm1.ViewAllClients1Click(Sender: TObject); begin form6.show; end;
Create the third menu item and call it Tools. Then add the following submenu items:
Settings
Double click on the above submenu item and add the following code:
procedure TForm1.Settings1Click(Sender: TObject); begin form3.show end;
Statistics
Double click on the above submenu item and add the following code:
procedure TForm1.Statistics1Click(Sender: TObject); begin form4.show; end;
Then create the final menu item called Help, and add a submenu item called About. Double click on it and add the following code:
procedure TForm1.About1Click(Sender: TObject); begin form7.show; end;
That's it for the menu items. Now on the form add a panel and align it to "all top." Put on the panel the following components:
Two radio buttons - Name them rb1 and rb2 respectively.Then give them the captions: Search by Invoice Name and Search by Invoice Number.
Tedit - Name the edit "edsearch." Clear the text property if there is any text in it.
Button - name the button "btnsearch" and add the caption "Search."
Save your work. Next, from the Data Controls tab add the database grid and set its align property to all client. Double click on the grid and the column property editor should come up. Add five columns and give them the following captions:
Invoice Number Invoice Name Invoice Date Status
You add captions by going to the title property of each column.
Next, we add another panel and set its align property to "alBottom." On this panel add the following widgets:
Two static text -- with caption names "Total Invoices" and "Current Invoice #."
Two labels
Three buttons, named btnDelete, btnAddInv and btnExit respectively.
To the three buttons, add the following code, in the order given:
btnDelete:
procedure TForm1.btndeleteClick(Sender: TObject); begin if ado1.RecordCount > 0 then begin ado1.Delete; end else showmessage('No invoices to delete'); end;
btnAddInv:
procedure TForm1.btnAddInvClick(Sender: TObject); begin ado1.Active:=false; //form1.ado1.TableName:=''; form2.show; end;
btnExit:
procedure TForm1.btnExitClick(Sender: TObject); begin close; end;
Then finally drop a datasource component (name it d1) from the Data Access tab and an ADO table component (name it ado1) from the Ado Tab. Set form1's caption to Invoice Manager. That completes the design on the first form. Your form should look something like this: