General query component design (continued three)

zhaozj2021-02-16  51

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.

Procedure TMYFIELDINFO.SETVARIABLES (D: TDataSet); var value: string; begin // Set Variable Value if AnsiUppercase (FilterValue) = 'Null' Then // Exit EXIT; if FieldType = ftstring the // If The field type is a string type, then Begin if Casensitive the // If the case sensitive case matchType is // match type fdmatchStart, fdmatchany: // start part matching or arbitrary location Match value: = filterValue; fdmatchend: // End section Match Value: = '%' filterue; fdmatchexact: // Non-match record value: = filterValue; ELSE // Sizeless Case MatchType of fdmatchStart, fdmatchany: // Start part matching or arbitrary location Match Value: = AnsiUpperCase (FilterValue); fdMatchEnd: // end partial match value: = '%' AnsiUpperCase (FilterValue); {do not localize} fdMatchExact: // record the non-matching value: = AnsiUpperCase (FilterValue); end; end else // Field type is non-string type value: = filtervalue;

If MatchType <> FDMATCHRANGE // If the match type is not for the range TQuery (d) .Parambyname (FieldName 'filter'). Value: = value else // If you apply if casesensitive dam// If you do not copy sensitive Begin if StartingValue <> '"// If the start range is not empty TQuery (d) .Parambyname (FieldName ' Start '). Value: = StartingValue; if endingValue <>' Then // If the end range is not empty TQuery (d) .Parambyname (FieldName 'end'). Value: = endingValue; ELSE // Sensitive Begin if StartingValue <> 'TEN // If the start range is not empty TQuery (d) .Parambyname ( FieldName 'Start'). Value: = ANSIUPPERCASE (StartingValue); if endingvalue <> 'then // If the end range value is not empty TQuery (D) .Parambyname (FieldName ' end '). Value: = ANSIUPPPPERCASE EndingValue); End; End;

Field defines the type field class TMyFieldInfo = class // public FieldName: String; // field name FieldOrigin: String; FieldType: TFieldType; // field type DisplayLabel: String; MatchType // display name: TDBFilterMatchType; // match type FilterValue: String; // Filter value StartingValue: String; // Start value endingValue: string; // End value CaseSensitive: boolean; // Does case sensitive Nonmatching: boolean; // does not match Procedure Assign (o: tmyfieldInfo); // Specify field definition function createSQL: String; // Create SQL Statement Procedure SetVariables (D: TDataSet); // Setting field variable END; specifying field definition procedure TMYFIELDINFO.Assign (o: TMYFIELDINFO); begin // Specify field information fieldName: = o.FieldName; FieldOrigin: = o.FieldOrigin; FieldType: = o.FieldType; DisplayLabel: = o.DisplayLabel; MatchType: = o.MatchType; FilterValue: = o.FilterValue; StartingValue: = o.StartingValue; EndingValue: = o Casesensitive: = o.casesensitive; nonmatch: = o.nonmatching; end; create a SQL statement Function TMYFIELDINFO.CREATESQL: STRING; var Field: String Begin // Create SQL Statement IF Fieldorigin <> '' Then Field: = Fieldorigin Else Field: = FieldName; if Nonmatching Ten Result: = 'NOT (' else result: = '('; if AnsiUppercase (filtervalue) = 'NULL 'TEN BEGIN RESULT: = Result Format ('% s null) ', [Field]); exit; end; if FieldType = ftstring the beginning of caasensitiVE Case MatchType of FdmatchStart: Result: = Result Format ('% 0: s Starting with: 1: sfilter) ', [Field, FieldName]); fdmatchany: Result: = Result Format ('% 0: s Containing:% 1: sfilter) '

, [Field, FieldName]); FDMATCHEND: Result: = Result Format ('% 0: s =:% 1: sfilter)', [Field, FieldName]); fdmatchexact: Result: = Result Format ('% 0 : s =:% 1: sfilter ', [Field, FieldName]); FDMATCHRANGE: Begin if StartingValue <>' 'Ten Result: = Result Format ('% 0: S> =:% 1: sStart) ', [Field, FieldName]); IF (STARTINGVALUE <> ') and (endingvalue <>') Then Result: = Result 'and ('; if endingvalue <> '' Then Result: = Result Format ('% 0: S <=:% 1: Send ', [Field, FieldName]); End; Else Case MatchType of FdmatchStart: Result: = Result Format (' Upper (% 0: S) Starting with:% 1: Sfilter) ', [Field, FieldName]); {do not localize} fdmatchany: result: = result format (' Upper (% 0: s) containing:% 1: sfilter) ', [Field, FieldName]); { Do Not Localize} fdmatchend: Result: = Result Format (' Upper (% 0: s) LIKE:% 1: sfilter) ', [Field, FieldName]); {Do Not Localize} fdmatchexact: Result: = Result Format (' Upper (% 0: s) =:% 1: Sfilter) ', [Field, FieldName]); {Do Not Localize} fdmatchrange: Begin if FieldType = fTString The beginness: = Result Format (' Upper (% 0: s)> =: % 1: sStart ', [Field, FieldName]); {Do Not Localize} IF (StartingValue <>

转载请注明原文地址:https://www.9cbs.com/read-26394.html

New Post(0)