389 lines
10 KiB
ObjectPascal
389 lines
10 KiB
ObjectPascal
|
||
|
||
unit U_GetDllForm;
|
||
interface
|
||
uses
|
||
Windows,Messages,forms,OleCtnrs,DateUtils,SysUtils,ADODB,IniFiles;
|
||
function GetDllForm(App:Tapplication; FormH:hwnd; FormID:integer;
|
||
Language: integer; WinStyle:integer;
|
||
GCode: Pchar; GName: Pchar; DataBase:Pchar;Title:PChar;
|
||
Parameters1:PChar;Parameters2:PChar;Parameters3:PChar;Parameters4:PChar;
|
||
Parameters5:PChar;Parameters6:PChar;Parameters7:PChar;Parameters8:PChar;
|
||
Parameters9:PChar;Parameters10:PChar;DataBaseStr:PChar):hwnd;export;stdcall;
|
||
function ConnData():Boolean;
|
||
|
||
implementation
|
||
uses
|
||
U_DataLink,U_PRTOrderList,U_BPJHList,U_BPDHList,U_BPTPList,U_BPKCList,
|
||
U_CPKCList,U_JGZKCList,U_GDRKList,U_GDCKList,U_GDPBDHList,U_GDTPList,U_GDQSList;
|
||
|
||
/////////////////////////////////////////////////////////////////
|
||
// 功能说明:取Dll中得窗体 //
|
||
// 参数说明:App>>调用应用程序; //
|
||
// FormH>>调用窗口句柄 ; //
|
||
// FormID>>窗口号; //
|
||
// Language>>语言种类; //
|
||
// WinStyle>>窗口类型; //
|
||
/////////////////////////////////////////////////////////////////
|
||
function GetDllForm(App:Tapplication; FormH:hwnd; FormID:integer;
|
||
Language: integer; WinStyle:integer;
|
||
GCode: Pchar; GName: Pchar; DataBase:Pchar;Title:PChar;
|
||
Parameters1:PChar;Parameters2:PChar;Parameters3:PChar;Parameters4:PChar;
|
||
Parameters5:PChar;Parameters6:PChar;Parameters7:PChar;Parameters8:PChar;
|
||
Parameters9:PChar;Parameters10:PChar;
|
||
DataBaseStr:PChar):hwnd;
|
||
|
||
var
|
||
mnewHandle: hwnd;
|
||
mstyle: TFormStyle; // 0:子窗口; 1:普通窗口
|
||
mstate: TWindowState;
|
||
mborderstyle: TFormBorderStyle;
|
||
begin
|
||
mNewHandle:=0;
|
||
DName:=PChar(GName);
|
||
DCode:=PChar(GCode);
|
||
DdataBase:=DataBase;
|
||
DTitCaption:=Title;
|
||
DParameters1:=Parameters1;
|
||
DParameters2:=Parameters2;
|
||
DParameters3:=Parameters3;
|
||
DParameters4:=Parameters4;
|
||
DParameters5:=Parameters5;
|
||
DParameters6:=Parameters6;
|
||
DParameters7:=Parameters7;
|
||
DParameters8:=Parameters8;
|
||
DParameters9:=Parameters9;
|
||
DParameters10:=Parameters10;
|
||
|
||
|
||
MainApplication:=App;
|
||
DCurHandle:=FormH;
|
||
IsDelphiLanguage:= Language;
|
||
|
||
Application:=TApplication(App);
|
||
DCurHandle:=0;
|
||
|
||
|
||
//赋值链接字符串
|
||
SetLength(server, 255);
|
||
SetLength(dtbase, 255);
|
||
SetLength(user, 255);
|
||
SetLength(pswd, 255);
|
||
|
||
server:='.';
|
||
// server:='122.224.56.214,9997';
|
||
dtbase:='tengyuedata';
|
||
user:='sa';
|
||
|
||
// pswd:='rightsoft@123';
|
||
pswd:='rightsoft';
|
||
DConString := 'Provider=SQLOLEDB.1;Password='+pswd+';Persist Security Info=True;User ID='
|
||
+user+';Initial Catalog='+dtbase+';Data Source='+server;
|
||
DConString:=DataBaseStr;
|
||
// DName:='周高祥';
|
||
|
||
// DParameters1:='高权限'; //高权限
|
||
//DParameters3:='1';
|
||
if not ConnData() then
|
||
begin
|
||
result:=0;
|
||
exit;
|
||
end;
|
||
|
||
// 定义窗口类型 、状态
|
||
if WinStyle=0 then
|
||
begin
|
||
mstyle := fsMDIChild ;
|
||
mstate := wsMaximized ;
|
||
mborderstyle := bsSizeable;
|
||
end
|
||
else
|
||
begin
|
||
mstyle := fsNormal ;
|
||
mstate := wsNormal ;
|
||
mborderstyle := bsSizeable;
|
||
end;
|
||
/////////////////////
|
||
//调用子模块窗口
|
||
case FormId of
|
||
-1: //跟单签到
|
||
begin
|
||
if frmGDQSList=nil then
|
||
begin
|
||
frmGDQSList:= TfrmGDQSList.Create(application.MainForm);
|
||
with frmGDQSList do
|
||
begin
|
||
caption:=Trim(Title);
|
||
FormStyle := mstyle ;
|
||
windowState := mstate ;
|
||
BorderStyle := mborderstyle;
|
||
//show;
|
||
end;
|
||
end
|
||
else
|
||
frmGDQSList.BringToFront;
|
||
//句柄
|
||
mNewHandle:=frmGDQSList.Handle;
|
||
end ;
|
||
0: //生产指示单管理
|
||
begin
|
||
if frmPRTOrderList=nil then
|
||
begin
|
||
frmPRTOrderList:= TfrmPRTOrderList.Create(application.MainForm);
|
||
with frmPRTOrderList do
|
||
begin
|
||
caption:=Trim(Title);
|
||
FormStyle := mstyle ;
|
||
windowState := mstate ;
|
||
BorderStyle := mborderstyle;
|
||
//show;
|
||
end;
|
||
end
|
||
else
|
||
frmPRTOrderList.BringToFront;
|
||
//句柄
|
||
mNewHandle:=frmPRTOrderList.Handle;
|
||
end ;
|
||
1: //布匹到货计划
|
||
begin
|
||
if frmBPJHList=nil then
|
||
begin
|
||
frmBPJHList:= TfrmBPJHList.Create(application.MainForm);
|
||
with frmBPJHList do
|
||
begin
|
||
caption:=Trim(Title);
|
||
FormStyle := mstyle ;
|
||
windowState := mstate ;
|
||
BorderStyle := mborderstyle;
|
||
//show;
|
||
end;
|
||
end
|
||
else
|
||
frmBPJHList.BringToFront;
|
||
//句柄
|
||
mNewHandle:=frmBPJHList.Handle;
|
||
end ;
|
||
2: //布匹到货
|
||
begin
|
||
if frmBPDHList=nil then
|
||
begin
|
||
frmBPDHList:= TfrmBPDHList.Create(application.MainForm);
|
||
with frmBPDHList do
|
||
begin
|
||
caption:=Trim(Title);
|
||
FormStyle := mstyle ;
|
||
windowState := mstate ;
|
||
BorderStyle := mborderstyle;
|
||
//show;
|
||
end;
|
||
end
|
||
else
|
||
frmBPDHList.BringToFront;
|
||
//句柄
|
||
mNewHandle:=frmBPDHList.Handle;
|
||
end ;
|
||
3: //布匹生产
|
||
begin
|
||
if frmBPTPList=nil then
|
||
begin
|
||
frmBPTPList:= TfrmBPTPList.Create(application.MainForm);
|
||
with frmBPTPList do
|
||
begin
|
||
caption:=Trim(Title);
|
||
FormStyle := mstyle ;
|
||
windowState := mstate ;
|
||
BorderStyle := mborderstyle;
|
||
//show;
|
||
end;
|
||
end
|
||
else
|
||
frmBPTPList.BringToFront;
|
||
//句柄
|
||
mNewHandle:=frmBPTPList.Handle;
|
||
end ;
|
||
5: //坯布库存
|
||
begin
|
||
if frmBPKCList=nil then
|
||
begin
|
||
frmBPKCList:= TfrmBPKCList.Create(application.MainForm);
|
||
with frmBPKCList do
|
||
begin
|
||
caption:=Trim(Title);
|
||
FormStyle := mstyle ;
|
||
windowState := mstate ;
|
||
BorderStyle := mborderstyle;
|
||
//show;
|
||
end;
|
||
end
|
||
else
|
||
frmBPKCList.BringToFront;
|
||
//句柄
|
||
mNewHandle:=frmBPKCList.Handle;
|
||
end ;
|
||
6: //加工中库存
|
||
begin
|
||
if frmJGZKCList=nil then
|
||
begin
|
||
frmJGZKCList:= TfrmJGZKCList.Create(application.MainForm);
|
||
with frmJGZKCList do
|
||
begin
|
||
caption:=Trim(Title);
|
||
FormStyle := mstyle ;
|
||
windowState := mstate ;
|
||
BorderStyle := mborderstyle;
|
||
//show;
|
||
end;
|
||
end
|
||
else
|
||
frmJGZKCList.BringToFront;
|
||
//句柄
|
||
mNewHandle:=frmJGZKCList.Handle;
|
||
end ;
|
||
7: //成品入库查询
|
||
begin
|
||
if frmGDRKList=nil then
|
||
begin
|
||
frmGDRKList:= TfrmGDRKList.Create(application.MainForm);
|
||
with frmGDRKList do
|
||
begin
|
||
caption:=Trim(Title);
|
||
FormStyle := mstyle ;
|
||
windowState := mstate ;
|
||
BorderStyle := mborderstyle;
|
||
//show;
|
||
end;
|
||
end
|
||
else
|
||
frmGDRKList.BringToFront;
|
||
//句柄
|
||
mNewHandle:=frmGDRKList.Handle;
|
||
end ;
|
||
8: //成品出库查询
|
||
begin
|
||
if frmGDCKList=nil then
|
||
begin
|
||
frmGDCKList:= TfrmGDCKList.Create(application.MainForm);
|
||
with frmGDCKList do
|
||
begin
|
||
caption:=Trim(Title);
|
||
FormStyle := mstyle ;
|
||
windowState := mstate ;
|
||
BorderStyle := mborderstyle;
|
||
//show;
|
||
end;
|
||
end
|
||
else
|
||
frmGDCKList.BringToFront;
|
||
//句柄
|
||
mNewHandle:=frmGDCKList.Handle;
|
||
end ;
|
||
9: //成品库存
|
||
begin
|
||
if frmCPKCList=nil then
|
||
begin
|
||
frmCPKCList:= TfrmCPKCList.Create(application.MainForm);
|
||
with frmCPKCList do
|
||
begin
|
||
caption:=Trim(Title);
|
||
FormStyle := mstyle ;
|
||
windowState := mstate ;
|
||
BorderStyle := mborderstyle;
|
||
//show;
|
||
end;
|
||
end
|
||
else
|
||
frmCPKCList.BringToFront;
|
||
//句柄
|
||
mNewHandle:=frmCPKCList.Handle;
|
||
end ;
|
||
10: //坯布到货查询
|
||
begin
|
||
if frmGDPBDHList=nil then
|
||
begin
|
||
frmGDPBDHList:= TfrmGDPBDHList.Create(application.MainForm);
|
||
with frmGDPBDHList do
|
||
begin
|
||
caption:=Trim(Title);
|
||
FormStyle := mstyle ;
|
||
windowState := mstate ;
|
||
BorderStyle := mborderstyle;
|
||
//show;
|
||
end;
|
||
end
|
||
else
|
||
frmGDPBDHList.BringToFront;
|
||
//句柄
|
||
mNewHandle:=frmGDPBDHList.Handle;
|
||
end ;
|
||
11: //坯布投坯查询
|
||
begin
|
||
if frmGDTPList=nil then
|
||
begin
|
||
frmGDTPList:= TfrmGDTPList.Create(application.MainForm);
|
||
with frmGDTPList do
|
||
begin
|
||
caption:=Trim(Title);
|
||
FormStyle := mstyle ;
|
||
windowState := mstate ;
|
||
BorderStyle := mborderstyle;
|
||
//show;
|
||
end;
|
||
end
|
||
else
|
||
frmGDTPList.BringToFront;
|
||
//句柄
|
||
mNewHandle:=frmGDTPList.Handle;
|
||
end ;
|
||
|
||
|
||
|
||
|
||
end ;
|
||
|
||
Result:= mnewHandle;
|
||
NewDllApp:=Application ;
|
||
end;
|
||
//===========================================================
|
||
//建立数据库连接池
|
||
//===========================================================
|
||
function ConnData():Boolean;
|
||
var
|
||
IniFile: TIniFile;
|
||
begin
|
||
try
|
||
IniFile := TIniFile.Create(ExtractFilePath(Application.ExeName) + 'SYSTEMSET.INI');
|
||
PicSvr := IniFile.ReadString('SERVER', '服务器地址','127.0.0.1');
|
||
UserDataFlag:=IniFile.ReadString('SERVER', '服务器地址类型','-1');
|
||
finally
|
||
IniFile.Free;
|
||
end;
|
||
if not Assigned(DataLink_OrderAndGD) then
|
||
DataLink_OrderAndGD:=TDataLink_OrderAndGD.Create(Application);
|
||
Try
|
||
with DataLink_OrderAndGD.ADOLink do
|
||
begin
|
||
//if not Connected then
|
||
begin
|
||
Connected:=false;
|
||
ConnectionString:=DConString;
|
||
LoginPrompt:=false;
|
||
Connected:=true;
|
||
end;
|
||
end;
|
||
Result:=true;
|
||
Except
|
||
Result:=false;
|
||
application.MessageBox('数据库连接失败!','错误',mb_Ok+ MB_ICONERROR);
|
||
end;
|
||
|
||
end;
|
||
INITIALIZATION
|
||
OldDllApp:= Application;
|
||
|
||
FINALIZATION
|
||
DataLink_OrderAndGD.Free;
|
||
Application := OldDllApp;
|
||
|
||
end.
|
||
|