设为首页】 【加入收藏】 【网站地图】 【商品折扣
娱乐一生 娱乐明星
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
首页  |  java  |  .NET  |  C/C++  |  网页技术  |  php  |  asp  |  delphi  |  VC  |  VB开发  |  游戏开发  |  软件工程  |  Power Builder  |  Linux开发  |  Windows开发技巧
当前位置:首页 >> delphi >> 通用查询组件设计(续三)_Delphi教程_src119.com

通用查询组件设计(续三)_Delphi教程_src119.com -

通用查询组件设计

作者:nxyc_twz@163.com

  前段时间由于工作较忙,无暇整理本组件的相关文档,请大家谅解!以后我会陆续整理公布该组件的所有相关文档及源码!

< AN lang=EN-US>procedure TMyFieldInfo.SetVariables(d: TDataset);

var

< AN style="mso- acerun: yes">  value : String;

begin

//设置变量值

< AN style="mso- acerun: yes">  if A iU erCase(FilterValue) = 'NULL' then //如果FilterValue为空,则退出

< AN style="mso- acerun: yes">  exit;

< AN style="mso- acerun: yes">  if FieldType = ftString then //如果字段类型为字符串型,则

< AN style="mso- acerun: yes">  begin

< AN style="mso- acerun: yes">  if CaseSe itive the  //如果大小写敏感

< AN style="mso- acerun: yes">  case MatchType of  //匹配类型

< AN style="mso- acerun: yes">  fdMatchStart, fdMatchAny :  //起始部分匹配或任意位置匹配

< AN style="mso- acerun: yes">  value := FilterValue;

< AN style="mso- acerun: yes">  fdMatchEnd : //结束部分匹配

< AN style="mso- acerun: yes">  value := '%' + FilterValue 

< AN style="mso- acerun: yes">  fdMatchExact : //非匹配记录

< AN style="mso- acerun: yes">  value := FilterValue;

< AN style="mso- acerun: yes">  end

else< AN style="mso- acerun: yes">  //大小写不敏感

< AN style="mso- acerun: yes">  case MatchType of

< AN style="mso- acerun: yes">  fdMatchStart, fdMatchAny : //起始部分匹配或任意位置匹配

< AN style="mso- acerun: yes">  value := A iU erCase(FilterValue);

< AN style="mso- acerun: yes">  fdMatchEnd : //结束部分匹配

< AN style="mso- acerun: yes">  value := '%' + A iU erCase(FilterValue)  {do not localize}

< AN style="mso- acerun: yes">  fdMatchExact : //非匹配记录

< AN style="mso- acerun: yes">  value := A iU erCase(FilterValue);

< AN style="mso- acerun: yes">  end;

< AN style="mso- acerun: yes">  end

< AN style="mso- acerun: yes">  else//字段类型为非字符串型

< AN style="mso- acerun: yes"> value := FilterValue;

 

< AN style="mso- acerun: yes">  if MatchType < gt; fdMatchRange then//如果匹配类型不为按范围

TQuery(d).ParamByName(FieldName + 'Filter').Value :=< AN style="mso- acerun: yes">  value

else //否则

< AN style="mso- acerun: yes">  begin

< AN style="mso- acerun: yes">  if CaseSe itive then //如果大小写敏感

< AN style="mso- acerun: yes">  begin

< AN style="mso- acerun: yes">  if StartingValue < gt; '' then //如果起始范围值不为空 

< AN style="mso- acerun: yes">   TQuery(d).ParamByName(FieldName + 'Start').Value := StartingValue 

< AN style="mso- acerun: yes">  if EndingValue < gt; '' then //如果结束范围不为空

< AN style="mso- acerun: yes">  TQuery(d).ParamByName(FieldName + 'End').Value := EndingValue 

< AN style="mso- acerun: yes">  end

< AN style="mso- acerun: yes">  else //大小写敏感

< AN style="mso- acerun: yes">  begin

< AN style="mso- acerun: yes">  if StartingValue < gt; '' then //如果起始范围值不为空

< AN style="mso- acerun: yes">  TQuery(d).ParamByName(FieldName + 'Start').Value := A iU erCase(StartingValue);

< AN style="mso- acerun: yes">  if EndingValue < gt; '' then //如果结束范围值不为空

< AN style="mso- acerun: yes">  TQuery(d).ParamByName(FieldName + 'End').Value := A iU erCase(EndingValue) 

< AN style="mso- acerun: yes">  end;

< AN style="mso- acerun: yes">  end;

< AN style="mso- acerun: yes">  end

end;

 

< AN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-ha i-font-family: 'Times New Roman'">字段定义类

TMyFieldInfo = cla < AN style="mso- acerun: yes">  //字段类

< AN style="mso- acerun: yes">  public

< AN style="mso- acerun: yes">  FieldName : String  //字段名

< AN style="mso- acerun: yes">  FieldOrigin : String 

< AN style="mso- acerun: yes">  FieldType : TFieldType  //字段类型

< AN style="mso- acerun: yes">  Di layLabel : String  //显示的名称

< AN style="mso- acerun: yes">  MatchType : TDBFilterMatchType  //匹配类型

< AN style="mso- acerun: yes">  FilterValue : String; //过滤值

< AN style="mso- acerun: yes">  StartingValue : String; //开始值

< AN style="mso- acerun: yes">  EndingValue : String  //结束值

< AN style="mso- acerun: yes">  CaseSe itive : boolea  //是否大小写敏感

< AN style="mso- acerun: yes">  NonMatching : boolea  //不匹配

< AN style="mso- acerun: yes">  procedure A ign(o : TMyFieldInfo); //指定字段定义

function CreateSQL : String;< AN style="mso- acerun: yes">  //创建SQL语句

procedure SetVariables( d : TDataset);< AN style="mso- acerun: yes">  //设置字段变量

< AN style="mso- acerun: yes">  end;

< AN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-ha i-font-family: 'Times New Roman'">指定字段定义

procedure TMyFieldInfo.A ign(o : TMyFieldInfo);

begin

//指定字段信息

< AN style="mso- acerun: yes">  FieldName := o.FieldName;

< AN style="mso- acerun: yes">  FieldOrigin := o.FieldOrigi 

< AN style="mso- acerun: yes">  FieldType := o.FieldType;

< AN style="mso- acerun: yes">  Di layLabel := o.Di layLabel;

< AN style="mso- acerun: yes">  MatchType := o.MatchType;

< AN style="mso- acerun: yes">  FilterValue := o.FilterValue;

< AN style="mso- acerun: yes">  StartingValue := o.StartingValue;

< AN style="mso- acerun: yes">  EndingValue := o.EndingValue;

< AN style="mso- acerun: yes">  CaseSe itive := o.CaseSe itive;

< AN style="mso- acerun: yes">  NonMatching := o.NonMatching;

end;

< AN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-ha i-font-family: 'Times New Roman'">创建SQL语句

function TMyFieldInfo.CreateSQL: String;

var

< AN style="mso- acerun: yes">  Field : String;

begin

//创建SQL语句

< AN style="mso- acerun: yes">  if FieldOrigin < gt; '' then

< AN style="mso- acerun: yes">  Field := FieldOrigin

< AN style="mso- acerun: yes">  else

< AN style="mso- acerun: yes">  Field := FieldName;

< AN style="mso- acerun: yes">  if NonMatching then

< AN style="mso- acerun: yes">  Result := ' not ( '

< AN style="mso- acerun: yes">  else

< AN style="mso- acerun: yes">  Result := ' ( ';

< AN style="mso- acerun: yes">  if A iU erCase(FilterValue) = 'NULL' then

< AN style="mso- acerun: yes">  begin

< AN style="mso- acerun: yes">  Result := Result + Format('%s is NULL) ', [Field]);

< AN style="mso- acerun: yes">  exit;

< AN style="mso- acerun: yes">  end;

< AN style="mso- acerun: yes">  if FieldType = ftString then

< AN style="mso- acerun: yes">  begin

< AN style="mso- acerun: yes">  if CaseSe itive then

< AN style="mso- acerun: yes">  case MatchType of

< AN style="mso- acerun: yes">  fdMatchStart:

< AN style="mso- acerun: yes">  Result := Result + Format('%0:s starting with :%1:sFilter ) ', [Field, FieldName]);

< AN style="mso- acerun: yes">  fdMatchAny:

< AN style="mso- acerun: yes">  Result := Result + Format('%0:s containing :%1:sFilter ) ', [Field, FieldName]);

< AN style="mso- acerun: yes">  fdMatchEnd :

< AN style="mso- acerun: yes">  Result := Result + Format('%0:s = :%1:sFilter ) ', [Field, FieldName]);

< AN style="mso- acerun: yes">  fdMatchExact :

< AN style="mso- acerun: yes">  Result := Result + Format('%0:s = :%1:sFilter ) ', [Field, FieldName]);

< AN style="mso- acerun: yes">  fdMatchRange :

< AN style="mso- acerun: yes">   egin

< AN style="mso- acerun: yes">  if StartingValue < gt; '' then

< AN style="mso- acerun: yes">  Result := Result + Format('%0:s >= :%1: tart)', [Field, FieldName]);

< AN style="mso- acerun: yes">  if (StartingValue < gt; '') and (EndingValue < gt; '') then

< AN style="mso- acerun: yes">  Result := Result + ' and (';

< AN style="mso- acerun: yes">  if EndingValue < gt; '' then

< AN style="mso- acerun: yes">  Result := Result + Format('%0:s <= :%1:sEnd)', [Field, FieldName]);

< AN style="mso- acerun: yes">  end;

< AN style="mso- acerun: yes">  end

< AN style="mso- acerun: yes">  else

< AN style="mso- acerun: yes">  case MatchType of

< AN style="mso- acerun: yes">  fdMatchStart:

< AN style="mso- acerun: yes">  Result := Result + Format('U ER(%0:s) starting with :%1:sFilter ) ', [Field, FieldName]); {do not localize}

< AN style="mso- acerun: yes">  fdMatchAny:

< AN style="mso- acerun: yes">  Result := Result + Format('U ER(%0:s) containing :%1:sFilter ) ', [Field, FieldName]); {do not localize}

< AN style="mso- acerun: yes">  fdMatchEnd :

< AN style="mso- acerun: yes">  Result := Result + Format('U ER(%0:s) like :%1:sFilter ) ', [Field, FieldName])  {do not localize}

< AN style="mso- acerun: yes">  fdMatchExact :

< AN style="mso- acerun: yes">  Result := Result + Format('U ER(%0:s) = :%1:sFilter ) ', [Field, FieldName])  {do not localize}

< AN style="mso- acerun: yes">  fdMatchRange :

< AN style="mso- acerun: yes">  begin

< AN style="mso- acerun: yes">  if FieldType = ftString then

< AN style="mso- acerun: yes">  begin

< AN style="mso- acerun: yes">  if StartingValue < gt; '' then

< AN style="mso- acerun: yes">  Result := Result + Format('U ER(%0:s) >= :%1: tart)', [Field, FieldName]); {do not localize}

< AN style="mso- acerun: yes">  if (StartingValue < gt; '') and (EndingValue < gt; '') then

< AN style="mso- acerun: yes">  Result := Result + ' and ('  {do not localize}

< AN style="mso- acerun: yes">  if EndingValue < gt; '' then

< AN style="mso- acerun: yes">  Result := Result + Format('U ER(%0:s) <= :%1:sEnd)', [Field, FieldName]); {do not localize}

< AN style="mso- acerun: yes">  end

< AN style="mso- acerun: yes">  else

< AN style="mso- acerun: yes">  begin

< AN style="mso- acerun: yes">  if StartingValue < gt; '' then

< AN style="mso- acerun: yes">  Result := Result + Format('%0:s >= :%1: tart)', [Field, FieldName])  {do not localize}

< AN style="mso- acerun: yes">  if (StartingValue < gt; '') and (EndingValue < gt; '') then

< AN style="mso- acerun: yes">  Result := Result + ' and ('  {do not localize}

< AN style="mso- acerun: yes">  if EndingValue < gt; '' then

< AN style="mso- acerun: yes">  Result := Result + Format('%0:s <= :%1:sEnd)', [Field, FieldName])  {do not localize}

< AN style="mso- acerun: yes">  end

< AN style="mso- acerun: yes">  end;

< AN style="mso- acerun: yes">  end;

< AN style="mso- acerun: yes">  end

< AN style="mso- acerun: yes">  else

< AN style="mso- acerun: yes">  case MatchType of

< AN style="mso- acerun: yes">  fdMatchRange :

< AN style="mso- acerun: yes">  begin

< AN style="mso- acerun: yes">  if StartingValue < gt; '' then

< AN style="mso- acerun: yes">  Result := Result + Format('%0:s >= :%1: tart)', [Field, FieldName]); {do not localize}

< AN style="mso- acerun: yes">  if (StartingValue < gt; '') and (EndingValue < gt; '') then

< AN style="mso- acerun: yes">  Result := Result + ' and ('; {do not localize}

< AN style="mso- acerun: yes">  if EndingValue < gt; '' then

< AN style="mso- acerun: yes">  Result := Result + Format('%0:s <= :%1:sEnd)', [Field, FieldName])  {do not localize}

< AN style="mso- acerun: yes">  end;

< AN style="mso- acerun: yes">  else

< AN style="mso- acerun: yes">  Result := Result + Format('%0:s = :%1:sFilter ) ', [Field, FieldName]); {do not localize}

< AN style="mso- acerun: yes">  end;

end;



 

娱乐图摘

更多 >>

靓丽清纯美女meimei

美女私房全裸照
导演劝女演员脱衣服(视频)

大胆火辣人体艺术写真(图)

黑丝妹妹热辣诱惑-丝袜美女妹妹

PLMM 漂亮妹妹图集-妹妹图库

全球美女图库-美女集中营

52MM 我爱漂亮妹妹-制服妹妹诱惑

图王图库-世界美女明星图片资料库
美女写真集锦

激情两性-解密性生活
浴室MM湿身内衣诱惑
邻家小妹洗澡被偷拍(视频)

热点文章

更多

· 使用MIDAS访问远程Access数据库_Delphi教程_
· Delphi2005学习笔记4——再谈NameSpace和D
· 多层数据库开发十二:使用数据控件_Delphi教程_src1
· 在Delphi中自己建立交叉表_Delphi教程_src11
· 用Delphi设计代理服务器_Delphi教程_src119
· Delphi开发单机瘦数据库程序要点_Delphi教程_sr
· 拖拉打开文件_Delphi教程_src119.com
· 搜索字符串在流中的位置_Delphi教程_src119.co
· 用Delphi编写Win2000服务程序_Delphi教程_
· 創建一個簡單的"專家"_Delphi教程

热点文章

更多