D7YPbaoying/样品仓库/U_GetDllForm.pas
DESKTOP-E401PHE\Administrator e505f1d7a5 ~
2025-04-30 16:02:03 +08:00

349 lines
9.2 KiB
ObjectPascal
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

unit U_GetDllForm;
interface
uses
Windows, Messages, forms, OleCtnrs, DateUtils, SysUtils, ADODB,IniFiles, dxcore,activeX;
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;
Function GetsysParam(muserId:pchar;fparam1:pchar):Boolean;
implementation
uses
U_DataLink,U_getDogServer,U_BpRklist,U_Bpcklist,U_Bpckchklist,U_Bpkclist,U_ZDYHelp,U_Bpkcsumlist,U_ZdyAttachmentBJ;
/////////////////////////////////////////////////////////////////
// 功能说明:取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:=GName;
DCode:=GName;
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 := '101.132.143.144,7781';
// server:='.';
dtbase := 'baoyingdata';
user := 'rtsa';
pswd := 'rightsoft@5740';
DConString := 'Provider=SQLOLEDB.1;Password='+pswd+';Persist Security Info=True;User ID='
+user+';Initial Catalog='+dtbase+';Data Source='+server;
IF trim(DataBaseStr)<>''then
DConString := DataBaseStr;
Parameters1:='样品仓库';
// Parameters2:='业务员';
// if GetLinkDog(DCurHandle,DConString)<0 then application.Terminate;
if not ConnData() then
begin
result:=0;
exit;
end;
GetsysParam('','');
// 定义窗口类型 、状态
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
frmZDYHelp:=TfrmZDYHelp.Create(Application);
with frmZDYHelp do
begin
flag:='YPCK';
flagname:='名称';
if ShowModal=1 then
begin
end;
free;
end;
end;
-2: //入库类型
begin
frmZDYHelp:=TfrmZDYHelp.Create(Application);
with frmZDYHelp do
begin
flag:='YPRKTYPE';
flagname:='名称';
fnote:=true;
if ShowModal=1 then
begin
end;
free;
end;
end;
-3: //出库类型
begin
frmZDYHelp:=TfrmZDYHelp.Create(Application);
with frmZDYHelp do
begin
flag:='YPCKTYPE';
flagname:='名称';
fnote:=true;
if ShowModal=1 then
begin
end;
free;
end;
end;
10: //成品入库
begin
if frmBpRklist=nil then
begin
frmBpRklist:= TfrmBpRklist.Create(application.MainForm);
with frmBpRklist do
begin
caption:=Trim(Title);
fCkName:=trim(Parameters1);
canshu1:=trim(Parameters2);
FormStyle := mstyle ;
windowState := mstate ;
BorderStyle := mborderstyle;
//show;
end;
end
else
frmBpRklist.BringToFront;
//句柄
mNewHandle:=frmBpRklist.Handle;
end;
20: //成品出库
begin
if frmBpCklist=nil then
begin
frmBpCklist:= TfrmBpCklist.Create(application.MainForm);
with frmBpCklist do
begin
caption:=Trim(Title);
fCkName:=trim(Parameters1);
canshu1:=trim(Parameters2);
FormStyle := mstyle ;
windowState := mstate ;
BorderStyle := mborderstyle;
//show;
end;
end
else
frmBpCklist.BringToFront;
//句柄
mNewHandle:=frmBpCklist.Handle;
end;
21: //成品出库审核
begin
if frmBpckchklist=nil then
begin
frmBpckchklist:= TfrmBpckchklist.Create(application.MainForm);
with frmBpckchklist do
begin
caption:=Trim(Title);
fCkName:=trim(Parameters1);
canshu1:=trim(Parameters2);
FormStyle := mstyle ;
windowState := mstate ;
BorderStyle := mborderstyle;
//show;
end;
end
else
frmBpckchklist.BringToFront;
//句柄
mNewHandle:=frmBpckchklist.Handle;
end;
30: //成品库存
begin
if frmBpkclist=nil then
begin
frmBpkclist:= TfrmBpkclist.Create(application.MainForm);
with frmBpkclist do
begin
caption:=Trim(Title);
fCkName:=trim(Parameters1);
FormStyle := mstyle ;
windowState := mstate ;
BorderStyle := mborderstyle;
//show;
end;
end
else
frmBpkclist.BringToFront;
//句柄
mNewHandle:=frmBpkclist.Handle;
end;
31: //成品库存汇总
begin
if frmBpkcsumlist=nil then
begin
frmBpkcsumlist:= TfrmBpkcsumlist.Create(application.MainForm);
with frmBpkcsumlist do
begin
caption:=Trim(Title);
fCkName:=trim(Parameters1);
canshu2:=trim(Parameters2);
FormStyle := mstyle ;
windowState := mstate ;
BorderStyle := mborderstyle;
//show;
end;
end
else
frmBpkcsumlist.BringToFront;
//句柄
mNewHandle:=frmBpkcsumlist.Handle;
end;
40: //样品报价
begin
if frmZdyAttachmentCB=nil then
begin
frmZdyAttachmentCB:= TfrmZdyAttachmentCB.Create(application.MainForm);
with frmZdyAttachmentCB do
begin
caption:=Trim(Title);
FormStyle := mstyle ;
windowState := mstate ;
BorderStyle := mborderstyle;
//show;
end;
end
else
frmZdyAttachmentCB.BringToFront;
//句柄
mNewHandle:=frmZdyAttachmentCB.Handle;
end;
end ; // end case
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');
finally
IniFile.Free;
end;
if not Assigned(YPCK_DataLink) then
YPCK_DataLink:=TYPCK_DataLink.Create(Application);
Try
with YPCK_DataLink.ADOLink do
begin
if not Connected then
begin
Connected:=false;
ConnectionString:=DConString;
LoginPrompt:=false;
Connected:=true;
// BaseData10_DataLink.Timer1.Enabled:=true;
end;
end;
Result:=true;
Except
Result:=false;
application.MessageBox('数据库连接失败!','错误',mb_Ok+ MB_ICONERROR);
end;
end;
//=========================================================
//获取系统参数
//=========================================================
Function GetsysParam(muserId:pchar;fparam1:pchar):Boolean;
begin
result:=true;
//////////////////////////////
shortDateFormat:='yyyy-MM-dd';
//服务器日期
with YPCK_DataLink.AdoDataLink do
begin
close;
sql.Clear;
sql.Add('select getDate()as dt');
open;
DServerDate:=fieldByName('dt').AsDatetime;
end;
result:=true;
end;
initialization
CoInitialize(nil);
dxUnitsLoader.Initialize;
finalization
YPCK_DataLink.Free;
application:=NewDllApp;
dxUnitsLoader.Finalize;
end.