D7zzHanglin/坯布仓库(GreyClothWarehouse.dll)/U_GetDllForm.pas
DESKTOP-E401PHE\Administrator 4c4c37570c 0
2025-08-06 16:42:07 +08:00

423 lines
12 KiB
ObjectPascal
Raw 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, 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;
implementation
uses
U_DataLink, U_CpRkSaoMNew, U_CKProductBCPInList, U_SQSMCK, U_CPSMCK,
U_PBOuGLtList, U_PBOuGLtListHZ, U_PBOuGLtListBHHZ, U_CKProductBCPKCList,
U_CKProductBCPKCHZList;
/////////////////////////////////////////////////////////////////
// 功能说明:取Dll中得窗体 //
// 参数说明App>>调用应用程序; //
// FormH>>调用窗口句柄 //
// FormID>>窗口号; //
// Language>>语言种类; //
// WinStyle>>窗口类型; //
/////////////////////////////////////////////////////////////////
var
frmCKProductBCPInListPBGL, frmCKProductBCPInListPBCX: TfrmCKProductBCPInListPB;
frmCKProductBCPKCListPB, frmCKProductBCPKCListPBGL: TfrmCKProductBCPKCListPB;
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
i: Integer;
bFound: Boolean;
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 := '121.40.233.100,7781';
// server := '.';
dtbase := 'HANGLINdata';
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
101: //坯布入库扫描
begin
if frmCpRkSaoMNewPB = nil then
begin
frmCpRkSaoMNewPB := TfrmCpRkSaoMNewPB.Create(application.MainForm);
with frmCpRkSaoMNewPB do
begin
caption := Trim(Title);
FormStyle := mstyle;
windowState := mstate;
BorderStyle := mborderstyle;
//show;
end;
end
else
frmCpRkSaoMNewPB.BringToFront;
//句柄
mnewHandle := frmCpRkSaoMNewPB.Handle;
end;
111: //坯布入库管理
begin
bFound := FALSE;
for i := (App.MainForm.MDIChildCount - 1) downto 0 do
begin
if App.MainForm.MDIChildren[i].Caption = '坯布入库管理' then
begin
BringWindowToTop(frmCKProductBCPInListPBGL.Handle);
bFound := TRUE;
Break;
end;
end;
if not bFound then
//if frmBaoGuanListBGZL=nil then
begin
frmCKProductBCPInListPBGL := TfrmCKProductBCPInListPB.Create(application.MainForm);
with frmCKProductBCPInListPBGL do
begin
Title := '坯布入库管理';
caption := Trim(Title);
FormStyle := mstyle;
windowState := mstate;
BorderStyle := mborderstyle;
//show;
end;
end
else
frmCKProductBCPInListPBGL.BringToFront;
//句柄
mnewHandle := frmCKProductBCPInListPBGL.Handle;
end;
112: //坯布入库查询
begin
bFound := FALSE;
for i := (App.MainForm.MDIChildCount - 1) downto 0 do
begin
if App.MainForm.MDIChildren[i].Caption = '坯布入库查询' then
begin
BringWindowToTop(frmCKProductBCPInListPBCX.Handle);
bFound := TRUE;
Break;
end;
end;
if not bFound then
//if frmBaoGuanListBGZL=nil then
begin
frmCKProductBCPInListPBCX := TfrmCKProductBCPInListPB.Create(application.MainForm);
with frmCKProductBCPInListPBCX do
begin
Title := '坯布入库查询';
caption := Trim(Title);
FormStyle := mstyle;
windowState := mstate;
BorderStyle := mborderstyle;
//show;
end;
end
else
frmCKProductBCPInListPBCX.BringToFront;
//句柄
mnewHandle := frmCKProductBCPInListPBCX.Handle;
end;
201: //扫描出库
begin
if frmSQSMCK = nil then
begin
frmSQSMCK := TfrmSQSMCK.Create(application.MainForm);
with frmSQSMCK do
begin
caption := Trim(Title);
FormStyle := mstyle;
windowState := mstate;
BorderStyle := mborderstyle;
//show;
end;
end
else
frmSQSMCK.BringToFront;
//句柄
mnewHandle := frmSQSMCK.Handle;
end;
202: //次品出库
begin
if frmCPSMCK = nil then
begin
frmCPSMCK := TfrmCPSMCK.Create(application.MainForm);
with frmCPSMCK do
begin
caption := Trim(Title);
FormStyle := mstyle;
windowState := mstate;
BorderStyle := mborderstyle;
//show;
end;
end
else
frmCPSMCK.BringToFront;
//句柄
mnewHandle := frmCPSMCK.Handle;
end;
211: //出库管理
begin
if frmPBOuGLtList = nil then
begin
frmPBOuGLtList := TfrmPBOuGLtList.Create(application.MainForm);
with frmPBOuGLtList do
begin
caption := Trim(Title);
FormStyle := mstyle;
windowState := mstate;
BorderStyle := mborderstyle;
//show;
end;
end
else
frmPBOuGLtList.BringToFront;
//句柄
mnewHandle := frmPBOuGLtList.Handle;
end;
221: //出库汇总
begin
if frmPBOuGLtListHZ = nil then
begin
frmPBOuGLtListHZ := TfrmPBOuGLtListHZ.Create(application.MainForm);
with frmPBOuGLtListHZ do
begin
caption := Trim(Title);
FormStyle := mstyle;
windowState := mstate;
BorderStyle := mborderstyle;
//show;
end;
end
else
frmPBOuGLtListHZ.BringToFront;
//句柄
mnewHandle := frmPBOuGLtListHZ.Handle;
end;
231: //坯布出库编号汇总
begin
if frmPBOuGLtListBHHZ = nil then
begin
frmPBOuGLtListBHHZ := TfrmPBOuGLtListBHHZ.Create(application.MainForm);
with frmPBOuGLtListBHHZ do
begin
caption := Trim(Title);
FormStyle := mstyle;
windowState := mstate;
BorderStyle := mborderstyle;
//show;
end;
end
else
frmPBOuGLtListBHHZ.BringToFront;
//句柄
mnewHandle := frmPBOuGLtListBHHZ.Handle;
end;
311: //坯布库存列表
begin
bFound := FALSE;
for i := (App.MainForm.MDIChildCount - 1) downto 0 do
begin
if App.MainForm.MDIChildren[i].Caption = '坯布库存列表' then
begin
BringWindowToTop(frmCKProductBCPKCListPB.Handle);
bFound := TRUE;
Break;
end;
end;
if not bFound then
begin
frmCKProductBCPKCListPB := TfrmCKProductBCPKCListPB.Create(application.MainForm);
with frmCKProductBCPKCListPB do
begin
Title := '坯布库存列表';
caption := Trim(Title);
FormStyle := mstyle;
windowState := mstate;
BorderStyle := mborderstyle;
//show;
end;
end
else
frmCKProductBCPKCListPB.BringToFront;
//句柄
mnewHandle := frmCKProductBCPKCListPB.Handle;
end;
312: //坯布库存管理
begin
bFound := FALSE;
for i := (App.MainForm.MDIChildCount - 1) downto 0 do
begin
if App.MainForm.MDIChildren[i].Caption = '坯布库存管理' then
begin
BringWindowToTop(frmCKProductBCPKCListPBGL.Handle);
bFound := TRUE;
Break;
end;
end;
if not bFound then
begin
frmCKProductBCPKCListPBGL := TfrmCKProductBCPKCListPB.Create(application.MainForm);
with frmCKProductBCPKCListPBGL do
begin
Title := '坯布库存管理';
canshu1 := '管理';
caption := Trim(Title);
FormStyle := mstyle;
windowState := mstate;
BorderStyle := mborderstyle;
//show;
end;
end
else
frmCKProductBCPKCListPBGL.BringToFront;
//句柄
mnewHandle := frmCKProductBCPKCListPBGL.Handle;
end;
321: //坯布库存汇总列表
begin
if frmCKProductBCPKCHZListPB = nil then
begin
frmCKProductBCPKCHZListPB := TfrmCKProductBCPKCHZListPB.Create(application.MainForm);
with frmCKProductBCPKCHZListPB do
begin
caption := Trim(Title);
FormStyle := mstyle;
windowState := mstate;
BorderStyle := mborderstyle;
//show;
end;
end
else
frmCKProductBCPKCHZListPB.BringToFront;
//句柄
mnewHandle := frmCKProductBCPKCHZListPB.Handle;
end;
end;
Result := mnewHandle;
// NewDllApp := Application;
end;
//===========================================================
//建立数据库连接池
//===========================================================
function ConnData(): Boolean;
begin
if not Assigned(DataLink_GreyClothWarehouse) then
DataLink_GreyClothWarehouse := TDataLink_GreyClothWarehouse.Create(Application);
try
with DataLink_GreyClothWarehouse.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_GreyClothWarehouse.Free;
// Application := OldDllApp;
initialization
CoInitialize(nil);
dxUnitsLoader.Initialize;
finalization
DataLink_GreyClothWarehouse.Free;
application := NewDllApp;
dxUnitsLoader.Finalize;
end.