estoy creando un pequeno from de faturacion el cual me esta dando unu erro cuando ejecuto los calculos.
este es el codigo
Código Delphi
[-]unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DB, ADODB, StdCtrls, DBCtrls, Grids, DBGrids, Buttons, Mask,
ExtCtrls;
type
TForm1 = class(TForm)
Label1: TLabel;
GroupBox1: TGroupBox;
Panel2: TPanel;
Label2: TLabel;
Label15: TLabel;
DBGrid1: TDBGrid;
DBMemo1: TDBMemo;
DSFuncionBoton: TDataSource;
Bevel2: TBevel;
SpeedButton1: TSpeedButton;
SpeedButton2: TSpeedButton;
SpeedButton3: TSpeedButton;
SpeedButton4: TSpeedButton;
SpeedButton5: TSpeedButton;
SpeedButton6: TSpeedButton;
SpeedButton7: TSpeedButton;
SpeedButton8: TSpeedButton;
SpeedButton9: TSpeedButton;
SpeedButton10: TSpeedButton;
SpeedButton11: TSpeedButton;
SpeedButton12: TSpeedButton;
DataSource1: TDataSource;
GroupBox2: TGroupBox;
DBNavigator1: TDBNavigator;
BitBtn1: TBitBtn;
Label11: TLabel;
MaskEdit1: TMaskEdit;
Label3: TLabel;
Label12: TLabel;
DBEdit5: TDBEdit;
DBEdit2: TDBEdit;
Label13: TLabel;
DBEdit9: TDBEdit;
Label14: TLabel;
DBComboBox2: TDBComboBox;
Label16: TLabel;
DBComboBox3: TDBComboBox;
Label17: TLabel;
DBEdit3: TDBEdit;
Label18: TLabel;
Label20: TLabel;
FTotales: TPanel;
Label6: TLabel;
Label9: TLabel;
Label4: TLabel;
LM: TLabel;
Label26: TLabel;
DataSource2: TDataSource;
DataSource3: TDataSource;
DBText1: TDBText;
DBText2: TDBText;
DBText3: TDBText;
DBText4: TDBText;
DBText5: TDBText;
DBText6: TDBText;
DBEdit1: TDBEdit;
DBEdit4: TDBEdit;
procedure SpeedButton6Click(Sender: TObject);
procedure SpeedButton1Click(Sender: TObject);
procedure SpeedButton2Click(Sender: TObject);
procedure SpeedButton9Click(Sender: TObject);
procedure SpeedButton7Click(Sender: TObject);
procedure SpeedButton3Click(Sender: TObject);
procedure SpeedButton12Click(Sender: TObject);
procedure SpeedButton10Click(Sender: TObject);
procedure SpeedButton11Click(Sender: TObject);
procedure SpeedButton5Click(Sender: TObject);
procedure DataSource2DataChange(Sender: TObject; Field: TField);
procedure BitBtn1Click(Sender: TObject);
private
public
end;
var
Form1: TForm1;
implementation
uses Unit2;
{$R *.dfm}
procedure TForm1.SpeedButton6Click(Sender: TObject);
begin
ConexionDB.Query1.Cancel();
end;
procedure TForm1.SpeedButton1Click(Sender: TObject);
Var xouble;
begin
ConexionDB.Query1.Last();
If ( ConexionDB.Query1.IsEmpty) And ( ConexionDB.Query1.IsEmpty) Then
Begin
X:=1;
End
Else
Begin
X:= ConexionDB.Query1['idcliente']+1;
end;
ConexionDB.Query1.Append;
ConexionDB.Query1['idcliente']:=X;
DBEdit5.SetFocus();
end;
procedure TForm1.SpeedButton2Click(Sender: TObject);
begin
ConexionDB.Query1.Post();
end;
procedure TForm1.SpeedButton9Click(Sender: TObject);
begin
ConexionDB.Query1.Next();
end;
procedure TForm1.SpeedButton7Click(Sender: TObject);
begin
close;
end;
procedure TForm1.SpeedButton3Click(Sender: TObject);
begin
conexiondb.Query1.Edit();
end;
procedure TForm1.SpeedButton12Click(Sender: TObject);
begin
conexiondb.Query1.First();
end;
procedure TForm1.SpeedButton10Click(Sender: TObject);
begin
conexiondb.Query1.Prior();
end;
procedure TForm1.SpeedButton11Click(Sender: TObject);
begin
conexiondb.Query1.Last;
end;
procedure TForm1.SpeedButton5Click(Sender: TObject);
begin
if MessageDlg('¿Esta Seguro que Desea Borrar Este registro?',
mtConfirmation, [mbYes, mbNo], 0) = mrYes then
ConexionDB.Query1.Delete();
end;
procedure TForm1.DataSource2DataChange(Sender: TObject; Field: TField);
begin
If ConexionDB.Query1.State In[DsInsert,DsEdit] Then
Begin
SpeedButton2.Enabled := True;
SpeedButton1.Enabled := False;
SpeedButton6.Enabled := True;
SpeedButton3.Enabled := False;
SpeedButton5.Enabled := True;
SpeedButton7.Enabled := False;
SpeedButton8.Enabled := False;
End
Else
Begin
SpeedButton2.Enabled := False;
SpeedButton1.Enabled := True;
SpeedButton6.Enabled := False;
SpeedButton3.Enabled := True;
SpeedButton5.Enabled := False;
SpeedButton7.Enabled := True;
SpeedButton8.Enabled := True;
End
end;
procedure TForm1.BitBtn1Click(Sender: TObject);
var
importe: double;
monto: double;
ITBIS: double;
Total: double;
Apagar: double;
descuento: double;
ivaf: double;
acuenta: double;
begin
if (conexiondb.Query1.state=dsinsert) or (conexiondb.Query1.state=dsedit) then
conexiondb.Query1.Post;
monto := 0;
conexiondb.Query1.First;
while not conexiondb.Query1.Eof do
begin
if not varisnull(conexiondb.Query1.FieldByName('importe').value) then
importe := conexiondb.Query1.FieldByName('importe').value
else
importe:=0;
monto := importe + monto;
conexiondb.Query1.next;
end;
if not varisnull(conexiondb.Query1.fieldbyname('descuento').value) then
descuento := conexiondb.Query1.fieldbyname('descuento').value
else
descuento := 0;
monto := monto -(descuento/ 100)* monto;
if not varisnull(conexiondb.Query1.fieldbyname('ITBIS').value) then
if (conexiondb.Query1.fieldbyname('Cambio').value <> 0) and
(not (varisnull(conexiondb.Query1.fieldbyname('Cambio').value))) then
else
ITBIS := ITBIS;
total := monto + ITBIS;
if not varisnull(conexiondb.Query1.fieldbyname('ACuenta').value) then
ACuenta := conexiondb.Query1.fieldbyname('ACuenta').value
else
acuenta := 0;
conexiondb.Query1.Edit;
conexiondb.Query1.FieldByName('Tmonto').value :=
formatfloat('###,###,###,##0.00;(###,###,###,##0.00);0', monto);
conexiondb.Query1.FieldByName('TotalITBIS').value :=
formatfloat('###,###,###,##0.00;(###,###,###,##0.00);0', ITBIS);
conexiondb.Query1.FieldByName('TotalRecibo').value :=
formatfloat('###,###,###,##0.00;(###,###,###,##0.00);0', total);
conexiondb.Query1.FieldByName('APagar').value :=
formatfloat('###,###,###,##0.00;(###,###,###,##0.00);0', apagar);
conexiondb.Query1.FieldByName('Euros').value :=
formatfloat('###,###,###,##0.00;(###,###,###,##0.00);0', apagar);
conexiondb.Query1.Post;
end;
end.
adema lo subi a la web si lo pueden chequiar aqui esta el link
http://www.4shared.com/get/60995750/...06C8AB4FB.dc61