Looking at the Details for an Invoicing Application in Delphi - Invoice Management Code and Output
(Page 4 of 6 )
The remaining part of the application deals mostly with managing invoice and client information. Check below for a listing of the code for the two units.
unit viewchange;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, DBCtrls, ExtCtrls, Mask, Buttons,math, RpRave,
RpDefine, RpCon, RpConDS, DB, ADODB, RpRenderCanvas, RpRenderPreview,
RpRender, RpRenderPDF, RpBase, RpSystem;
type
TForm5 = class(TForm)
GroupBox1: TGroupBox;
StaticText7: TStaticText;
StaticText3: TStaticText;
dbm: TDBMemo;
StaticText6: TStaticText;
StaticText4: TStaticText;
dbnav: TDBNavigator;
edinvname: TDBText;
StaticText1: TStaticText;
SpeedButton1: TSpeedButton;
StaticText2: TStaticText;
DBText4: TDBText;
edAmount: TDBEdit;
edTotal: TDBEdit;
SpeedButton2: TSpeedButton;
rds: TRvDataSetConnection;
rvp: TRvProject;
cd: TDataSource;
cado: TADOTable;
DBMemo1: TDBMemo;
rds2: TRvDataSetConnection;
edstatus: TDBEdit;
StaticText5: TStaticText;
pdf1: TRvRenderPDF;
RvRenderPreview1: TRvRenderPreview;
rvs: TRvSystem;
SpeedButton3: TSpeedButton;
procedure SpeedButton1Click(Sender: TObject);
procedure edTotalClick(Sender: TObject);
procedure edAmountChange(Sender: TObject);
procedure SpeedButton2Click(Sender: TObject);
procedure SpeedButton3Click(Sender: TObject);
procedure FormShow(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form5: TForm5;
tots:real;
dt:tdatetime;
implementation
{$R *.dfm}
uses invmain;
procedure TForm5.SpeedButton1Click(Sender: TObject);
begin
close;
end;
procedure TForm5.edTotalClick(Sender: TObject);
var
am:real;
begin
edtotal.Clear;
if tots > 0 then
begin
am:= (form1.vat / 100) * tots;
tots:=tots + am;
tots:=RoundTo(tots,-2);
edTotal.Text:=floattostr(tots);
end;
end;
procedure TForm5.edAmountChange(Sender: TObject);
begin
tots:= strtofloat(edAmount.Text);
end;
procedure TForm5.SpeedButton2Click(Sender: TObject);
begin
rvp.Execute;
end;
procedure TForm5.SpeedButton3Click(Sender: TObject);
begin
dt:=now;
ShortDateFormat := 'dmyyyy';
rvs.DefaultDest:=rdFile;
rvs.DoNativeOutput:=false;
rvs.RenderObject:= pdf1;
rvs.OutputFileName:='d:'+edinvname.Caption +''+DateToStr(Date)+'.pdf';
rvs.SystemSetups:=rvs.SystemSetups-[ssAllowsetup];
rvp.Engine:=rvs;
rvp.Execute;
end;
procedure TForm5.FormShow(Sender: TObject);
begin
cado.ConnectionString:=form1.con;
form1.ado1.ConnectionString:=form1.con;
form1.ado1.Active:=true;
form1.ado1.recno:=form1.num;
cado.active:=true;
{cd.DataSet:='cado';
cado.tablename:='clients';
cado.masterfield:='invname';
edamount.datasource:='Form1.d1';
edamount.datafield:='amount';
edtotal.datasource:='Form1.d1';
edtotal.datafield:='total';
edstatus.datasource:='Form1.d1';
edstatus.datafield:='status';
dbtext4.datasource:='Form1.d1';
dbnav.datasource:='Form1.d1';
dbm.datasource:='Form1.d1';
dbm.datafield:='notes';
}
//client properties
{cd.DataSet:=cado;
cado.tablename:='clients';
cado.MasterFields:='invname';
edinvname.datasource:=cd;
dbmemo1.datasource:=cd;
dbmemo1.DataField:='address';
edinvname.DataField:='invname'; }
//cado.Active:=true;
rvp.ProjectFile:=form1.rav;
end;
end.
Output produced by this code:

Next: Client Management Code >>
More Delphi-Kylix Articles
More By Chris Neeman