📄 uadoset.pas
字号:
end;///while
end;///if(_ctrl is TEasyGrid)
if (_ctrl is TListView) then
begin
TListView(_ctrl).Clear;
first;
for i:=0 to FieldList.Count do
begin
TlistView(_ctrl).Columns.Add;
end;
while not eof do
begin
listitem:=TlistView(_ctrl).Items.Add;
for i:=0 to FieldList.Count-1 do
begin
//listitem.Caption:=FieldValues[FieldDefList[0].Name];
if not FieldbyName(FieldDefList[i].Name).IsNull then
begin
listitem.SubItems.Add(FieldValues[FieldDefList[i].Name]);
end;
end;//for
next;
end;///while
end;///if(ctrl is Listview)结束///
end;//if
end;///with
Finally
_FQuery.close;
end;
end;
{
功能:
参数:
用法:
}
procedure TuAdoSet.BindToGrid_JK(_ctrl:TControl;_Sql:string;paramValues:TStringList;bCol:integer;eCol:integer;bRow:integer);
var
i:integer;
j:integer;
listitem:TListItem;
begin
try
with _FQuery do
begin
if _FDbType=1 then
begin
ConnectionString:='Provider=SQLOLEDB.1;Persist Security Info=False;User ID='+trim(_FLoginID)+';Initial Catalog='+_FdbName+';Data Source='+trim(_FserverName)+'';
end;
if _FDbType=2 then
begin
ConnectionString:='Provider=Microsoft.Jet.OLEDB.4.0;Data Source='+_FDbName+';Persist Security Info=False';
end;
Close;
Sql.Clear;
if _Sql='' then
begin
showmessage('sql语句错误...');
exit;
end;
Sql.Text:=trim(_Sql);
if _str.getSubStringCount(':',_Sql)<>paramValues.Count then
begin
showmessage('参数的个数不匹配...');
exit;
end;
if paramValues=nil then
begin
exit;
end;
if paramValues.Count<>0 then
begin
for i:=0 to paramValues.count-1 do
begin
Parameters[i].value:=paramValues[i];
end;
end
else
begin
end;
prepared;
open;
if RecordCount<>0 then
begin
///1.****/////////
if (_ctrl is TStringGrid) then
begin
for i:=1 to TStringGrid(_Ctrl).RowCount-2 do
begin
for j:=1 to TStringGrid(_ctrl).ColCount-1 do
begin
TStringGrid(_ctrl).Cells[j,i]:='';
end;
end;
TStringGrid(_ctrl).ColCount:=FieldList.Count+1;
TStringGrid(_ctrl).RowCount:=Recordcount+3;
j:=1;
while (not eof) and (j<=Recordcount) do
begin
for i:=0 to FieldList.Count-1 do
begin
TStringGrid(_ctrl).Cells[i+1,j]:=FieldByName(FieldDefList[i].Name).asstring;
end;
next;
inc(j);
end;///while
end;//if (_ctrl is StringGrid)
///2.*******//////////////
if (_ctrl is TEasyGrid) then
begin
//////清空表格中的数据////////////////
for j:=bRow+1 to TEasyGrid(_ctrl).RowCount-2 do
begin
for i:=bCol to eCol do
begin
TEasyGrid(_ctrl).Cells[i,j].ForeText:='';
end;///i
end;
//TEasyGrid(_ctrl).ColCount:=FieldList.Count+1;
TEasyGrid(_ctrl).RowCount:=Recordcount+4;
j:=bRow;
while (not eof) do
begin
for i:=bCol to eCol do
begin
if FieldByName(FieldDefList[i-bCol].Name).asstring='0' then
begin
TEasyGrid(_ctrl).Cells[i,j+1].ForeText:='';
end
else
TEasyGrid(_ctrl).Cells[i,j+1].ForeText:=trim(FieldByName(FieldDefList[i-bCol].Name).asstring);
end;
next;
inc(j);
end;///while
end;///if(_ctrl is TEasyGrid)
if (_ctrl is TListView) then
begin
TListView(_ctrl).Clear;
first;
for i:=0 to FieldList.Count do
begin
TlistView(_ctrl).Columns.Add;
end;
while not eof do
begin
listitem:=TlistView(_ctrl).Items.Add;
for i:=0 to FieldList.Count-1 do
begin
//listitem.Caption:=FieldValues[FieldDefList[0].Name];
if not FieldbyName(FieldDefList[i].Name).IsNull then
begin
listitem.SubItems.Add(FieldValues[FieldDefList[i].Name]);
end;
end;//for
next;
end;///while
end;///if(ctrl is Listview)结束///
end;//if
end;///with
Finally
_FQuery.close;
end;
end;
{
功能:
参数:
用法:
}
procedure TuAdoSet.BindToGrid(_ctrl:TControl);
var
i:integer;
j:integer;
listitem:TListItem;
begin
try
with _FQuery do
begin
if _FDbType=1 then
begin
ConnectionString:='Provider=SQLOLEDB.1;Persist Security Info=False;User ID='+trim(_FLoginID)+';Initial Catalog='+_FdbName+';Data Source='+trim(_FserverName)+'';
end;
if _FDbType=2 then
begin
ConnectionString:='Provider=Microsoft.Jet.OLEDB.4.0;Data Source='+_FDbName+';Persist Security Info=False';
end;
Close;
Sql.Clear;
if _FSqlString='' then
begin
showmessage('sql语句错误...');
exit;
end;
Sql.Text:=trim(_FSqlString);
if _str.getSubStringCount(':',_FSqlString)<>_FParamList.Count then
begin
showmessage('参数的个数不匹配...');
exit;
end;
if _FParamList=nil then
begin
exit;
end;
if _FParamList.Count<>0 then
begin
for i:=0 to _FParamList.count-1 do
begin
Parameters[i].value:=_FParamList[i];
end;
end
else
begin
end;
prepared;
open;
if RecordCount<>0 then
begin
///1.****/////////
if (_ctrl is TStringGrid) then
begin
for i:=1 to TStringGrid(_Ctrl).RowCount-2 do
begin
for j:=1 to TStringGrid(_ctrl).ColCount-1 do
begin
TStringGrid(_ctrl).Cells[j,i]:='';
end;
end;
TStringGrid(_ctrl).ColCount:=FieldList.Count+1;
TStringGrid(_ctrl).RowCount:=Recordcount+3;
j:=1;
while (not eof) and (j<=Recordcount) do
begin
for i:=0 to FieldList.Count-1 do
begin
TStringGrid(_ctrl).Cells[i+1,j]:=FieldByName(FieldDefList[i].Name).asstring;
end;
next;
inc(j);
end;///while
end;//if (_ctrl is StringGrid)
///2.*******//////////////
if (_ctrl is TEasyGrid) then
begin
//////清空表格中的数据////////////////
for j:=2 to TEasyGrid(_ctrl).RowCount-2 do
begin
for i:=1 to TEasyGrid(_ctrl).ColCount-1 do
begin
TEasyGrid(_ctrl).Cells[i,j].ForeText:='';
end;///i
end;
TEasyGrid(_ctrl).ColCount:=FieldList.Count+1;
TEasyGrid(_ctrl).RowCount:=Recordcount+3;
j:=1;
while (not eof) and (j<=Recordcount) do
begin
for i:=0 to FieldList.Count-1 do
begin
////showmessage(FieldByName(FieldDefList[i].Name).asstring);
TEasyGrid(_ctrl).Cells[i+1,j+1].ForeText:=trim(FieldByName(FieldDefList[i].Name).asstring);
end;
next;
inc(j);
end;///while
end;///if(_ctrl is TEasyGrid)
if (_ctrl is TListView) then
begin
TListView(_ctrl).Clear;
first;
for i:=0 to FieldList.Count do
begin
TlistView(_ctrl).Columns.Add;
end;
while not eof do
begin
listitem:=TlistView(_ctrl).Items.Add;
for i:=0 to FieldList.Count-1 do
begin
//listitem.Caption:=FieldValues[FieldDefList[0].Name];
if not FieldbyName(FieldDefList[i].Name).IsNull then
begin
listitem.SubItems.Add(FieldValues[FieldDefList[i].Name]);
end;
end;//for
next;
end;///while
end;///if(ctrl is Listview)结束///
end;//if
end;///with
Finally
_FQuery.close;
end;
end;
{
功能:
参数:
用法:
}
procedure TuAdoSet.BindToGrid(AdoQuery:TAdoQuery;_ctrl:TDBGrid;_sql:string;paramValues:TStringList);
var
i:integer;
begin
try
with AdoQuery do
begin
if _FDbType=1 then
begin
ConnectionString:='Provider=SQLOLEDB.1;Persist Security Info=False;User ID='+trim(_FLoginID)+';Initial Catalog='+_FdbName+';Data Source='+trim(_FserverName)+'';
end;
if _FDbType=2 then
begin
ConnectionString:='Provider=Microsoft.Jet.OLEDB.4.0;Data Source='+_FDbName+';Persist Security Info=False';
end;
Close;
Sql.Clear;
if _Sql='' then
begin
showmessage('sql语句错误...');
exit;
end;
Sql.Text:=trim(_Sql);
if _str.getSubStringCount(':',_Sql)<>paramValues.Count then
begin
showmessage('参数的个数不匹配...');
exit;
end;
if paramValues.Count<>0 then
begin
for i:=0 to paramValues.count-1 do
begin
Parameters[i].value:=paramValues[i];
end;
end
else
begin
end;
prepared;
open;
end;//with
_FDataSource.DataSet:=AdoQuery;
TDBGrid(_ctrl).DataSource:=_FDataSource;
///TDBGrid(_ctrl).Refresh;
Finally
_FDataSource.Free;
AdoQuery.Close;
end;
end;
{
功能:
参数:
用法:
}
Function TuAdoSet.getFieldValue(_Sql:string;paramValues:TStringList;FieldName:string):Variant;
var
i:integer;
begin
try
with _FQuery do
begin
if _FDbType=1 then
begin
ConnectionString:='Provider=SQLOLEDB.1;Persist Security Info=False;User ID='+trim(_FLoginID)+';Initial Catalog='+_FdbName+';Data Source='+trim(_FserverName)+'';
end;
if _FDbType=2 then
begin
ConnectionString:='Provider=Microsoft.Jet.OLEDB.4.0;Data Source='+_FDbName+';Persist Security Info=False';
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -