procedure Tdtmzd_CostCalc.adsMasterStuffFeeChange(Sender: TField); begin inherited; if not (adsMaster.State in [dsEdit,dsInsert]) then exit; adsMaster.FieldByName('StuffCost').AsCurrency:= StuffCost(adsMaster.FieldByName('StuffFee').AsCurrency, adsMaster.FieldByName('RatingWaste').AsCurrency); end; function Tdtmzd_CostCalc.StuffCost(StuffFee, WasteRate: double): double; begin if WasteRate >= 100 then begin WarnBox('织造损耗率不能大于等于100%'); exit; end else begin result := StuffFee / (1- WasteRate/100); end; end;在ADO控件里的字段的ONCHANGE事件里写
如果不行,你可以写一下eh的DBGridEh1SumListRecalcAll
begin
inherited;
if not (adsMaster.State in [dsEdit,dsInsert]) then exit;
adsMaster.FieldByName('StuffCost').AsCurrency:=
StuffCost(adsMaster.FieldByName('StuffFee').AsCurrency, adsMaster.FieldByName('RatingWaste').AsCurrency);
end;
function Tdtmzd_CostCalc.StuffCost(StuffFee, WasteRate: double): double;
begin
if WasteRate >= 100 then
begin
WarnBox('织造损耗率不能大于等于100%');
exit;
end else
begin
result := StuffFee / (1- WasteRate/100);
end;
end;在ADO控件里的字段的ONCHANGE事件里写