打印本文 打印本文 关闭窗口 关闭窗口
通用查询组件设计(续三)
作者:武汉SEO闵涛  文章来源:敏韬网  点击数1822  更新时间:2009/4/23 18:35:20  文章录入:mintao  责任编辑:mintao
    Field := FieldName;

  if NonMatching then

    Result := '''' not ( ''''

  else

    Result := '''' ( '''';

  if AnsiUpperCase(FilterValue) = ''''NULL'''' then

  begin

    Result := Result + Format(''''%s is NULL) '''', [Field]);

    exit;

  end;

  if FieldType = ftString then

  begin

    if CaseSensitive then

      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 <> '''''''' then

            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;

      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 then

          begin

            if StartingValue <> '''''''' then

              Result := Result + Format(''''UPPER(%0:s) >= :%1:sStart)'''', [Field, FieldName]); {do not localize}

            if (StartingValue <> '''''''') and (EndingValue <> '''''''') then

              Result := Result + '''' and ('''';  {do not localize}

            if EndingValue <> '''''''' then

              Result := Result + Format(''''UPPER(%0:s) <= :%1:sEnd)'''', [Field, FieldName]); {do not localize}

          end

          else

          begin

            if StartingValue <> '''''''' then

              Result := Result + Format(''''%0:s >= :%1:sStart)'''', [Field, FieldName]);   {do not localize}

            if (StartingValue <> '''''''') and (EndingValue <> '''''''') then

              Result := Result + '''' and ('''';   {do not localize}

            if EndingValue <> '''''''' then

              Result := Result + Format(''''%0:s <= :%1:sEnd)'''', [Field, FieldName]);  {do not localize}

          end

        end;

      end;

  end

  else

    case MatchType of

      fdMatchRange :

      begin

        if StartingValue <> '''''''' then

          Result := Result + Format(''''%0:s >= :%1:sStart)'''', [Field, FieldName]); {do not localize}

        if (StartingValue <> '''''''') and (EndingValue <> '''''''') then

          Result := Result + '''' and (''''; {do not localize}

        if EndingValue <> '''''''' then

          Result := Result + Format('''

上一页  [1] [2] [3]  下一页

打印本文 打印本文 关闭窗口 关闭窗口