偶写的第一个控件,一个用选择代替输入的Edit控件…
2008-04-09 04:21:11来源:互联网 阅读 ()
key:=0;
end;
end;
end;
//判断是否全是数字
function IsAllInteger(Text:widestring):boolean;
var
Temp:string;
i:integer;
begin
try
Result:=true;
Temp:=trim(text);
if (length(Temp)<=0) then
begin
Result:=false;
exit;
end;
for i:=1 to length(Temp) do
begin
if not (Temp[i] in [''''0''''..''''9'''']) then
begin
Result:=false;
break;
end;
end;
except
Result:=false;
end;
end;
//生成筛选语句
function CSQL(EditText,FieldName:WideString):WideString;
var
i:integer;
sql:WideString;
tmEditText1,tmEditText2:WideString;
begin
Result:='''''''';
if IsAllInteger(EditText) then
begin
tmEditText1:=trim(EditText);
tmEditText2:=trim(EditText);
SQL:=SQL ''''('''' FieldName ''''>='''' trim(EditText) '''' and '''' FieldName ''''<='''' inttostr((StrToInt(EditText) div 10)*10 9) '''')'''';
for i:=length(EditText) to 6 do
begin
tmEditText1:=tmEditText1 ''''0'''';
tmEditText2:=tmEditText2 ''''9'''';
sql:=sql '''' or ('''' FieldName ''''>='''' tmEditText1 '''' and '''' FieldName ''''<='''' tmEditText2 '''')'''';
end;
Result:=sql;
end;
end;
procedure TDBLookUpEdit.KeyUp(var Key: Word; Shift: TShiftState);
begin
inherited;
if FDBGrid.Visible then
begin
if (key=38) or (key=40) then
begin
SetRecText(1);
end
else if IsAllInteger(self.Text) then
begin
FADOQuery.Filtered:=false;
FADOQuery.Filter:=CSQL(self.Text,FKeyField);
FADOQuery.Filtered:=true;
end;
end;
end;
procedure TDBLookUpEdit.KeyPress(var Key: Char);
begin
inherited;
end;
function TDBLookUpEdit.GetConnection: TADOConnection;
begin
Result := FADOQuery.Connection;
end;
procedure TDBLookUpEdit.SetConnection(const Value: TADOConnection);
begin
if Value <> FADOQuery.Connection then
begin
FADOQuery.Connection := Value;
end;
if Value <> nil then Value.FreeNotification(Self);
end;
function TDBLookUpEdit.GetConnectionString: WideString;
begin
Result := FADOQuery.ConnectionString;
end;
procedure TDBLookUpEdit.SetConnectionString(const Value: WideString);
begin
if Value <> FADOQuery.ConnectionString then FADOQuery.ConnectionString := Value;
end;
function TDBLookUpEdit.GetActive: Boolean;
begin
Result :=FADOQuery.Active;
end;
procedure TDBLookUpEdit.SetActive(Value: Boolean);
begin
if Value <> FADOQuery.Active then
begin
FADOQuery.Active := Value;
end;
end;
function TDBLookUpEdit.GetSQL: TStrings;
begin
Result := FADOQuery.SQL;
end;
procedure TDBLookUpEdit.SetSQL(const Value: TStrings);
begin
if FADOQuery.SQL<>Value then FADOQuery.SQL.Assign(Value);
end;
procedure TDBLookUpEdit.Loaded;
begin
inherited Loaded;
end;
end.
标签:
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有
上一篇:编译原理的一个简单的枚举算法
下一篇:delphi7的新特性
IDC资讯: 主机资讯 注册资讯 托管资讯 vps资讯 网站建设
网站运营: 建站经验 策划盈利 搜索优化 网站推广 免费资源
网络编程: Asp.Net编程 Asp编程 Php编程 Xml编程 Access Mssql Mysql 其它
服务器技术: Web服务器 Ftp服务器 Mail服务器 Dns服务器 安全防护
软件技巧: 其它软件 Word Excel Powerpoint Ghost Vista QQ空间 QQ FlashGet 迅雷
网页制作: FrontPages Dreamweaver Javascript css photoshop fireworks Flash
