📄 unitfun.pas
字号:
unit unitFun;
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
// 该系统源码归青岛东亚电子衡器有限公司版权所有
// Author:HaiBin
// Email:qdseashore@163.com DateTime:2005.06.22
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
interface
uses sysutils,DB,ADODB,Dialogs, Windows;
Type
Tfun=Class
public
function CheckUserLv(strUserID: string;strFrmID:string;var isRead:boolean;var isDelete:boolean;var isModify:boolean):boolean;
function GetDevicePortSetup(intPort:integer;strSet:string;intBuff:integer):boolean;
procedure ReadDevicePortSetup;
function GetJianJinNo:string;
procedure MainfromDictIni;
function GetDictInfo(strTB,strFI:string):String; //获取字典表相应字段的信息
end;
var
strFengefu:string;
implementation
uses unitMain;
{ Tfun }
function Tfun.CheckUserLv(strUserID: string;strFrmID:string;var isRead:boolean;var isDelete:boolean;var isModify:boolean):boolean;
var
tmpAdoConn:TAdoConnection;
tmpAdoQuery:TADOQuery;
tmpSQL:string;
tmpadoConnstr:String;
begin
Try
tmpadoConnstr:='Provider=Microsoft.Jet.OLEDB.4.0;Data Source='+ ExtractFilePath(Paramstr(0)) +'weight.mdb;Persist Security Info=False;Jet OLEDB:Database Password=qdseashore960501';
isRead:=false;
isDelete:=false;
isModify:=false;
tmpADOConn:=TAdoConnection.Create(nil);
if Not tmpADOCOnn.Connected then
begin
tmpADOConn.KeepConnection:=false;
tmpADOConn.ConnectionString:=tmpadoConnstr;
tmpADOConn.LoginPrompt:=False;
tmpADOConn.Open;
end;
tmpAdoQuery:=TADOQuery.Create(nil);
tmpADOQuery.Connection:=tmpAdoCOnn;
tmpAdoQuery.SQL.Clear;
tmpSQL:='Select * from uLevel Where frmLv=' + quotedstr(strFrmID) + ' and uManage=' + quotedstr(strUserID);
tmpADOQuery.SQL.Add(tmpSQL);
tmpADOQuery.Open;
if tmpADOQuery.RecordCount> 0 then
begin
isRead:=tmpAdoQuery.FieldByName('Read').AsBoolean;
isDelete:=tmpAdoQuery.FieldByName('Delete').AsBoolean;
isModify:=tmpADOQuery.FieldByName('Modify').AsBoolean;
Result:=true;
end
else
begin
Result:=false;
isRead:=false;
isDelete:=false;
isModify:=false;
end;
Except
Result:=false;
isRead:=false;
isDelete:=false;
isModify:=false;
End;
end;
function Tfun.GetDevicePortSetup(intPort: integer; strSet: string;
intBuff: integer): boolean;
var
tmpB:boolean;
begin
//tmpB:=false;
if (intPort=0) or (Trim(strSet)='') then
begin
tmpB:=false;
end
else
begin
if frmMain.MSComm1.PortOpen=true then
begin
frmMain.MSComm1.PortOpen:=false;
end;
frmMain.MSComm1.InputMode:=0; //ASCII字符接收方式
frmMain.MSComm1.CommPort:=intPort; //端口号
frmMain.MSComm1.Settings:=strSet; //设置初始化参数.
frmMain.MSComm1.InBufferCount:=0; //清除缓冲数据
frmMain.MSComm1.RThreshold:=intBuff; //引发OnComm中的ComEvreceive
frmMain.MSComm1.PortOpen:=true; //打开端口
tmpB:=true;
end;
Result:=tmpB;
end;
function Tfun.GetDictInfo(strTB, strFI: string): String;
var
strR:String;
tmpAdoConn:TAdoConnection;
tmpAdoQuery:TADOQuery;
tmpSQL:string;
tmpadoConnstr:string;
begin
Try
tmpadoConnstr:='Provider=Microsoft.Jet.OLEDB.4.0;Data Source='+ ExtractFilePath(Paramstr(0)) +'weight.mdb;Persist Security Info=False;Jet OLEDB:Database Password=qdseashore960501';
if Trim(strTB)='' then
begin
strR:='';
Exit;
end;
if Trim(strFI)='' then
begin
strR:='';
Exit;
end;
tmpADOConn:=TAdoConnection.Create(nil);
tmpADOConn.KeepConnection:=false;
tmpADOConn.ConnectionString:=tmpadoConnstr;
tmpADOConn.LoginPrompt:=False;
tmpADOConn.Open;
tmpAdoQuery:=TADOQuery.Create(nil);
tmpADOQuery.Connection:=tmpAdoCOnn;
tmpAdoQuery.SQL.Clear;
tmpSQL:='Select [name] from ' + strTB + ' Where id = ' + quotedstr(strFI);
tmpADOQuery.SQL.Add(tmpSQL);
tmpADOQuery.Open;
if tmpADOQuery.RecordCount>0 then
begin
strR:=tmpADOQuery.FieldByName('name').AsString;
end
else
begin
strR:=strFI;
end;
Result:=strR;
tmpADOQuery.Close;
tmpADOQuery.Free;
tmpADOConn.Close;
tmpADOConn.Free;
Except
Result:=strFI;
End;
end;
function Tfun.GetJianJinNo: string;
var
str,strR:string;
tmpAdoConn:TAdoConnection;
tmpAdoQuery:TADOQuery;
tmpSQL:string;
intC:integer;
intS:Int64;
tmpadoConnstr:string;
begin
try
tmpadoConnstr:='Provider=Microsoft.Jet.OLEDB.4.0;Data Source='+ ExtractFilePath(Paramstr(0)) +'weight.mdb;Persist Security Info=False;Jet OLEDB:Database Password=qdseashore960501';
tmpADOConn:=TAdoConnection.Create(nil);
tmpADOConn.KeepConnection:=false;
tmpADOConn.ConnectionString:=tmpadoConnstr;
tmpADOConn.LoginPrompt:=False;
tmpADOConn.Open;
tmpAdoQuery:=TADOQuery.Create(nil);
tmpADOQuery.Connection:=tmpAdoCOnn;
tmpAdoQuery.SQL.Clear;
tmpSQL:='Select Max(ListID) as ListID from uMaster';
tmpADOQuery.SQL.Add(tmpSQL);
tmpADOQuery.Open;
if tmpADOQuery.RecordCount>0 then
begin
str:=tmpADOQuery.FieldByName('ListID').AsString;
val(str,intS,intC);
if intC=0 then
begin
intS:=intS+1;
str:=inttostr(intS);
case length(str) of
0:strR:='0000000000';
1:strR:='000000000'+str;
2:strR:='00000000'+ str;
3:strR:='0000000'+ str;
4:strR:='000000'+ str;
5:strR:='00000'+ str;
6:strR:='0000'+ str;
7:strR:='000'+ str;
8:strR:='00'+ str;
9:strR:='0'+ str;
10:strR:= str;
else
strR:='0000000000';
end;
end
else //不是数字型
begin
result:='0000000000';
end;
end;
result:=strR;
tmpADOQuery.Close;
tmpADOConn.Close;
tmpADOQuery.Free;
tmpADOCOnn.Free;
except
result:='0000000000';
end;
end;
procedure Tfun.MainfromDictIni;
var
sql,oldInfo,oldInfo1:string;
begin
try
with frmMain do
begin
oldInfo:=dbcCPH.Text;
//
dbcCPH.Clear;
sql:='select * from dChepaiQ';
adoQDict.close;
adoQDict.sql.clear;
adoQDict.sql.Add(sql);
adoQDict.open;
if adoQDict.recordcount>0 then
begin
while not adoQDict.eof do
begin
dbcCPH.Items.Add(adoQDict.FieldByName('name').AsString);
adoQDict.Next;
end;
end;
dbcCPH.Text:=oldInfo;
//
oldInfo:=dbcCPHN.Text;
dbcCPHN.Clear;
sql:='select * from dChepaiN';
adoQDict.close;
adoQDict.sql.clear;
adoQDict.sql.Add(sql);
adoQDict.open;
if adoQDict.recordcount>0 then
begin
while not adoQDict.eof do
begin
dbcCPHN.Items.Add(adoQDict.FieldByName('name').AsString);
adoQDict.Next;
end;
end;
dbcCPHN.Text:=oldInfo;
//
oldInfo:=dbcHPMC.Text;
dbcHPMC.Clear;
sql:='select * from dHuoPin';
adoQDict.close;
adoQDict.sql.clear;
adoQDict.sql.Add(sql);
adoQDict.open;
if adoQDict.recordcount>0 then
begin
while not adoQDict.eof do
begin
dbcHPMC.Items.Add(adoQDict.FieldByName('name').AsString);
adoQDict.Next;
end;
end;
dbcHPMC.Text:=oldInfo;
//
oldInfo:=dbcFHDW.Text;
oldInfo1:=dbcSHDW.Text;
dbcFHDW.Clear;
dbcSHDW.Clear;
sql:='select * from dDanWei';
adoQDict.close;
adoQDict.sql.clear;
adoQDict.sql.Add(sql);
adoQDict.open;
if adoQDict.recordcount>0 then
begin
while not adoQDict.eof do
begin
dbcFHDW.Items.Add(adoQDict.FieldByName('name').AsString);
dbcSHDW.Items.Add(adoQDict.FieldByName('name').AsString);
adoQDict.Next;
end;
end;
dbcFHDW.Text:=oldInfo;
dbcSHDW.Text:=oldInfo1;
//
dbcCPH.Refresh;
dbcCPHN.Refresh;
dbcHPMC.Refresh;
dbcFHDW.Refresh;
dbcSHDW.Refresh;
end;
except
//异常处理
end;
end;
procedure Tfun.ReadDevicePortSetup;
var
tmpAdoConn:TAdoConnection;
tmpAdoQuery:TADOQuery;
tmpSQL,strSet:string;
tmpadoConnstr:string;
begin
try
tmpadoConnstr:='Provider=Microsoft.Jet.OLEDB.4.0;Data Source='+ ExtractFilePath(Paramstr(0)) +'weight.mdb;Persist Security Info=False;Jet OLEDB:Database Password=qdseashore960501';
tmpADOConn:=TAdoConnection.Create(nil);
tmpADOConn.KeepConnection:=false;
tmpADOConn.ConnectionString:=tmpadoConnstr;
tmpADOConn.LoginPrompt:=False;
tmpADOConn.Open;
tmpAdoQuery:=TADOQuery.Create(nil);
tmpADOQuery.Connection:=tmpAdoCOnn;
tmpAdoQuery.SQL.Clear;
tmpSQL:='Select * from portconfig where id in (select currCofig from CurrPortCfg)';
tmpADOQuery.SQL.Add(tmpSQL);
tmpADOQuery.Open;
if tmpADOQuery.RecordCount>0 then
begin
strset:=tmpAdoQuery.FieldByName('sulv').AsString +','+tmpAdoQuery.FieldByName('jiou').AsString + ',' +
tmpAdoQuery.FieldByName('shujuwei').AsString + ',' + tmpAdoQuery.FieldByName('tingzhiwei').AsString;
GetDevicePortSetup(tmpAdoQuery.FieldByName('port').AsInteger,strset,tmpAdoQuery.FieldByName('huanchong').AsInteger);
strFengefu:=tmpADOQuery.FieldByName('fengefu').AsString;
end;
tmpADOQuery.Close;
tmpADOConn.Close;
tmpADOQuery.Free;
tmpADOCOnn.Free;
except
exit;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -