求数据表录入信息代码...............(100分)

  • 主题发起人 mytree520
  • 开始时间
M

mytree520

Unregistered / Unconfirmed
GUEST, unregistred user!
有如下一张表:<br>字段含义 列名 数据类型 长度 允许空<br>部门名称 BM_Name Char 16 <br>职工姓名 ZG_Name Char 8 <br>基本工资 GZ _Name Numeric 5,2 √<br>职务工资 GZ_Sex Numeric 5,2 √<br>住房补贴 GZ_ZFBT Numeric 5,2 √<br>交通补贴 GZ_SDBT Numeric 5,2 √<br>本月奖金 GZ_BYJJ Numeric 5,2 √<br>其它应发款 GZ_QTYF Numeric 5,2 √<br>应发款合计 GZ_YFHJ Numeric 5,2 √<br>水电费 GZ_SDF Numeric 5,2 √<br>煤气费 GZ_MQF Numeric 5,2 √<br>房租 GZ_FZ Numeric 5,2 √<br>个人所得税 GZ_GRSDS Numeric 5,2 √<br>其它应扣款 GZ_QTYK Numeric 5,2 √<br>应扣款合计 GZ_YKHJ Numeric 5,2 √<br>实际发放 GZ_SJFF Numeric 5,2 √<br>说明:个人所得税=(Σ收入项-1600)*8%<br>做一动态的录入功能.按一般的表偶可以搞定,但不知道为什么.因这张表中有&quot;应发款合计&quot;,<br>&quot;应扣款合计&quot;,和&quot;实际发放&quot;这三列需用到计算.所以小弟按无计算的做法做老出错.哪位<br>大哥帮个忙搞一下啊................偶的原代码如下<br>procedure TForm31.Button1Click(Sender: TObject);<br>var<br> &nbsp;str1,str2,str3,str4,str5,str6,str7,<br> &nbsp;str8,str10,str11,str12,str14:string;<br> &nbsp;str9,str13,str15,str16:real;<br>begin<br> &nbsp; &nbsp;str1:=combobox1.Text;<br> &nbsp; &nbsp;str2:=combobox2.Text;<br> &nbsp; &nbsp;str3:=edit1.Text;<br> &nbsp; &nbsp;str4:=edit2.Text;<br> &nbsp; &nbsp;str5:=edit3.Text;<br> &nbsp; &nbsp;str6:=edit4.Text;<br> &nbsp; &nbsp;str7:=edit5.Text;<br> &nbsp; &nbsp;str8:=edit6.Text;<br> &nbsp; &nbsp;str9:=strtofloat(str3+str4+str5+str6+str7+str8);<br> &nbsp; &nbsp;str10:=edit7.Text;<br> &nbsp; &nbsp;str11:=edit8.Text;<br> &nbsp; &nbsp;str12:=edit9.Text;<br><br> &nbsp; &nbsp;str14:=edit10.Text;<br> &nbsp; &nbsp;str15:=strtofloat(str10+str11+str12+str14)+str13;<br> &nbsp; &nbsp;str16:=str9-str15;<br> &nbsp; &nbsp;if str9&gt;1600 then<br> &nbsp; &nbsp;begin<br> &nbsp; &nbsp;str13:=(str9-1600)*0.08;<br> &nbsp; &nbsp;end<br> &nbsp; &nbsp;else<br> &nbsp; &nbsp; str13:=0;<br> &nbsp; &nbsp;with query1 do<br> &nbsp; &nbsp;begin<br> &nbsp; &nbsp; &nbsp;close;<br> &nbsp; &nbsp; &nbsp;sql.Clear;<br> &nbsp; &nbsp; &nbsp;sql.Add('insert into GZ');<br> &nbsp; &nbsp; &nbsp;sql.Add('values:)str1,:str2,:str3,:str4,:str5,:str6,:str7,:str8,:str9,:str10,:str11,:str12,:str13,:str14,:str15,:str16)');<br> &nbsp; &nbsp; &nbsp;parambyname('str1').AsString:=str1;<br> &nbsp; &nbsp; &nbsp;parambyname('str2').AsString:=str2;<br> &nbsp; &nbsp; &nbsp;parambyname('str3').AsString:=str3;<br> &nbsp; &nbsp; &nbsp;parambyname('str4').AsString:=str4;<br> &nbsp; &nbsp; &nbsp;parambyname('str5').AsString:=str5;<br> &nbsp; &nbsp; &nbsp;parambyname('str6').AsString:=str6;<br> &nbsp; &nbsp; &nbsp;parambyname('str7').AsString:=str7;<br> &nbsp; &nbsp; &nbsp;parambyname('str8').AsString:=str8;<br> &nbsp; &nbsp; &nbsp;parambyname('str9').AsString:=floattostr(str9);<br> &nbsp; &nbsp; &nbsp;parambyname('str10').AsString:=str10;<br> &nbsp; &nbsp; &nbsp;parambyname('str11').AsString:=str11;<br> &nbsp; &nbsp; &nbsp;parambyname('str12').AsString:=str12;<br> &nbsp; &nbsp; &nbsp;parambyname('str13').AsString:=floattostr(str13);<br> &nbsp; &nbsp; &nbsp;parambyname('str14').AsString:=str14;<br> &nbsp; &nbsp; &nbsp;parambyname('str15').AsString:=floattostr(str15);<br> &nbsp; &nbsp; &nbsp;parambyname('str16').AsString:=floattostr(str16);<br> &nbsp; &nbsp; &nbsp;sql.Add('select * from GZ');<br> &nbsp; &nbsp; prepare;<br> &nbsp; &nbsp; open;<br> &nbsp; end;<br>end;
 
最近做课设也有这样的问题,学习中.帮顶一下................
 
错误:str9:=strtofloat(str3+str4+str5+str6+str7+str8)中的str3+str4+str5+str6+str7+str8全部都是字符型,如何参与数学运算,改为:<br>str9 := FloatToStr(StrToFloat(trim(str3))+StrToFloat(trim(str4))+StrToFloat(trim(str5))+StrToFloat(trim(str6))+StrToFloat(trim(str7))+StrToFloat(trim(str8)));<br><br>下面那个表达式也是一样的错误。
 
多人接受答案了。
 
顶部