General query component design
Author: nxyc_twz@163.com
Some time ago, due to work, innocent documents, please understand! I will organize all relevant documents and source code for this component.
Field variable set procedure TMyFieldInfo.SetVariables (d: TDataset); var value: String; begin // set the variable value if AnsiUpperCase (FilterValue) = 'NULL' then exit; if FieldType = ftString then begin if CaseSensitive then case MatchType of fdMatchStart, fdMatchAny: value: = FilterValue; fdMatchEnd: value: = '%' FilterValue; fdMatchExact: value: = FilterValue; end else case MatchType of fdMatchStart, fdMatchAny: value: = AnsiUpperCase (FilterValue); fdMatchEnd: value: = '%' AnsiUpperCase (FilterValue); fdMatchExact: value: = AnsiUpperCase (FilterValue); end; end else value: = FilterValue; if d is TDataSet then begin if MatchType <> fdMatchRange then TQuery (d) .ParamByName (FieldName 'Filter') .Value: = value else begin if discountValue <> 'Then TQuery (d) .Parambyname (FieldName 'Start') Value:. = StartingValue; if EndingValue <> '' then TQuery (d) .ParamByName (FieldName 'End') Value:. = EndingValue; end else begin if StartingValue <> '' then TQuery (d) .ParamByName (FieldName 'Start') Value:. = AnsiUpperCase (StartingValue); if EndingValue <> '' then TQuery (d) .ParamByName (FieldName 'End') Value:. = AnsiUpperCase (EndingValue); End; end; ELSE BEGIN IF MATCHPE <>
fdMatchRange then TQuery (d) .ParamByName (FieldName 'Filter') Value:.. = value else begin if CaseSensitive then begin if StartingValue <> '' then TQuery (d) .ParamByName (FieldName 'Start') Value: = StartingValue; if EndingValue <> '' then TQuery (d) .ParamByName (FieldName 'End') Value:. = EndingValue; end else begin if StartingValue <> '' then TQuery (d) .ParamByName (FieldName 'Start' ) .Value: = ANSIUPPPPERCASE (STARTINGVALUE); if endingvalue <> 'TENTENTINGEERY (D) .Parambyname (FieldName ' end '). Value: = ANSIUPPERCASE (EndingValue); end; end; end end; define parameter variable class TDBVARIABLE = Class // Parameter Data Variable Public Variablename: String; // Variable Name VariableValue: Variant; // Variable value constructor create (name: string; value: variant); // Construct function end;