文本如何转换成命令。(GzFf.FieldByName('CalcShouldPay').AsFloat:=aText1)(200分)

  • 主题发起人 主题发起人 LanzeServer
  • 开始时间 开始时间
L

LanzeServer

Unregistered / Unconfirmed
GUEST, unregistred user!
procedure TFrmDt.GzFfCalcFields(DataSet: TDataSet);
var
aText:string; //aText1
i,j:integer;
aText1:variant;
begin
with Query2 do
begin
Close;
SQL.Clear;
SQL.Text:='Select Name,Memo from S_GZ_FA where DepartmentID in (Select ID from D_Department where Name='''+FrmGzFf.RzComboBox3.Text+''')';
Open;
if IsEmpty then
begin
Application.MessageBox('请先设置好工资工式肉容!','提示信息',48);
Abort;
end
else if not IsEmpty then
begin
First;
while Eof=false do
begin
aText:=Fields[1].AsString;
if Fields[0].AsString='应付合计' then
begin
aText1:='';
for i:=1 to Length(aText) do
begin
if Copy(aText,i,1)='(' then
aText1:=aText1+'('
else if Copy(aText,i,1)=')' then
aText1:=aText1+')'
else if Copy(aText,i,1)='+' then
aText1:=aText1+'+'
else if Copy(aText,i,1)='-' then
aText1:=aText1+'-'
else if Copy(aText,i,1)='*' then
aText1:=aText1+'*'
else if Copy(aText,i,1)='/' then
aText1:=aText1+'/';
for j:=0 to FrmGzFf.DBGridEh1.Columns.Count-1 do
if Copy(aText,i,Length(FrmGzFf.DBGridEh1.Columns[j].Title.Caption))=FrmGzFf.DBGridEh1.Columns[j].Title.Caption then
begin
aText1:=aText1+'FrmGzFf.DBGridEh1.DataSource.DataSet.Fields[StrToInt('''+IntTostr(j)+''')].AsFloat';
end;
end;
end;
GzFf.FieldByName('CalcShouldPay').AsFloat:=aText1;
//ShowMessage(aText1);
Next;
end;
end;
end;
 
写清你哪里有问题啊
 
http://delphibbs.com/delphibbs/dispq.asp?lid=1468562
 
如果你能看懂下面的过程,借助查询进行处理:

procedure TForm1.Button1Click(Sender: TObject);
var
x,x2:integer;
s,y:string;
begin
x:=10;
y:='(x-3)*x+x';
y:=stringreplace(y,'x',inttostr(x),[rfReplaceAll]);
s:='select '+y+' as yy from gyppara';
adoquery1.SQL.Add(s);
adoquery1.Open ;
x2:=adoquery1.Fieldbyname('yy').AsInteger ;
showmessage(inttostr(x2));
end;
 

Similar threads

S
回复
0
查看
688
SUNSTONE的Delphi笔记
S
S
回复
0
查看
683
SUNSTONE的Delphi笔记
S
I
回复
0
查看
509
import
I
I
回复
0
查看
630
import
I
后退
顶部