大家谁能解决这个问题? ( 积分: 100 )

  • 主题发起人 主题发起人 zongytao
  • 开始时间 开始时间
Z

zongytao

Unregistered / Unconfirmed
GUEST, unregistred user!
当以下程序执行按下BITBTN1按钮时出错出错信息为:“[Microsoft][ODBC Microsoft Access Driver]查询值的数目与目标字段中的数目不同”。请问是怎么回事?
另外 house_num、man_的值都为空,是什么原因?
该程序用DELPHI6+ACCESS2000+ADO实现.

以下是源代码:
unit shuidianfei_input;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Mask, ComCtrls, DBCtrls, Buttons;

type
TForm25 = class(TForm)
Label1: TLabel;
Label3: TLabel;
Edit1: TEdit;
Label9: TLabel;
Edit3: TEdit;
Label12: TLabel;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
Label19: TLabel;
Edit6: TEdit;
Edit7: TEdit;
Label4: TLabel;
DBEdit1: TDBEdit;
Label2: TLabel;
DBEdit2: TDBEdit;
Label5: TLabel;
DBEdit3: TDBEdit;
Label6: TLabel;
DBEdit4: TDBEdit;
Label7: TLabel;
DBEdit5: TDBEdit;
Label8: TLabel;
Edit2: TEdit;
Label10: TLabel;
DBEdit6: TDBEdit;
Label11: TLabel;
Edit4: TEdit;
Label13: TLabel;
Edit5: TEdit;
Label14: TLabel;
Label15: TLabel;
DBEdit7: TDBEdit;
Label16: TLabel;
Label17: TLabel;
Edit8: TEdit;
Label18: TLabel;
Label20: TLabel;
Edit9: TEdit;
Label21: TLabel;
Label22: TLabel;
Edit10: TEdit;
Label23: TLabel;
Label24: TLabel;
Edit11: TEdit;
Label25: TLabel;
Edit12: TEdit;
Label26: TLabel;
Label27: TLabel;
DBEdit8: TDBEdit;
Label30: TLabel;
Label31: TLabel;
Edit14: TEdit;
Label32: TLabel;
ComboBox1: TComboBox;
Label33: TLabel;
Label34: TLabel;
DateTimePicker1: TDateTimePicker;
Label35: TLabel;
BitBtn3: TBitBtn;
Label36: TLabel;
Label37: TLabel;
DBEdit9: TDBEdit;
Edit15: TEdit;
Edit13: TEdit;
Edit17: TEdit;
Edit16: TEdit;
Label28: TLabel;
procedure Edit1Exit(Sender: TObject);
procedure Edit3Exit(Sender: TObject);
procedure Edit6Exit(Sender: TObject);
procedure Edit1KeyPress(Sender: TObject; var Key: Char);
procedure Edit3KeyPress(Sender: TObject; var Key: Char);
procedure Edit6KeyPress(Sender: TObject; var Key: Char);
procedure FormActivate(Sender: TObject);
procedure Edit5Exit(Sender: TObject);
procedure Edit5KeyPress(Sender: TObject; var Key: Char);
procedure Edit9Exit(Sender: TObject);
procedure Edit9KeyPress(Sender: TObject; var Key: Char);
procedure Edit8Exit(Sender: TObject);
procedure Edit8KeyPress(Sender: TObject; var Key: Char);
procedure DateTimePicker1KeyPress(Sender: TObject; var Key: Char);
procedure ComboBox1CloseUp(Sender: TObject);
procedure Edit17KeyPress(Sender: TObject; var Key: Char);
procedure Edit17Exit(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form25: TForm25;
s1,s2,s3,s4,s5,s6,s7,s8,s9:string;

jiaofei_num:string;
jiaofei_month:string;

house_num:string;
man_name:string;
house_type:string;
louhao:string;
fanghao:string;
dianbiao_qichu:integer;
dianbiao_qimo:integer;
dianbiao_benyue:real;
shuibiao_qichu:integer;
shuibiao_qimo:integer;
yongshui_benyue:integer;
feiyong_yingjiao:real;
feiyong_shijiao:real;
feiyong_yujiao_qichu:real;
feiyong_yujiao:real;
feiyong_yujiao_zhuanchu:real;
feiyong_yujiao_qimo:real;
feiyong_yue:real;
feiyong_qianjiao_yuemo:real;
jiaofei:string;
feiyong_yingjiao_date:string;
jiaofei_date:string;
dianfei_price:real;
shuifei_price:real;
dianbiao_yuechu:real;
shuifei_yingjiao:real;
dianfei_yingjiao:real;
wgf_yingjiao:real;
rent_yingjiao:real;
//qunuanfei_yue:real;
feiyong_qianjiao_qichu:real;
zhinajin_qichu:real;
feiyong_yue_benyue:real;
zhinajin_benyue:real;
zhinajin_yuemo:real;
zhinajin_bilv:real;
implementation

uses Unit1, dianfei_price_add;

{$R *.dfm}

procedure TForm25.Edit1Exit(Sender: TObject);
begin
if trim(edit1.Text)='' then
begin
Application.Messagebox('·¿ÎݱàºÅ²»ÄÜΪ¿Õ£¡ÇëÊäÈë·¿ÎݱàºÅ¡£','Ìáʾ',MB_OK);
edit1.setfocus;
end
else
datetimepicker1.SetFocus;
end;

procedure TForm25.Edit3Exit(Sender: TObject);
begin
if trim(edit3.Text)='' then
begin
Application.Messagebox('µç±íÆÚÄ©Êý²»ÄÜΪ¿Õ£¡ÇëÊäÈëµç±íÆÚÄ©Êý¡£','Ìáʾ',MB_OK);
edit3.setfocus;
end
else
edit6.SetFocus;
end;

procedure TForm25.Edit6Exit(Sender: TObject);
begin
if trim(edit6.Text)='' then
begin
Application.Messagebox('±¾ÔÂÓÃË®Êý²»ÄÜΪ¿Õ£¡ÇëÊäÈë±¾ÔÂÓÃË®Êý¡£','Ìáʾ',MB_OK);
edit6.setfocus;
end;

end;

procedure TForm25.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
if(Key=#13)then
begin
jiaofei_month:=formatdatetime('yyyy-mm',incmonth(date,-1));
edit15.Text:=jiaofei_month;
datetimepicker1.setfocus;
end;
with datamodule1.ADOQuery13 do
begin
close;
sql.Clear;
sql.Add('select * from house where house_num='''+edit1.Text+'''');
open;
end;
begin
s1:=datamodule1.ADOQuery13.Fields.Fields[2].AsString;
man_name:=dbedit1.Text;
s2:=datamodule1.ADOQuery13.Fields.Fields[6].AsString;
s2:=house_type;
s3:=datamodule1.ADOQuery13.Fields.Fields[4].AsString;
s3:=louhao;
s4:=datamodule1.ADOQuery13.Fields.Fields[5].AsString;
s4:=fanghao;
end;
with datamodule1.ADOQuery2 do
begin
close;
sql.Clear;
sql.Add('select * from pay_feiyong_qichu where house_num='''+edit1.Text+'''');
open;
end;
begin
dianbiao_qichu:=datamodule1.ADOQuery2.Fields.Fields[7].AsInteger;
dbedit5.Text:=inttostr(dianbiao_qichu);

shuibiao_qichu:=datamodule1.ADOQuery2.Fields.Fields[6].AsInteger;
dbedit6.Text:=inttostr(shuibiao_qichu);

feiyong_qianjiao_qichu:=datamodule1.ADOQuery2.Fields.Fields[4].AsFloat;
dbedit9.Text:=floattostr(feiyong_qianjiao_qichu);

zhinajin_qichu:=datamodule1.ADOQuery2.Fields.Fields[5].AsFloat;

feiyong_yue:=datamodule1.ADOQuery2.Fields.Fields[2].AsFloat;

feiyong_yujiao_qichu:=datamodule1.ADOQuery2.Fields.Fields[3].AsFloat;
dbedit7.Text:=floattostr(feiyong_yujiao_qichu);

zhinajin_qichu:= datamodule1.ADOQuery2.Fields.Fields[5].asFloat;
dbedit8.Text:=formatfloat('0.00',zhinajin_qichu);

end;
end;

procedure TForm25.Edit3KeyPress(Sender: TObject; var Key: Char);
begin
if not(Key in['0'..'9',#8,#13])then
begin
Key:=#0;
end
else
if(key=#13)then
begin
if trim(Edit3.Text)=''then
begin
Application.Messagebox('ÇëÊäÈëµç±íÆÚÄ©Êý!','Ìáʾ',MB_OK);
Edit3.Text:='';
Edit3.SetFocus;
end
else
begin
dianbiao_qimo:=strtoint(trim(edit3.Text))+2;
edit3.Text:=inttostr(dianbiao_qimo);

dianbiao_benyue:=(dianbiao_qimo-dianbiao_qichu);
edit2.Text:=floattostr(dianbiao_benyue);
Edit6.SetFocus;
end;
end;
end;
procedure TForm25.Edit6KeyPress(Sender: TObject; var Key: Char);
begin
if not(Key in['0'..'9',#8,#13]) then
begin
Key:=#0;
end;
//else
if(key=#13)then
begin
if trim(Edit6.Text)='' then
begin
Application.Messagebox('ÇëÊäÈë±¾ÔÂÓÃË®Êý!','Ìáʾ',MB_OK);
Edit6.Text:='';
Edit6.SetFocus;
end
else
begin
yongshui_benyue:=strtoint(trim(edit6.Text));
shuibiao_qimo:=shuibiao_qichu+yongshui_benyue;
edit4.Text:=inttostr(shuibiao_qimo);
with datamodule1.ADOQuery_add_price do
begin
close;
sql.Clear;
sql.Add('select * from price');
open;
end;
begin
s5:=datamodule1.ADOQuery_add_price.Fields.Fields[0].AsString;
s6:=datamodule1.ADOQuery_add_price.Fields.Fields[1].AsString;
s7:=datamodule1.ADOQuery_add_price.Fields.Fields[3].AsString;
s8:=datamodule1.ADOQuery_add_price.Fields.Fields[4].AsString;
s9:=datamodule1.ADOQuery_add_price.Fields.Fields[5].AsString;
dianfei_price:=strtofloat(s5);
shuifei_price:=strtofloat(s6);
wgf_yingjiao:=strtofloat(s7);
zhinajin_bilv:=strtofloat(s9);
if dbedit2.Text<>'LF' then
rent_yingjiao:=strtofloat(s8)
else
begin
rent_yingjiao:=0;
end;
feiyong_yingjiao:=((dianbiao_benyue*dianfei_price)+(yongshui_benyue*shuifei_price)+wgf_yingjiao+rent_yingjiao+feiyong_qianjiao_qichu+zhinajin_qichu+feiyong_yue);
edit12.Text:=floattostr(feiyong_yue_benyue);
edit5.SetFocus;
end;

end;
end;

if (datetimepicker1.Date-strtodate(jiaofei_date))>=0 then
begin
zhinajin_benyue:=0;
zhinajin_yuemo:=0;
edit14.Text:=floattostr(zhinajin_yuemo);
end
else
begin
zhinajin_benyue:=((strtodate(jiaofei_date)-datetimepicker1.Date)*zhinajin_bilv*feiyong_yingjiao);
zhinajin_yuemo:=0;
edit14.Text:=floattostr(zhinajin_yuemo);

end;
feiyong_yingjiao:=((dianbiao_benyue*dianfei_price)+(yongshui_benyue*shuifei_price)+wgf_yingjiao+rent_yingjiao+feiyong_qianjiao_qichu+zhinajin_qichu+feiyong_yue+zhinajin_benyue);
feiyong_yue_benyue:=feiyong_yingjiao-int(feiyong_yingjiao);
feiyong_yingjiao:=int(feiyong_yingjiao);
edit7.Text:=floattostr(feiyong_yingjiao);
edit12.Text:=floattostr(feiyong_yue_benyue);

end;


procedure TForm25.FormActivate(Sender: TObject);
begin
bitbtn1.Enabled:=false;
bitbtn3.Enabled:=false;
edit16.Text:=formatdatetime('yyyymmdd',date);
edit17.Text:='0001';
edit17.SetFocus;
end;

procedure TForm25.Edit5Exit(Sender: TObject);
begin
if trim(edit5.Text)='' then
begin
Application.Messagebox('±¾ÔÂʵ½»·ÑÓò»ÄÜΪ¿Õ£¡ÇëÊäÈë±¾ÔÂʵ½»·ÑÓá£','Ìáʾ',MB_OK);
edit5.setfocus;
end
else
edit8.setfocus;
end;

procedure TForm25.Edit5KeyPress(Sender: TObject; var Key: Char);
begin
//feiyong_shijiao:=strtofloat(trim(edit5.Text));
if not(Key in['0'..'9',#8,#13])then
begin
Key:=#0;
end
else
if(key=#13)then
begin
if trim(Edit5.Text)=''then
begin
Application.Messagebox('ÇëÊäÈë±¾ÔÂʵ½»·ÑÓÃ!','Ìáʾ',MB_OK);
Edit5.Text:='';
Edit5.SetFocus;
end
else
feiyong_shijiao:=strtofloat(trim(edit5.Text));
feiyong_yujiao_zhuanchu:=feiyong_yingjiao-feiyong_shijiao;
edit9.Text:=floattostr(feiyong_yujiao_zhuanchu);
edit8.setfocus;

end;
end;

procedure TForm25.Edit9Exit(Sender: TObject);
begin
if trim(edit9.Text)='' then
begin
Application.Messagebox('±¾ÔÂÔ¤½»·ÑÓÃת³ö½ð¶î²»ÄÜΪ¿Õ£¡ÇëÊäÈë±¾ÔÂÔ¤½»·ÑÓÃת³ö½ð¶î¡£','Ìáʾ',MB_OK);
edit9.setfocus;
end
else
combobox1.setfocus;
end;

procedure TForm25.Edit9KeyPress(Sender: TObject; var Key: Char);
begin
if not(Key in['0'..'9',#8,'.',#13])then
begin
Key:=#0;
end
else
if(key=#13)then
begin
combobox1.SetFocus;
if trim(Edit9.Text)=''then
begin
Application.Messagebox('ÇëÊäÈë±¾ÔÂÔ¤½»·ÑÓÃת³ö½ð¶î!','Ìáʾ',MB_OK);
Edit9.Text:='';
Edit9.SetFocus;
end
else
begin
feiyong_yujiao:=strtofloat(trim(edit8.Text));
feiyong_qianjiao_yuemo:=feiyong_yingjiao+feiyong_yue_benyue-feiyong_shijiao-feiyong_yujiao_zhuanchu;
edit11.Text:=floattostr(feiyong_qianjiao_yuemo);
combobox1.SetFocus;
end;

if feiyong_yujiao_zhuanchu>(feiyong_yujiao_qichu+feiyong_yujiao) then
begin
Application.Messagebox('±¾ÔÂÔ¤½»·ÑÓÃת³ö½ð¶î²»ÄÜ´óÓÚÔ¤½»·ÑÓÃÔ³õÓà¶îÓë±¾ÔÂÔ¤½»·ÑÓÃÖ®ºÍ,ÇëÖØÐÂÊäÈë±¾ÔÂÔ¤½»·ÑÓûòÕß±¾ÔÂÔ¤½»·ÑÓÃת³ö½ð¶î!','¾¯¸æ',MB_OK);
edit10.Text:='';
Edit8.SetFocus;
end
else
begin
feiyong_yujiao_qimo:=feiyong_yujiao_qichu+feiyong_yujiao-feiyong_yujiao_zhuanchu;
edit10.Text:=floattostr(feiyong_yujiao_qimo);
combobox1.setfocus;
end;
end;


if feiyong_shijiao+feiyong_yujiao_zhuanchu<>feiyong_yingjiao then
begin
Application.Messagebox('±¾ÔÂÔ¤½»·ÑÓÃת³ö½ð¶îÓë±¾ÔÂʵ½»·ÑÓÃÖ®ºÍ±ØÐëµÈÓÚ±¾ÔÂÓ¦½»·ÑÓÃ,ÇëÖØÐÂÊäÈë±¾ÔÂʵ½»·ÑÓûòÕß±¾ÔÂÔ¤½»·ÑÓÃת³ö½ð¶î!','¾¯¸æ',MB_OK);
Edit5.SetFocus;
end
else
combobox1.setfocus;

end;

procedure TForm25.Edit8Exit(Sender: TObject);
begin
if trim(edit8.Text)='' then
begin
Application.Messagebox('±¾ÔÂÔ¤½»·ÑÓò»ÄÜΪ¿Õ£¡ÇëÊäÈë±¾ÔÂÔ¤½»·ÑÓá£','Ìáʾ',MB_OK);
edit8.setfocus;
end
else
edit9.setfocus;
end;

procedure TForm25.Edit8KeyPress(Sender: TObject; var Key: Char);
begin
if not(Key in['0'..'9',#8,'.',#13])then
begin
Key:=#0;
end
else
if(key=#13)then
begin
if trim(Edit8.Text)=''then
begin
Application.Messagebox('ÇëÊäÈë±¾ÔÂÔ¤½»·ÑÓÃ!','Ìáʾ',MB_OK);
Edit8.Text:='';
Edit8.SetFocus;
end
else
edit9.SetFocus;
end;
end;

procedure TForm25.DateTimePicker1KeyPress(Sender: TObject; var Key: Char);
begin
if (key=#13) then
begin
jiaofei_date:=datetostr(date);
edit13.Text:=jiaofei_date;
edit3.SetFocus;
end;
end;

procedure TForm25.ComboBox1CloseUp(Sender: TObject);
begin
bitbtn1.Enabled:=true;
bitbtn3.Enabled:=true;
end;

procedure TForm25.Edit17KeyPress(Sender: TObject; var Key: Char);
begin
if not(Key in['0'..'9',#8,#13])then
begin
Key:=#0;
end
else
if(key=#13)then
begin
if trim(Edit17.Text)=''then
begin
Application.Messagebox('ÇëÊäÈë½»·Ñ±àºÅ!','Ìáʾ',MB_OK);
Edit17.Text:='';
Edit17.SetFocus;
end
else
edit1.SetFocus;
end;
end;

procedure TForm25.Edit17Exit(Sender: TObject);
begin
if trim(edit17.Text)='' then
begin
Application.Messagebox('½»·Ñ±àºÅ²»ÄÜΪ¿Õ£¡ÇëÊäÈë½»·Ñ±àºÅ¡£','Ìáʾ',MB_OK);
edit17.setfocus;
end
else
edit1.setfocus;
end;

procedure TForm25.BitBtn1Click(Sender: TObject);
begin
jiaofei_num:=edit16.Text+edit17.text;
jiaofei:=combobox1.Text;
feiyong_yingjiao_date:=datetostr(datetimepicker1.Date);
house_num:=trim(edit1.Text);
dianfei_yingjiao:=dianbiao_benyue*dianfei_price;
shuifei_yingjiao:=yongshui_benyue*shuifei_price;
with datamodule1.ADOQuery_add_jiaofei do
begin
close;
sql.Clear;
sql.Add('insert into pay_feiyong(jiaofei_num,house_num,man_name,jiaofei_shiqi,feiyong_yingjiao,feiyong_shijiao,feiyong_yue,feiyong_yujiao,feiyong_yujiao_qichu,feiyong_yujiao_zhuanchu,feiyong_yujiao_qimo,');
sql.Add('feiyong_qianjiao_qichu,feiyong_qianjiao,zhinajin_qichu,zhinajin_benyue,zhinajin_yuemo,jiaofei,');
sql.Add('feiyong_yingjiao_date,jiaofei_date,shuibiao_yuechu,shuibiao_yuemo,shuibiao_benyue,shuifei_yingjiao,rent_yingjiao,wgf_yingjiao,dianbiao_yuechu,dianbiao_yuemo,dianbiao_benyue,dianfei_yingjiao)');
sql.Add('values('''+jiaofei_num+''','''+house_num+''','''+man_name+''','''+jiaofei_month+''','''+floattostr(feiyong_yingjiao)+''','''+floattostr(feiyong_shijiao)+''','''+floattostr(feiyong_yue_benyue)+''','''+floattostr(feiyong_yujiao)+''','''+floattostr(feiyong_yujiao_qichu)+''','''+floattostr(feiyong_yujiao_zhuanchu)+''','''+floattostr(feiyong_yujiao_qimo)+''','''+floattostr(feiyong_qianjiao_qichu)+''','''+floattostr(feiyong_qianjiao_yuemo)+''','''+floattostr(zhinajin_qichu)+''','''+floattostr(zhinajin_benyue)+''','''+floattostr(zhinajin_yuemo)+''','''+jiaofei+''''''+feiyong_yingjiao_date+''','''+jiaofei_date+''','''+floattostr(shuibiao_qichu)+''','''+floattostr(shuibiao_qimo)+''','''+floattostr(yongshui_benyue)+''','''+floattostr(shuifei_yingjiao)+''','''+floattostr(rent_yingjiao)+''','''+floattostr(wgf_yingjiao)+''','''+floattostr(dianbiao_qichu)+''','''+floattostr(dianbiao_qimo)+''','''+floattostr(dianbiao_benyue)+''','''+floattostr(dianfei_yingjiao)+''')');
execsql;
end;

end;

end.
 
当以下程序执行按下BITBTN1按钮时出错出错信息为:“[Microsoft][ODBC Microsoft Access Driver]查询值的数目与目标字段中的数目不同”。请问是怎么回事?
另外 house_num、man_的值都为空,是什么原因?
该程序用DELPHI6+ACCESS2000+ADO实现.

以下是源代码:
unit shuidianfei_input;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Mask, ComCtrls, DBCtrls, Buttons;

type
TForm25 = class(TForm)
Label1: TLabel;
Label3: TLabel;
Edit1: TEdit;
Label9: TLabel;
Edit3: TEdit;
Label12: TLabel;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
Label19: TLabel;
Edit6: TEdit;
Edit7: TEdit;
Label4: TLabel;
DBEdit1: TDBEdit;
Label2: TLabel;
DBEdit2: TDBEdit;
Label5: TLabel;
DBEdit3: TDBEdit;
Label6: TLabel;
DBEdit4: TDBEdit;
Label7: TLabel;
DBEdit5: TDBEdit;
Label8: TLabel;
Edit2: TEdit;
Label10: TLabel;
DBEdit6: TDBEdit;
Label11: TLabel;
Edit4: TEdit;
Label13: TLabel;
Edit5: TEdit;
Label14: TLabel;
Label15: TLabel;
DBEdit7: TDBEdit;
Label16: TLabel;
Label17: TLabel;
Edit8: TEdit;
Label18: TLabel;
Label20: TLabel;
Edit9: TEdit;
Label21: TLabel;
Label22: TLabel;
Edit10: TEdit;
Label23: TLabel;
Label24: TLabel;
Edit11: TEdit;
Label25: TLabel;
Edit12: TEdit;
Label26: TLabel;
Label27: TLabel;
DBEdit8: TDBEdit;
Label30: TLabel;
Label31: TLabel;
Edit14: TEdit;
Label32: TLabel;
ComboBox1: TComboBox;
Label33: TLabel;
Label34: TLabel;
DateTimePicker1: TDateTimePicker;
Label35: TLabel;
BitBtn3: TBitBtn;
Label36: TLabel;
Label37: TLabel;
DBEdit9: TDBEdit;
Edit15: TEdit;
Edit13: TEdit;
Edit17: TEdit;
Edit16: TEdit;
Label28: TLabel;
procedure Edit1Exit(Sender: TObject);
procedure Edit3Exit(Sender: TObject);
procedure Edit6Exit(Sender: TObject);
procedure Edit1KeyPress(Sender: TObject; var Key: Char);
procedure Edit3KeyPress(Sender: TObject; var Key: Char);
procedure Edit6KeyPress(Sender: TObject; var Key: Char);
procedure FormActivate(Sender: TObject);
procedure Edit5Exit(Sender: TObject);
procedure Edit5KeyPress(Sender: TObject; var Key: Char);
procedure Edit9Exit(Sender: TObject);
procedure Edit9KeyPress(Sender: TObject; var Key: Char);
procedure Edit8Exit(Sender: TObject);
procedure Edit8KeyPress(Sender: TObject; var Key: Char);
procedure DateTimePicker1KeyPress(Sender: TObject; var Key: Char);
procedure ComboBox1CloseUp(Sender: TObject);
procedure Edit17KeyPress(Sender: TObject; var Key: Char);
procedure Edit17Exit(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form25: TForm25;
s1,s2,s3,s4,s5,s6,s7,s8,s9:string;

jiaofei_num:string;
jiaofei_month:string;

house_num:string;
man_name:string;
house_type:string;
louhao:string;
fanghao:string;
dianbiao_qichu:integer;
dianbiao_qimo:integer;
dianbiao_benyue:real;
shuibiao_qichu:integer;
shuibiao_qimo:integer;
yongshui_benyue:integer;
feiyong_yingjiao:real;
feiyong_shijiao:real;
feiyong_yujiao_qichu:real;
feiyong_yujiao:real;
feiyong_yujiao_zhuanchu:real;
feiyong_yujiao_qimo:real;
feiyong_yue:real;
feiyong_qianjiao_yuemo:real;
jiaofei:string;
feiyong_yingjiao_date:string;
jiaofei_date:string;
dianfei_price:real;
shuifei_price:real;
dianbiao_yuechu:real;
shuifei_yingjiao:real;
dianfei_yingjiao:real;
wgf_yingjiao:real;
rent_yingjiao:real;
//qunuanfei_yue:real;
feiyong_qianjiao_qichu:real;
zhinajin_qichu:real;
feiyong_yue_benyue:real;
zhinajin_benyue:real;
zhinajin_yuemo:real;
zhinajin_bilv:real;
implementation

uses Unit1, dianfei_price_add;

{$R *.dfm}

procedure TForm25.Edit1Exit(Sender: TObject);
begin
if trim(edit1.Text)='' then
begin
Application.Messagebox('·¿ÎݱàºÅ²»ÄÜΪ¿Õ£¡ÇëÊäÈë·¿ÎݱàºÅ¡£','Ìáʾ',MB_OK);
edit1.setfocus;
end
else
datetimepicker1.SetFocus;
end;

procedure TForm25.Edit3Exit(Sender: TObject);
begin
if trim(edit3.Text)='' then
begin
Application.Messagebox('µç±íÆÚÄ©Êý²»ÄÜΪ¿Õ£¡ÇëÊäÈëµç±íÆÚÄ©Êý¡£','Ìáʾ',MB_OK);
edit3.setfocus;
end
else
edit6.SetFocus;
end;

procedure TForm25.Edit6Exit(Sender: TObject);
begin
if trim(edit6.Text)='' then
begin
Application.Messagebox('±¾ÔÂÓÃË®Êý²»ÄÜΪ¿Õ£¡ÇëÊäÈë±¾ÔÂÓÃË®Êý¡£','Ìáʾ',MB_OK);
edit6.setfocus;
end;

end;

procedure TForm25.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
if(Key=#13)then
begin
jiaofei_month:=formatdatetime('yyyy-mm',incmonth(date,-1));
edit15.Text:=jiaofei_month;
datetimepicker1.setfocus;
end;
with datamodule1.ADOQuery13 do
begin
close;
sql.Clear;
sql.Add('select * from house where house_num='''+edit1.Text+'''');
open;
end;
begin
s1:=datamodule1.ADOQuery13.Fields.Fields[2].AsString;
man_name:=dbedit1.Text;
s2:=datamodule1.ADOQuery13.Fields.Fields[6].AsString;
s2:=house_type;
s3:=datamodule1.ADOQuery13.Fields.Fields[4].AsString;
s3:=louhao;
s4:=datamodule1.ADOQuery13.Fields.Fields[5].AsString;
s4:=fanghao;
end;
with datamodule1.ADOQuery2 do
begin
close;
sql.Clear;
sql.Add('select * from pay_feiyong_qichu where house_num='''+edit1.Text+'''');
open;
end;
begin
dianbiao_qichu:=datamodule1.ADOQuery2.Fields.Fields[7].AsInteger;
dbedit5.Text:=inttostr(dianbiao_qichu);

shuibiao_qichu:=datamodule1.ADOQuery2.Fields.Fields[6].AsInteger;
dbedit6.Text:=inttostr(shuibiao_qichu);

feiyong_qianjiao_qichu:=datamodule1.ADOQuery2.Fields.Fields[4].AsFloat;
dbedit9.Text:=floattostr(feiyong_qianjiao_qichu);

zhinajin_qichu:=datamodule1.ADOQuery2.Fields.Fields[5].AsFloat;

feiyong_yue:=datamodule1.ADOQuery2.Fields.Fields[2].AsFloat;

feiyong_yujiao_qichu:=datamodule1.ADOQuery2.Fields.Fields[3].AsFloat;
dbedit7.Text:=floattostr(feiyong_yujiao_qichu);

zhinajin_qichu:= datamodule1.ADOQuery2.Fields.Fields[5].asFloat;
dbedit8.Text:=formatfloat('0.00',zhinajin_qichu);

end;
end;

procedure TForm25.Edit3KeyPress(Sender: TObject; var Key: Char);
begin
if not(Key in['0'..'9',#8,#13])then
begin
Key:=#0;
end
else
if(key=#13)then
begin
if trim(Edit3.Text)=''then
begin
Application.Messagebox('ÇëÊäÈëµç±íÆÚÄ©Êý!','Ìáʾ',MB_OK);
Edit3.Text:='';
Edit3.SetFocus;
end
else
begin
dianbiao_qimo:=strtoint(trim(edit3.Text))+2;
edit3.Text:=inttostr(dianbiao_qimo);

dianbiao_benyue:=(dianbiao_qimo-dianbiao_qichu);
edit2.Text:=floattostr(dianbiao_benyue);
Edit6.SetFocus;
end;
end;
end;
procedure TForm25.Edit6KeyPress(Sender: TObject; var Key: Char);
begin
if not(Key in['0'..'9',#8,#13]) then
begin
Key:=#0;
end;
//else
if(key=#13)then
begin
if trim(Edit6.Text)='' then
begin
Application.Messagebox('ÇëÊäÈë±¾ÔÂÓÃË®Êý!','Ìáʾ',MB_OK);
Edit6.Text:='';
Edit6.SetFocus;
end
else
begin
yongshui_benyue:=strtoint(trim(edit6.Text));
shuibiao_qimo:=shuibiao_qichu+yongshui_benyue;
edit4.Text:=inttostr(shuibiao_qimo);
with datamodule1.ADOQuery_add_price do
begin
close;
sql.Clear;
sql.Add('select * from price');
open;
end;
begin
s5:=datamodule1.ADOQuery_add_price.Fields.Fields[0].AsString;
s6:=datamodule1.ADOQuery_add_price.Fields.Fields[1].AsString;
s7:=datamodule1.ADOQuery_add_price.Fields.Fields[3].AsString;
s8:=datamodule1.ADOQuery_add_price.Fields.Fields[4].AsString;
s9:=datamodule1.ADOQuery_add_price.Fields.Fields[5].AsString;
dianfei_price:=strtofloat(s5);
shuifei_price:=strtofloat(s6);
wgf_yingjiao:=strtofloat(s7);
zhinajin_bilv:=strtofloat(s9);
if dbedit2.Text<>'LF' then
rent_yingjiao:=strtofloat(s8)
else
begin
rent_yingjiao:=0;
end;
feiyong_yingjiao:=((dianbiao_benyue*dianfei_price)+(yongshui_benyue*shuifei_price)+wgf_yingjiao+rent_yingjiao+feiyong_qianjiao_qichu+zhinajin_qichu+feiyong_yue);
edit12.Text:=floattostr(feiyong_yue_benyue);
edit5.SetFocus;
end;

end;
end;

if (datetimepicker1.Date-strtodate(jiaofei_date))>=0 then
begin
zhinajin_benyue:=0;
zhinajin_yuemo:=0;
edit14.Text:=floattostr(zhinajin_yuemo);
end
else
begin
zhinajin_benyue:=((strtodate(jiaofei_date)-datetimepicker1.Date)*zhinajin_bilv*feiyong_yingjiao);
zhinajin_yuemo:=0;
edit14.Text:=floattostr(zhinajin_yuemo);

end;
feiyong_yingjiao:=((dianbiao_benyue*dianfei_price)+(yongshui_benyue*shuifei_price)+wgf_yingjiao+rent_yingjiao+feiyong_qianjiao_qichu+zhinajin_qichu+feiyong_yue+zhinajin_benyue);
feiyong_yue_benyue:=feiyong_yingjiao-int(feiyong_yingjiao);
feiyong_yingjiao:=int(feiyong_yingjiao);
edit7.Text:=floattostr(feiyong_yingjiao);
edit12.Text:=floattostr(feiyong_yue_benyue);

end;


procedure TForm25.FormActivate(Sender: TObject);
begin
bitbtn1.Enabled:=false;
bitbtn3.Enabled:=false;
edit16.Text:=formatdatetime('yyyymmdd',date);
edit17.Text:='0001';
edit17.SetFocus;
end;

procedure TForm25.Edit5Exit(Sender: TObject);
begin
if trim(edit5.Text)='' then
begin
Application.Messagebox('±¾ÔÂʵ½»·ÑÓò»ÄÜΪ¿Õ£¡ÇëÊäÈë±¾ÔÂʵ½»·ÑÓá£','Ìáʾ',MB_OK);
edit5.setfocus;
end
else
edit8.setfocus;
end;

procedure TForm25.Edit5KeyPress(Sender: TObject; var Key: Char);
begin
//feiyong_shijiao:=strtofloat(trim(edit5.Text));
if not(Key in['0'..'9',#8,#13])then
begin
Key:=#0;
end
else
if(key=#13)then
begin
if trim(Edit5.Text)=''then
begin
Application.Messagebox('ÇëÊäÈë±¾ÔÂʵ½»·ÑÓÃ!','Ìáʾ',MB_OK);
Edit5.Text:='';
Edit5.SetFocus;
end
else
feiyong_shijiao:=strtofloat(trim(edit5.Text));
feiyong_yujiao_zhuanchu:=feiyong_yingjiao-feiyong_shijiao;
edit9.Text:=floattostr(feiyong_yujiao_zhuanchu);
edit8.setfocus;

end;
end;

procedure TForm25.Edit9Exit(Sender: TObject);
begin
if trim(edit9.Text)='' then
begin
Application.Messagebox('±¾ÔÂÔ¤½»·ÑÓÃת³ö½ð¶î²»ÄÜΪ¿Õ£¡ÇëÊäÈë±¾ÔÂÔ¤½»·ÑÓÃת³ö½ð¶î¡£','Ìáʾ',MB_OK);
edit9.setfocus;
end
else
combobox1.setfocus;
end;

procedure TForm25.Edit9KeyPress(Sender: TObject; var Key: Char);
begin
if not(Key in['0'..'9',#8,'.',#13])then
begin
Key:=#0;
end
else
if(key=#13)then
begin
combobox1.SetFocus;
if trim(Edit9.Text)=''then
begin
Application.Messagebox('ÇëÊäÈë±¾ÔÂÔ¤½»·ÑÓÃת³ö½ð¶î!','Ìáʾ',MB_OK);
Edit9.Text:='';
Edit9.SetFocus;
end
else
begin
feiyong_yujiao:=strtofloat(trim(edit8.Text));
feiyong_qianjiao_yuemo:=feiyong_yingjiao+feiyong_yue_benyue-feiyong_shijiao-feiyong_yujiao_zhuanchu;
edit11.Text:=floattostr(feiyong_qianjiao_yuemo);
combobox1.SetFocus;
end;

if feiyong_yujiao_zhuanchu>(feiyong_yujiao_qichu+feiyong_yujiao) then
begin
Application.Messagebox('±¾ÔÂÔ¤½»·ÑÓÃת³ö½ð¶î²»ÄÜ´óÓÚÔ¤½»·ÑÓÃÔ³õÓà¶îÓë±¾ÔÂÔ¤½»·ÑÓÃÖ®ºÍ,ÇëÖØÐÂÊäÈë±¾ÔÂÔ¤½»·ÑÓûòÕß±¾ÔÂÔ¤½»·ÑÓÃת³ö½ð¶î!','¾¯¸æ',MB_OK);
edit10.Text:='';
Edit8.SetFocus;
end
else
begin
feiyong_yujiao_qimo:=feiyong_yujiao_qichu+feiyong_yujiao-feiyong_yujiao_zhuanchu;
edit10.Text:=floattostr(feiyong_yujiao_qimo);
combobox1.setfocus;
end;
end;


if feiyong_shijiao+feiyong_yujiao_zhuanchu<>feiyong_yingjiao then
begin
Application.Messagebox('±¾ÔÂÔ¤½»·ÑÓÃת³ö½ð¶îÓë±¾ÔÂʵ½»·ÑÓÃÖ®ºÍ±ØÐëµÈÓÚ±¾ÔÂÓ¦½»·ÑÓÃ,ÇëÖØÐÂÊäÈë±¾ÔÂʵ½»·ÑÓûòÕß±¾ÔÂÔ¤½»·ÑÓÃת³ö½ð¶î!','¾¯¸æ',MB_OK);
Edit5.SetFocus;
end
else
combobox1.setfocus;

end;

procedure TForm25.Edit8Exit(Sender: TObject);
begin
if trim(edit8.Text)='' then
begin
Application.Messagebox('±¾ÔÂÔ¤½»·ÑÓò»ÄÜΪ¿Õ£¡ÇëÊäÈë±¾ÔÂÔ¤½»·ÑÓá£','Ìáʾ',MB_OK);
edit8.setfocus;
end
else
edit9.setfocus;
end;

procedure TForm25.Edit8KeyPress(Sender: TObject; var Key: Char);
begin
if not(Key in['0'..'9',#8,'.',#13])then
begin
Key:=#0;
end
else
if(key=#13)then
begin
if trim(Edit8.Text)=''then
begin
Application.Messagebox('ÇëÊäÈë±¾ÔÂÔ¤½»·ÑÓÃ!','Ìáʾ',MB_OK);
Edit8.Text:='';
Edit8.SetFocus;
end
else
edit9.SetFocus;
end;
end;

procedure TForm25.DateTimePicker1KeyPress(Sender: TObject; var Key: Char);
begin
if (key=#13) then
begin
jiaofei_date:=datetostr(date);
edit13.Text:=jiaofei_date;
edit3.SetFocus;
end;
end;

procedure TForm25.ComboBox1CloseUp(Sender: TObject);
begin
bitbtn1.Enabled:=true;
bitbtn3.Enabled:=true;
end;

procedure TForm25.Edit17KeyPress(Sender: TObject; var Key: Char);
begin
if not(Key in['0'..'9',#8,#13])then
begin
Key:=#0;
end
else
if(key=#13)then
begin
if trim(Edit17.Text)=''then
begin
Application.Messagebox('ÇëÊäÈë½»·Ñ±àºÅ!','Ìáʾ',MB_OK);
Edit17.Text:='';
Edit17.SetFocus;
end
else
edit1.SetFocus;
end;
end;

procedure TForm25.Edit17Exit(Sender: TObject);
begin
if trim(edit17.Text)='' then
begin
Application.Messagebox('½»·Ñ±àºÅ²»ÄÜΪ¿Õ£¡ÇëÊäÈë½»·Ñ±àºÅ¡£','Ìáʾ',MB_OK);
edit17.setfocus;
end
else
edit1.setfocus;
end;

procedure TForm25.BitBtn1Click(Sender: TObject);
begin
jiaofei_num:=edit16.Text+edit17.text;
jiaofei:=combobox1.Text;
feiyong_yingjiao_date:=datetostr(datetimepicker1.Date);
house_num:=trim(edit1.Text);
dianfei_yingjiao:=dianbiao_benyue*dianfei_price;
shuifei_yingjiao:=yongshui_benyue*shuifei_price;
with datamodule1.ADOQuery_add_jiaofei do
begin
close;
sql.Clear;
sql.Add('insert into pay_feiyong(jiaofei_num,house_num,man_name,jiaofei_shiqi,feiyong_yingjiao,feiyong_shijiao,feiyong_yue,feiyong_yujiao,feiyong_yujiao_qichu,feiyong_yujiao_zhuanchu,feiyong_yujiao_qimo,');
sql.Add('feiyong_qianjiao_qichu,feiyong_qianjiao,zhinajin_qichu,zhinajin_benyue,zhinajin_yuemo,jiaofei,');
sql.Add('feiyong_yingjiao_date,jiaofei_date,shuibiao_yuechu,shuibiao_yuemo,shuibiao_benyue,shuifei_yingjiao,rent_yingjiao,wgf_yingjiao,dianbiao_yuechu,dianbiao_yuemo,dianbiao_benyue,dianfei_yingjiao)');
sql.Add('values('''+jiaofei_num+''','''+house_num+''','''+man_name+''','''+jiaofei_month+''','''+floattostr(feiyong_yingjiao)+''','''+floattostr(feiyong_shijiao)+''','''+floattostr(feiyong_yue_benyue)+''','''+floattostr(feiyong_yujiao)+''','''+floattostr(feiyong_yujiao_qichu)+''','''+floattostr(feiyong_yujiao_zhuanchu)+''','''+floattostr(feiyong_yujiao_qimo)+''','''+floattostr(feiyong_qianjiao_qichu)+''','''+floattostr(feiyong_qianjiao_yuemo)+''','''+floattostr(zhinajin_qichu)+''','''+floattostr(zhinajin_benyue)+''','''+floattostr(zhinajin_yuemo)+''','''+jiaofei+''''''+feiyong_yingjiao_date+''','''+jiaofei_date+''','''+floattostr(shuibiao_qichu)+''','''+floattostr(shuibiao_qimo)+''','''+floattostr(yongshui_benyue)+''','''+floattostr(shuifei_yingjiao)+''','''+floattostr(rent_yingjiao)+''','''+floattostr(wgf_yingjiao)+''','''+floattostr(dianbiao_qichu)+''','''+floattostr(dianbiao_qimo)+''','''+floattostr(dianbiao_benyue)+''','''+floattostr(dianfei_yingjiao)+''')');
execsql;
end;

end;

end.
 
估计是插入的字段数目与values的数目不一样吧,太长了,看了点眼睛就花了
 
插入的字段数目与values的数目一样!
 
sql语句的问题。调试查看sql变量值后在access中直接执行sql语句查看问题所在
 
skyblue7080:
请问如何在ACCESS2000中直接执行sql语句查看问题所在?
 
这个SQL在ACCESS中的查询里生成一个和你的SQL语句一样的查询,再执行一下看,先确定你的SQL是没有问题的先
 
先用一个字段测试,看是代码还是SQL语句还是什么的问题吧
 
sql.Clear;
sql.Add('insert into pay_feiyong(jiaofei_num,house_num,man_name,jiaofei_shiqi,feiyong_yingjiao,feiyong_shijiao,feiyong_yue,feiyong_yujiao,feiyong_yujiao_qichu,feiyong_yujiao_zhuanchu,feiyong_yujiao_qimo,');
sql.Add('feiyong_qianjiao_qichu,feiyong_qianjiao,zhinajin_qichu,zhinajin_benyue,zhinajin_yuemo,jiaofei,');
sql.Add('feiyong_yingjiao_date,jiaofei_date,shuibiao_yuechu,shuibiao_yuemo,shuibiao_benyue,shuifei_yingjiao,rent_yingjiao,wgf_yingjiao,dianbiao_yuechu,dianbiao_yuemo,dianbiao_benyue,dianfei_yingjiao)');
sql.Add('values('''+jiaofei_num+''','''+house_num+''','''+man_name+''','''+jiaofei_month+''','''+floattostr(feiyong_yingjiao)+''','''+floattostr(feiyong_shijiao)+''','''+floattostr(feiyong_yue_benyue)+''','''+floattostr(feiyong_yujiao)+''','''+floattostr(feiyong_yujiao_qichu)+''','''+floattostr(feiyong_yujiao_zhuanchu)+''','''+floattostr(feiyong_yujiao_qimo)+''','''+floattostr(feiyong_qianjiao_qichu)+''','''+floattostr(feiyong_qianjiao_yuemo)+''','''+floattostr(zhinajin_qichu)+''','''+floattostr(zhinajin_benyue)+''','''+floattostr(zhinajin_yuemo)+''','''+jiaofei+''''''+feiyong_yingjiao_date+''','''+jiaofei_date+''','''+floattostr(shuibiao_qichu)+''','''+floattostr(shuibiao_qimo)+''','''+floattostr(yongshui_benyue)+''','''+floattostr(shuifei_yingjiao)+''','''+floattostr(rent_yingjiao)+''','''+floattostr(wgf_yingjiao)+''','''+floattostr(dianbiao_qichu)+''','''+floattostr(dianbiao_qimo)+''','''+floattostr(dianbiao_benyue)+''','''+floattostr(dianfei_yingjiao)+''')');

[blue]在这里把sql.text取出来,放到你的对应数据库环境里面调试下就知道了,目前大家也不清楚你的表结构,不好定,问题可能是因为你的values前后个数不一致[/blue]

execsql;
end;

end;
 
多人接受答案了。
 
后退
顶部