📄 commlist.pas
字号:
params[0].AsString:='0';
params[1].AsString:=AddTab_name;
prepare;
open;
setlength(code,recordcount);
k:=0;
while not eof do
begin
code[k].parentid:=fieldbyname('parentid').AsInteger;
code[k].id:=fieldbyname('id').AsInteger;
code[k].e_expr:=fieldbyname('e_expr').AsString;
code[k].c_brif:=fieldbyname('c_brif').AsString;
inc(k);
next;
end;
end;
for i:=low(code) to high(code) do
begin
if code[i].parentid=0 then
begin
NewItem:=Sour.Items.AddChild(nil,code[i].c_brif);
NewItem.StringData:=code[i].e_expr;
ListNode(i,high(code),code[i].id,NewItem,Sour);
end;
end;
Sour.TreeView.FullCollapse;
end;
procedure Init_CompOrgan(Sour:TfcTreeCombo);
var
NewItem:TfcTreeNode;
str:string;
i:integer;
begin
with datashare_frm.Query1 do
begin
close;
sql.clear;
str:='select * from organization order by parentid,id';
sql.Add(str);
prepare;
open;
setlength(organ,recordcount);
i:=0;
while not eof do
begin
organ[i].id:=fieldbyname('id').AsInteger;
organ[i].parentid:=fieldbyname('parentid').AsInteger;
organ[i].name:=fieldbyname('name').AsString;
organ[i].disptype:=fieldbyname('disptype').AsString;
organ[i].cpseno:=fieldbyname('cpseno').AsInteger;
inc(i);
next;
end;
end;
for i:=low(organ) to high(organ) do
begin
if organ[i].parentid=0 then
begin
NewItem:=Sour.Items.AddChild(nil,organ[i].name);
NewItem.StringData:=inttostr(organ[i].id);
NewItem.StringData2:=inttostr(organ[i].cpseno);
ListDept(i,high(organ),organ[i].id,NewItem,Sour);
end;
end;
//Sour.TreeView.FullCollapse;
end;
procedure ListDept(L,H,id:integer;item:TfcTreeNode;Sour:TfcTreeCombo);
var
i:integer;
NewItem:TfcTreeNode;
begin
for i:=L to H do
begin
if organ[i].parentid=id then
begin
NewItem:=Sour.Items.AddChild(item,organ[i].name);
NewItem.StringData:=inttostr(organ[i].id);
NewItem.StringData2:=inttostr(organ[i].cpseno);
ListDept(i,H,organ[i].id,NewItem,Sour);
end;
end;
end;
procedure ListNode(L,H,id:integer;item:TfcTreeNode;Sour:TfcTreeCombo);
var
i:integer;
NewItem:TfcTreeNode;
begin
for i:=L to H do
begin
if code[i].parentid=id then
begin
NewItem:=Sour.Items.AddChild(item,code[i].c_brif);
NewItem.StringData:=code[i].e_expr;
ListNode(i,H,code[i].id,NewItem,Sour);
end;
end;
end;
procedure Linkdata(dirstr,dataname:string);
var
//对注册表进行操作的变量
registerTemp : TRegistry;
bData : array[ 0..0 ] of byte;
a:Array[0..max_path] of char;
begin
registerTemp := TRegistry.Create; //建立一个Registry实例
with registerTemp do
begin
RootKey:=HKEY_LOCAL_MACHINE;//设置根键值为HKEY_LOCAL_MACHINE
//找到Software\ODBC\ODBC.INI\ODBC Data Sources
if OpenKey('Software\ODBC\ODBC.INI\ODBC Data Sources',True) then
WriteString(dataname, 'Microsoft FoxPro VFP Driver (*.dbf)' )
else
exit;
CloseKey;
if OpenKey(pchar('Software\ODBC\ODBC.INI\'+dataname),True) then
begin
WriteString( 'BackgroundFetch','Yes');//数据库目录
WriteString( 'Collate','Machine'); //数据源描述
WriteString( 'Deleted','Yes');
WriteString( 'Description','');
getwindowsDirectory(a,sizeof(a));
WriteString( 'Driver', pchar(strpas(a)+'\System\vfpodbc.dll') );//驱动程序DLL文件
WriteString( 'Exclusive','No');//驱动程序标识
WriteString( 'Null', 'Yes' );//Filter依据
WriteString( 'SetNoCountOn', 'No' );
WriteString( 'SourceDB',pchar(dirstr) );//支持的事务操作数目
WriteString( 'SourceType', 'DBF' );//用户名称
end
else //创建键值失败
exit;
CloseKey;
end;
{with registerTemp do
begin
RootKey:=HKEY_LOCAL_MACHINE;//设置根键值为HKEY_LOCAL_MACHINE
//找到Software\ODBC\ODBC.INI\ODBC Data Sources
if OpenKey('Software\ODBC\ODBC.INI\ODBC Data Sources',True) then
WriteString(dataname, 'Microsoft dBase Driver (*.dbf)' )
else
exit;
CloseKey;
if OpenKey(pchar('Software\ODBC\ODBC.INI\'+dataname),True) then
begin
WriteString( 'DefaultDir', pchar(dirstr));//数据库目录
WriteString( 'Description',pchar(dataname)); //数据源描述
getwindowsDirectory(a,sizeof(a));
WriteString( 'Driver', pchar(strpas(d)+'\driver\odbcjt32.dll') );//驱动程序DLL文件
WriteInteger( 'DriverId', 21);//驱动程序标识
WriteString( 'FIL', 'dBase III;' );//Filter依据
WriteInteger( 'SafeTransaction', 0 );//支持的事务操作数目
WriteString( 'UID', '' );//用户名称
end
else //创建键值失败
exit;
CloseKey;
if not OpenKey(pchar('Software\ODBC\ODBC.INI\'+dataname+'\Engines'),true) then
exit;
CloseKey;
if OpenKey(pchar('Software\ODBC\ODBC.INI\'+dataname+'\Engines\Xbase'),true) then
begin
WriteString( 'CollatingSequence', 'ASCII' );
//WriteInteger( 'Deleted', 00 );
WriteString( 'ImplicitCommitSync', '' );
WriteInteger('PageTimeout',5);
//WriteInteger( 'Statistics', 00 );
WriteInteger( 'Threads', 3 );
WriteString( 'UserCommitSync', 'yes' );
end;
CloseKey;
end; }
registerTemp.free;
end;
procedure LinkImpdata(dirstr,dataname:string);
var
//对注册表进行操作的变量
registerTemp : TRegistry;
bData : array[ 0..0 ] of byte;
a:Array[0..max_path] of char;
d:string;
begin
d:=getcurrentdir;
registerTemp := TRegistry.Create; //建立一个Registry实例
with registerTemp do
begin
RootKey:=HKEY_LOCAL_MACHINE;//设置根键值为HKEY_LOCAL_MACHINE
//找到Software\ODBC\ODBC.INI\ODBC Data Sources
if OpenKey('Software\ODBC\ODBC.INI\ODBC Data Sources',True) then
//WriteString(dataname, 'Microsoft FoxPro VFP Driver (*.dbf)' )
WriteString(dataname, 'Epsoft FoxPro VFP Driver (*.dbf)' )
else
exit;
CloseKey;
if OpenKey(pchar('Software\ODBC\ODBC.INI\'+dataname),True) then
begin
WriteString( 'BackgroundFetch','Yes');//数据库目录
WriteString( 'Collate','Machine'); //数据源描述
WriteString( 'Deleted','Yes');
WriteString( 'Description','');
//getwindowsDirectory(a,sizeof(a));
//WriteString( 'Driver', pchar(strpas(a)+'\System\vfpodbc.dll') );//驱动程序DLL文件
WriteString( 'Driver', pchar(d+'\driver\vfp\vfpodbc.dll') );
WriteString( 'Exclusive','No');//驱动程序标识
WriteString( 'Null', 'Yes' );//Filter依据
WriteString( 'SetNoCountOn', 'No' );
WriteString( 'SourceDB',pchar(dirstr) );//支持的事务操作数目
WriteString( 'SourceType', 'DBF' );//用户名称
end
else //创建键值失败
exit;
CloseKey;
end;
registerTemp.free;
end;
procedure LinkExpdata(dirstr,dataname:string);
var
//对注册表进行操作的变量
registerTemp : TRegistry;
bData : array[ 0..0 ] of byte;
a:Array[0..max_path] of char;
d:string;
begin
d:=getcurrentdir;
registerTemp := TRegistry.Create; //建立一个Registry实例
with registerTemp do
begin
RootKey:=HKEY_LOCAL_MACHINE;//设置根键值为HKEY_LOCAL_MACHINE
//找到Software\ODBC\ODBC.INI\ODBC Data Sources
if OpenKey('Software\ODBC\ODBC.INI\ODBC Data Sources',True) then
WriteString(dataname, 'Microsoft dBase Driver (*.dbf)' )
else
exit;
CloseKey;
if OpenKey(pchar('Software\ODBC\ODBC.INI\'+dataname),True) then
begin
WriteString( 'DefaultDir', pchar(dirstr));//数据库目录
WriteString( 'Description',pchar(dataname)); //数据源描述
getwindowsDirectory(a,sizeof(a));
WriteString( 'Driver', pchar(d+'\driver\odbcjt32.dll') );//驱动程序DLL文件
WriteInteger( 'DriverId', 21);//驱动程序标识
WriteString( 'FIL', 'dBase III;' );//Filter依据
WriteInteger( 'SafeTransaction', 0 );//支持的事务操作数目
WriteString( 'UID', '' );//用户名称
end
else //创建键值失败
exit;
CloseKey;
if not OpenKey(pchar('Software\ODBC\ODBC.INI\'+dataname+'\Engines'),true) then
exit;
CloseKey;
if OpenKey(pchar('Software\ODBC\ODBC.INI\'+dataname+'\Engines\Xbase'),true) then
begin
WriteString( 'CollatingSequence', 'ASCII' );
//WriteInteger( 'Deleted', 00 );
WriteString( 'ImplicitCommitSync', '' );
WriteInteger('PageTimeout',5);
//WriteInteger( 'Statistics', 00 );
WriteInteger( 'Threads', 3 );
WriteString( 'UserCommitSync', 'yes' );
end;
CloseKey;
end;
registerTemp.free;
end;
procedure DelLinkdata(dirstr,dataname:string);
var
registerTemp : TRegistry;
begin
registerTemp := TRegistry.Create;
with registerTemp do
begin
RootKey:=HKEY_LOCAL_MACHINE;
if OpenKey('Software\ODBC\ODBC.INI\ODBC Data Sources',True) then
DeleteValue(dataname);
CloseKey;
if OpenKey('Software\ODBC\ODBC.INI',True) then
DeleteKey(dataname);
CloseKey;
end;
registerTemp.free;
end;
function Fillchar(str:widestring;count:integer):widestring;
var
temp:widestring;
i:integer;
begin
temp:='';
for i:=1 to count do
temp:=temp+str;
result:=temp;
end;
function returnrewage(l_psseno ,l_yearno :integer;Db:Tdatabase):double;
var
l_rewage :double;
Query:TQuery;
begin
try
Query:=TQuery.Create(nil);
Query.DatabaseName :=Db.DatabaseName ;
Query.SQL.Add('select rewage from sbdu_pswgcase where psseno=:param1 and yearno=:param2');
Query.ParamByName('param1').AsInteger :=l_psseno;
Query.ParamByName('param2').AsInteger :=l_yearno-1;
Query.Prepare ;
Query.Open ;
l_rewage:=Query.Fields[0].AsFloat ;
except
l_rewage:=0;
end;
result:=l_rewage;
Query.Free ;
end;
function returnmonth(l_psseno ,l_yearno :integer;Db:TDatabase):integer;
var
i :integer;
cunt :integer;
mon :integer;
Query:TQuery;
begin
try
cunt:=0 ;mon:=0;
Query:=TQuery.Create(nil);
with Query do
begin
DatabaseName :=db.databasename;
sql.Add(' select count(*) from sbdu_pswgcase where psseno=:param1 and yearno=:param2 and months>0');
parambyname('param1').AsInteger :=l_psseno;
parambyname('param2').AsInteger :=l_yearno-2;
prepare;
open;
if RecordCount>0 then cunt:=Fields[0].AsInteger ;
end;
if cunt>0 then
begin
Query.Close;
Query.SQL.Clear ;
Query.SQL.Add(' select months from sbdu_pswgcase where psseno=:param1 and yearno=:param2');
Query.ParamByName('param1').AsInteger :=l_psseno;
Query.ParamByName('param2').AsInteger :=l_yearno-1;
Query.Prepare ;
Query.Open ;
if Query.RecordCount >0 then mon:=Query.Fields[0].AsInteger else Result:=0 ;
if mon>6 then
begin
i :=mon-6;
Result:=i;;
end else
begin
i :=0;
Result:=i;
end ;
end else
begin
Query.Close ;
Query.SQL.Clear ;
Query.SQL.Add('select months from sbdu_pswgcase where psseno=:param1 and yearno=:param2');
Query.ParamByName('param1').AsInteger :=l_psseno;
Query.ParamByName('param2').AsInteger :=l_yearno-1;
Query.Prepare ;
Query.Open ;
if Query.RecordCount >0 then mon:=Query.Fields[0].AsInteger else Result:=0;
if mon>6 then
begin
i :=6;
Result:=i;
end else
begin
i :=mon;
Result:=i;
end ;
end ;
except
Result:=0;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -