Home > Back-end >  Help: according to the standard database to calculate the results
Help: according to the standard database to calculate the results

Time:09-26

Here there is a standard, such as input value from 1 to 1000 of the input number multiplied by 5%; The 1000-2000 type number multiplied by 10%; This how to implement, train of thought

CodePudding user response:

Database trigger
Or
Add function fields

CodePudding user response:

If set up two fields: "base" "profits" :
Use DBEdit1 corresponds to "base", the use of DBEdit2 corresponding "profits",
In DBEdit1. OnChange events:

Procedure TMyFrm. DBEdit1Change (Sender: TObject);
Var N: Double;
The begin
With DataModule1. ClientDataSet1 do
The begin
N:=FieldByName (' base '.) asFloat;
If (N> 0) and (N<1000) then N:=N * 0.05
The else begin
If (N>=1000) and (N<2000) then N:=N * 0.1;
The end;
Edit;
FieldByName (' profits'). AsFloat:=N;
Post;
The end;
The end;
  • Related