Z
zlcgs
Unregistered / Unconfirmed
GUEST, unregistred user!
以下为我的程序,fp是我的数据表,单位名称,日期,发票号,金额,扣税率,扣税金额,代开发票人,备注为属性,其中,金额,扣税率,扣税金额是单精度型,我是用access来建数据库的,这个代码能够运行,但是,你执行功能时,会出现不正常的定义参数对象,能帮我吗,
unit fp;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DB, DBTables, Buttons, ADODB, ExtCtrls, ComCtrls, StdCtrls,
Grids, DBGrids;
type
TForm2 = class(TForm)
ADOConnection1: TADOConnection;
ADOQuery1: TADOQuery;
PageControl1: TPageControl;
TabSheet1: TTabSheet;
TabSheet2: TTabSheet;
Label1: TLabel;
DateTimePicker1: TDateTimePicker;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
Label8: TLabel;
Label9: TLabel;
Bevel1: TBevel;
SpeedButton1: TSpeedButton;
SpeedButton2: TSpeedButton;
SpeedButton3: TSpeedButton;
edit1: TEdit;
edit2: TEdit;
edit3: TEdit;
edit4: TEdit;
edit5: TEdit;
edit6: TEdit;
edit7: TEdit;
GroupBox1: TGroupBox;
ADOQuery2: TADOQuery;
DBGrid1: TDBGrid;
DataSource1: TDataSource;
Bevel2: TBevel;
Panel1: TPanel;
ComboBox1: TComboBox;
Edit8: TEdit;
SpeedButton4: TSpeedButton;
RadioGroup1: TRadioGroup;
a: TRadioButton;
e: TRadioButton;
procedure SpeedButton1Click(Sender: TObject);
procedure SpeedButton2Click(Sender: TObject);
procedure SpeedButton3Click(Sender: TObject);
procedure edit5Change(Sender: TObject);
procedure SpeedButton4Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
implementation
{$R *.dfm}
procedure TForm2.SpeedButton1Click(Sender: TObject);
begin
if edit1.Text =''then application.messagebox('单位名称不能为空!','填错啦 ',0)
else
begin
with adoquery1 do
begin
close;
sql.clear;
sql.add('insert into fp(单位名称,日期,发票号,金额,扣税率,扣税金额,代开发票人,备注) valuesa,:b,:c,:d,:e,:f,:g,:h)');
parameters.parambyname('a').value:=trim(edit1.Text );
parameters.parambyname('b').value:=datetimepicker1.time;
parameters.parambyname('c').value:=trim(edit2.text);
parameters.parambyname('d').value:=strtofloat(trim(edit3.text));
parameters.parambyname('f').value:= strtofloat(trim(edit4.text));
parameters.parambyname('g').value:=strtofloat(trim(edit5.text));
parameters.parambyname('h').value:=trim(edit6.Text );
parameters.parambyname('a').value:= trim(edit7.Text );
execsql;
end;
end;
end;
procedure TForm2.SpeedButton2Click(Sender: TObject);
begin
edit1.Text :='';
edit2.Text :='';
edit3.Text :=floattostr( 0);
edit4.Text :=floattostr(0 );
edit5.Text :=floattostr(0.0);
edit6.Text :='';
edit7.Text :='';
end;
procedure TForm2.SpeedButton3Click(Sender: TObject);
begin
close;
end;
procedure TForm2.edit5Change(Sender: TObject);
var
a,b,c:real;
begin
a:=strtofloat(trim(edit3.text));
b:=strtofloat(trim(edit4.Text ));
c:=a*b;
edit5.Text :=floattostr(c);
end;
procedure TForm2.SpeedButton4Click(Sender: TObject);
var c,b:string;
begin
if a.Checked then
begin
c:=combobox1.Text;
b:=edit8.Text;
adoquery2.close;
adoquery2.SQL.Clear;
adoquery2.SQL.Add('select *from fp');
if edit8.Text <>'' then
begin
adoquery2.SQL.Add('where'+' '+c+':=var1');
adoquery2.parameters.ParamByName('var1').Value:=b;
try
adoquery2.Open;
if adoquery2.FindLast then
application.MessageBox('查询成功!','恭喜!',0)
else
application.MessageBox('对不起,没有试发票!','信息框',0);
except
adoquery2.ExecSQL;
end ;
end
else
begin
showmessage('请输入正确的查询条件!');
end;
end;
if e.Checked then
adoquery2.edit ;
try
if messagedlg('确定要删除吗?',mtinformation,[mbyes,mbno],0)=mryes
then
begin
adoquery2.Delete ;
application.MessageBox('删除成功!','提示框',0);
end;
except
application.MessageBox('无法删除!','提示框',0);
end;
end;
end.
unit fp;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DB, DBTables, Buttons, ADODB, ExtCtrls, ComCtrls, StdCtrls,
Grids, DBGrids;
type
TForm2 = class(TForm)
ADOConnection1: TADOConnection;
ADOQuery1: TADOQuery;
PageControl1: TPageControl;
TabSheet1: TTabSheet;
TabSheet2: TTabSheet;
Label1: TLabel;
DateTimePicker1: TDateTimePicker;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
Label8: TLabel;
Label9: TLabel;
Bevel1: TBevel;
SpeedButton1: TSpeedButton;
SpeedButton2: TSpeedButton;
SpeedButton3: TSpeedButton;
edit1: TEdit;
edit2: TEdit;
edit3: TEdit;
edit4: TEdit;
edit5: TEdit;
edit6: TEdit;
edit7: TEdit;
GroupBox1: TGroupBox;
ADOQuery2: TADOQuery;
DBGrid1: TDBGrid;
DataSource1: TDataSource;
Bevel2: TBevel;
Panel1: TPanel;
ComboBox1: TComboBox;
Edit8: TEdit;
SpeedButton4: TSpeedButton;
RadioGroup1: TRadioGroup;
a: TRadioButton;
e: TRadioButton;
procedure SpeedButton1Click(Sender: TObject);
procedure SpeedButton2Click(Sender: TObject);
procedure SpeedButton3Click(Sender: TObject);
procedure edit5Change(Sender: TObject);
procedure SpeedButton4Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
implementation
{$R *.dfm}
procedure TForm2.SpeedButton1Click(Sender: TObject);
begin
if edit1.Text =''then application.messagebox('单位名称不能为空!','填错啦 ',0)
else
begin
with adoquery1 do
begin
close;
sql.clear;
sql.add('insert into fp(单位名称,日期,发票号,金额,扣税率,扣税金额,代开发票人,备注) valuesa,:b,:c,:d,:e,:f,:g,:h)');
parameters.parambyname('a').value:=trim(edit1.Text );
parameters.parambyname('b').value:=datetimepicker1.time;
parameters.parambyname('c').value:=trim(edit2.text);
parameters.parambyname('d').value:=strtofloat(trim(edit3.text));
parameters.parambyname('f').value:= strtofloat(trim(edit4.text));
parameters.parambyname('g').value:=strtofloat(trim(edit5.text));
parameters.parambyname('h').value:=trim(edit6.Text );
parameters.parambyname('a').value:= trim(edit7.Text );
execsql;
end;
end;
end;
procedure TForm2.SpeedButton2Click(Sender: TObject);
begin
edit1.Text :='';
edit2.Text :='';
edit3.Text :=floattostr( 0);
edit4.Text :=floattostr(0 );
edit5.Text :=floattostr(0.0);
edit6.Text :='';
edit7.Text :='';
end;
procedure TForm2.SpeedButton3Click(Sender: TObject);
begin
close;
end;
procedure TForm2.edit5Change(Sender: TObject);
var
a,b,c:real;
begin
a:=strtofloat(trim(edit3.text));
b:=strtofloat(trim(edit4.Text ));
c:=a*b;
edit5.Text :=floattostr(c);
end;
procedure TForm2.SpeedButton4Click(Sender: TObject);
var c,b:string;
begin
if a.Checked then
begin
c:=combobox1.Text;
b:=edit8.Text;
adoquery2.close;
adoquery2.SQL.Clear;
adoquery2.SQL.Add('select *from fp');
if edit8.Text <>'' then
begin
adoquery2.SQL.Add('where'+' '+c+':=var1');
adoquery2.parameters.ParamByName('var1').Value:=b;
try
adoquery2.Open;
if adoquery2.FindLast then
application.MessageBox('查询成功!','恭喜!',0)
else
application.MessageBox('对不起,没有试发票!','信息框',0);
except
adoquery2.ExecSQL;
end ;
end
else
begin
showmessage('请输入正确的查询条件!');
end;
end;
if e.Checked then
adoquery2.edit ;
try
if messagedlg('确定要删除吗?',mtinformation,[mbyes,mbno],0)=mryes
then
begin
adoquery2.Delete ;
application.MessageBox('删除成功!','提示框',0);
end;
except
application.MessageBox('无法删除!','提示框',0);
end;
end;
end.