📄 u_dm.pas
字号:
unit u_dm;
interface
uses
SysUtils, Classes, DB, ADODB,Dialogs,Forms,Controls;
type
TDM = class(TDataModule)
con1: TADOConnection;
EmployeeInfo: TADOQuery;
temp: TADOQuery;
AttendPunch: TADOQuery;
procedure DataModuleCreate(Sender: TObject);
private
{ Private declarations }
procedure LinkServer;
public
{ Public declarations }
function GetDeviceInfo(cDevID: integer;var IP: string; var Port,PassWord: integer;Var Spec: string):boolean;
end;
var
DM: TDM;
implementation
uses CommonUnit;
{$R *.dfm}
procedure TDM.LinkServer;
var
LoginPassword:string;
begin
// 数据库服务器
LoginPassword:=LoginPwd;
if Trim(SQLServer)='' then
begin
MsgBox('数据库服务器名称不能为空,请重新配置系统设置!',mtError,[mbOk]);
//Application.Terminate;
exit;
end;
if DBName='' then
begin
MsgBox('数据库名称不能为空,请重新配置系统设置!',mtError,[mbOk]);
exit;
end;
if LoginName='' then
begin
MsgBox('登陆用户名称不能为空,请重新配置系统设置',mtError,[mbOk]);
//Application.Terminate;
exit;
end;
try
Screen.Cursor:=crSQLWait;
if con1.Connected then con1.Close;
con1.ConnectionString:='Provider=SQLOLEDB.1;'
+'Persist Security Info=False;'
+'Initial Catalog='+DBName+';'
+'User ID='+LoginName+';'
+'Password='+LoginPassword+';'
+'Data Source='+SQLServer;
con1.Open;
except
Screen.Cursor:=crDefault;
//lbMsg.Caption:='连接到数据库失败';
MsgBox('连接到数据库失败,请检查'+#13#10
+'1.网络连接是否正常?'+#13#10
+'2.数据库服务器是否正确?'+#13#10
+'3.数据库名称是否正确?'+#13#10
+'4.登陆用户名称是否正确?'+#13#10
+'5.登陆密码是否正确?',mtError,[mbOk]);
//Application.Terminate;
exit;
end;
Screen.Cursor:=crDefault;
//if con1.Connected then RetValue:=True;
end;
//获取网络参数
function TDM.GetDeviceInfo(cDevID: integer;var IP: string; var Port,PassWord: integer;Var Spec: string):boolean;
begin
result := false;
with Temp do
begin
if active then close;
SQL.Text := 'select IP,Port,sysPwd,Spec from Device where DeviceID='+IntToStr(cDevID);
Open;
if not eof then
begin
IP := Fields[0].AsString;
Port := Fields[1].AsInteger;
PassWord := Fields[2].AsInteger;
Spec := Fields[3].AsString;
Result := true;
end;
end;
end;
procedure TDM.DataModuleCreate(Sender: TObject);
begin
LinkServer;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -