全國最多中醫師線上諮詢網站-台灣中醫網
發文 回覆 瀏覽次數:814
推到 Plurk!
推到 Facebook!

表达式运算的问题?

缺席
sl@cableplus.com.cn
高階會員


發表:168
回覆:359
積分:130
註冊:2004-03-26

發送簡訊給我
#1 引用回覆 回覆 發表時間:2005-04-04 16:46:00 IP:218.80.xxx.xxx 未訂閱
在FORMCREATE中定义   
  FCal := TfrParser.Create;
  FCal.OnGetValue := GetValue;
  FList := TList.Create;
  New(ListPoint); 
  
然后进行表达式计算:
 
function TDmdPayDtlRecord.CalPayTemp: Boolean;
var
  I: Integer;
  P: TBookmark;
begin
  result := False;
  IsAddList := False;
  if QryMaster.Active = False then
    QryMaster.Active := True;
  QryMaster.First;
  QryMaster.Filtered := False;      for I := 1 to QryMaster.RecordCount do
  begin
    if QryMaster.FieldByName('CalcuSign').AsBoolean then //有表达式就进行运算 如:G0005的表达式是G0001*G0002 那就从G0001和G0002得到相乘的积来付给G0005的PAYMENT字段 
    begin
      P := nil;
      try
        P := QryMaster.GetBookmark;
        if QryMaster.State = dsBrowse then QryMaster.Edit;
        QryMaster.FieldByName('PayAmnt').Value :=
          FCal.Calc(QryMaster.FieldByName('Expression').AsString);
      finally
        QryMaster.GotoBookmark(P);
        LocateParamQry;
      end;
      if IsAddList then
      begin
        FList.Add(P);
        IsAddList := False;
      end;
    end;
    QryMaster.Next;
  end;      while FList.Count > 0 do
  begin
    ListNum := FList.Count;
    CalListPro;
    if FList.Count = ListNum then
      Break;
  end;
end;
 
 
procedure TDmdPayDtlRecord.GetValue(const s: string; var v: Variant);
begin
  if QryCalParam.Locate('EmplyNum;PayCode;FiscaYear;AccoPerd',
    VarArrayOf([QryMaster.FieldByName('EmpLyNum').AsString, S,
    QryMaster.FieldByName('FiscaYear').AsString, QryMaster.FieldByName('AccoPerd').AsInteger]),
      [loCaseInsensitive]) then
  begin
    if QryMaster.State = dsBrowse then QryMaster.Edit;        if (QryCalParam.FieldBYName('CalcuSign').AsBoolean = False) or
      (QryCalParam.FieldBYName('CalFinsh').AsBoolean) then
    begin
      v := QryCalParam.FieldByName('PayAmnt').value;
      QryMaster.FieldBYName('CalFinsh').AsBoolean := True;
    end else
    begin
      QryMaster.FieldBYName('CalFinsh').AsBoolean := False;
      IsAddList := True;
      IsDelList := True;
    end;
  end else
    v := 0;
end;
 
procedure TDmdPayDtlRecord.CalListPro;
var
  I: Integer;
begin
  I := 0;
  IsDelList := False;
  while I < Flist.Count do
  begin
    QryMaster.GotoBookmark(FList.Items[I]);
    ListPoint := FList.Items[I];        if QryMaster.State = dsBrowse then QryMaster.Edit;
    QryMaster.FieldByName('PayAmnt').Value :=
      FCal.Calc(QryMaster.FieldByName('Expression').AsString);
    FList.Delete(FList.IndexOf(ListPoint));        LocateParamQry;
    I := I;
    if IsDelList then
    begin
      I := I   1;
      IsDelList := False;
    end;
  end;
end;    procedure TDmdPayDtlRecord.LocateParamQry;
begin
  if QryCalParam.Locate('EmplyNum;PayCode;FiscaYear;AccoPerd',
    VarArrayOf([QryMaster.FieldByName('EmpLyNum').AsString,
    QryMaster.FieldByName('PayCode').AsString,
      QryMaster.FieldByName('FiscaYear').AsString,
      QryMaster.FieldByName('AccoPerd').AsInteger]), [loCaseInsensitive]) then
  begin
    if QryCalParam.State = dsBrowse then QryCalParam.Edit;
    QryCalParam.FieldByName('PayAmnt').Value :=
      QryMaster.FieldByName('PayAmnt').Value;
    QryCalParam.FieldByName('CalFinsh').AsBoolean := True;
    QryCalParam.Post;
  end;
end;
 
以上运算出来结果都为0,请教是哪里出了问题?
系統時間:2024-07-03 22:27:16
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!