D7myGuhang/染整计划(DyeingFinishingPlan.dll)/U_GetDllForm.pas
DESKTOP-E401PHE\Administrator b27e54cd55 0
2025-08-13 10:59:27 +08:00

601 lines
18 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_iniParam, U_ProductOrderList, U_ProductOrderLBNameSet,
U_MarkingInspection, U_JYOrderCDList, U_OrderProgress, U_JYOrderCDListGH,
U_TableInspection;
/////////////////////////////////////////////////////////////////
// 功能说明:取Dll中得窗体 //
// 参数说明App>>调用应用程序; //
// FormH>>调用窗口句柄 //
// FormID>>窗口号; //
// Language>>语言种类; //
// WinStyle>>窗口类型; //
/////////////////////////////////////////////////////////////////
var
frmProductOrderListLR, frmProductOrderListGL, frmProductOrderListCX: TfrmProductOrderList;
frmProductOrderLBNameSetDQX, frmProductOrderLBNameSetGQX: TfrmProductOrderLBNameSet;
frmJYOrderCDListCX, frmJYOrderCDListGL, frmJYOrderCDListCPGL, frmJYOrderCDListCPCX, frmJYOrderCDListSHGL, frmJYOrderCDListHHGL: TfrmJYOrderCDList;
frmJYOrderCDListGH: TfrmJYOrderCDListGH; //检验信息汇总
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 := '139.224.59.117,7781';
// server := '.';
dtbase := 'guhangdata';
user := 'guhangsa';
pswd := 'rightsoft@8758';
// pswd := 'rightsoft';
DConString := 'Provider=SQLOLEDB.1;Password=' + pswd + ';Persist Security Info=True;User ID=' + user + ';Initial Catalog=' + dtbase + ';Data Source=' + server;
DConString := DataBaseStr;
// DName:='XYB';
// DParameters1 := '高权限';
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
101: //生产计划单录入
begin
bFound := FALSE;
for i := (App.MainForm.MDIChildCount - 1) downto 0 do
begin
if App.MainForm.MDIChildren[i].Caption = '生产计划单录入' then
begin
BringWindowToTop(frmProductOrderListLR.Handle);
bFound := TRUE;
Break;
end;
end;
if not bFound then
begin
frmProductOrderListLR := TfrmProductOrderList.Create(application.MainForm);
with frmProductOrderListLR do
begin
canshu1 := '录入';
Title := '生产计划单录入';
caption := Trim(Title);
FormStyle := mstyle;
windowState := mstate;
BorderStyle := mborderstyle;
//show;
end;
end
else
frmProductOrderListLR.BringToFront;
//句柄
mnewHandle := frmProductOrderListLR.Handle;
end;
102: //生产计划单管理
begin
bFound := FALSE;
for i := (App.MainForm.MDIChildCount - 1) downto 0 do
begin
if App.MainForm.MDIChildren[i].Caption = '生产计划单管理' then
begin
BringWindowToTop(frmProductOrderListGL.Handle);
bFound := TRUE;
Break;
end;
end;
if not bFound then
//if frmBaoGuanListBGZL=nil then
begin
frmProductOrderListGL := TfrmProductOrderList.Create(application.MainForm);
with frmProductOrderListGL do
begin
canshu1 := '高权限';
Title := '生产计划单管理';
caption := Trim(Title);
FormStyle := mstyle;
windowState := mstate;
BorderStyle := mborderstyle;
//show;
end;
end
else
frmProductOrderListGL.BringToFront;
//句柄
mnewHandle := frmProductOrderListGL.Handle;
end;
103: //生产计划单查询
begin
bFound := FALSE;
for i := (App.MainForm.MDIChildCount - 1) downto 0 do
begin
if App.MainForm.MDIChildren[i].Caption = '生产计划单查询' then
begin
BringWindowToTop(frmProductOrderListCX.Handle);
bFound := TRUE;
Break;
end;
end;
if not bFound then
begin
frmProductOrderListCX := TfrmProductOrderList.Create(application.MainForm);
with frmProductOrderListCX do
begin
Title := '生产计划单查询';
canshu1 := '查询';
caption := Trim(Title);
FormStyle := mstyle;
windowState := mstate;
BorderStyle := mborderstyle;
//show;
end;
end
else
frmProductOrderListCX.BringToFront;
//句柄
mnewHandle := frmProductOrderListCX.Handle;
end;
121: //标签皮重设置
begin
bFound := FALSE;
for i := (App.MainForm.MDIChildCount - 1) downto 0 do
begin
if App.MainForm.MDIChildren[i].Caption = '标签皮重设置' then
begin
BringWindowToTop(frmProductOrderLBNameSetDQX.Handle);
bFound := TRUE;
Break;
end;
end;
if not bFound then
begin
frmProductOrderLBNameSetDQX := TfrmProductOrderLBNameSet.Create(application.MainForm);
with frmProductOrderLBNameSetDQX do
begin
Title := '标签皮重设置';
canshu1 := '低权限';
caption := Trim(Title);
FormStyle := mstyle;
windowState := mstate;
BorderStyle := mborderstyle;
//show;
end;
end
else
frmProductOrderLBNameSetDQX.BringToFront;
//句柄
mnewHandle := frmProductOrderLBNameSetDQX.Handle;
end;
122: //标签皮重设置(高权限)
begin
bFound := FALSE;
for i := (App.MainForm.MDIChildCount - 1) downto 0 do
begin
if App.MainForm.MDIChildren[i].Caption = '标签皮重设置(高权限)' then
begin
BringWindowToTop(frmProductOrderLBNameSetGQX.Handle);
bFound := TRUE;
Break;
end;
end;
if not bFound then
begin
frmProductOrderLBNameSetGQX := TfrmProductOrderLBNameSet.Create(application.MainForm);
with frmProductOrderLBNameSetGQX do
begin
Title := '标签皮重设置(高权限)';
caption := Trim(Title);
FormStyle := mstyle;
windowState := mstate;
BorderStyle := mborderstyle;
//show;
end;
end
else
frmProductOrderLBNameSetGQX.BringToFront;
//句柄
mnewHandle := frmProductOrderLBNameSetGQX.Handle;
end;
311: //成品检验
begin
if frmMarkingInspection = nil then
begin
frmMarkingInspection := TfrmMarkingInspection.Create(application.MainForm);
with frmMarkingInspection do
begin
caption := Trim(Title);
FormStyle := mstyle;
windowState := mstate;
BorderStyle := mborderstyle;
//show;
end;
end
else
frmMarkingInspection.BringToFront;
//句柄
mnewHandle := frmMarkingInspection.Handle;
end;
312: //翻布检验
begin
if frmTableInspection = nil then
begin
frmTableInspection := TfrmTableInspection.Create(application.MainForm);
with frmTableInspection do
begin
caption := Trim(Title);
FormStyle := mstyle;
windowState := mstate;
BorderStyle := mborderstyle;
//show;
end;
end
else
frmTableInspection.BringToFront;
//句柄
mnewHandle := frmTableInspection.Handle;
end;
411: //检验信息管理
begin
bFound := FALSE;
for i := (App.MainForm.MDIChildCount - 1) downto 0 do
begin
if App.MainForm.MDIChildren[i].Caption = '检验信息管理' then
begin
BringWindowToTop(frmJYOrderCDListGL.Handle);
bFound := TRUE;
Break;
end;
end;
if not bFound then
begin
frmJYOrderCDListGL := TfrmJYOrderCDList.Create(application.MainForm);
with frmJYOrderCDListGL do
begin
Title := '检验信息管理';
canshu1 := '管理';
caption := Trim(Title);
FormStyle := mstyle;
windowState := mstate;
BorderStyle := mborderstyle;
//show;
end;
end
else
frmJYOrderCDListGL.BringToFront;
//句柄
mnewHandle := frmJYOrderCDListGL.Handle;
end;
412: //检验信息查询
begin
bFound := FALSE;
for i := (App.MainForm.MDIChildCount - 1) downto 0 do
begin
if App.MainForm.MDIChildren[i].Caption = '检验信息查询' then
begin
BringWindowToTop(frmJYOrderCDListCX.Handle);
bFound := TRUE;
Break;
end;
end;
if not bFound then
begin
frmJYOrderCDListCX := TfrmJYOrderCDList.Create(application.MainForm);
with frmJYOrderCDListCX do
begin
Title := '检验信息查询';
canshu1 := '查询';
caption := Trim(Title);
FormStyle := mstyle;
windowState := mstate;
BorderStyle := mborderstyle;
//show;
end;
end
else
frmJYOrderCDListCX.BringToFront;
//句柄
mnewHandle := frmJYOrderCDListCX.Handle;
end;
413: //次品管理
begin
bFound := FALSE;
for i := (App.MainForm.MDIChildCount - 1) downto 0 do
begin
if App.MainForm.MDIChildren[i].Caption = '次品管理' then
begin
BringWindowToTop(frmJYOrderCDListCPGL.Handle);
bFound := TRUE;
Break;
end;
end;
if not bFound then
begin
frmJYOrderCDListCPGL := TfrmJYOrderCDList.Create(application.MainForm);
with frmJYOrderCDListCPGL do
begin
Title := '次品管理';
canshu1 := '次品管理';
caption := Trim(Title);
FormStyle := mstyle;
windowState := mstate;
BorderStyle := mborderstyle;
//show;
end;
end
else
frmJYOrderCDListCPGL.BringToFront;
//句柄
mnewHandle := frmJYOrderCDListCPGL.Handle;
end;
414: //死货管理
begin
bFound := FALSE;
for i := (App.MainForm.MDIChildCount - 1) downto 0 do
begin
if App.MainForm.MDIChildren[i].Caption = '死货管理' then
begin
BringWindowToTop(frmJYOrderCDListSHGL.Handle);
bFound := TRUE;
Break;
end;
end;
if not bFound then
begin
frmJYOrderCDListSHGL := TfrmJYOrderCDList.Create(application.MainForm);
with frmJYOrderCDListSHGL do
begin
Title := '死货管理';
canshu1 := '死货管理';
caption := Trim(Title);
FormStyle := mstyle;
windowState := mstate;
BorderStyle := mborderstyle;
//show;
end;
end
else
frmJYOrderCDListSHGL.BringToFront;
//句柄
mnewHandle := frmJYOrderCDListSHGL.Handle;
end;
416: //活货管理
begin
bFound := FALSE;
for i := (App.MainForm.MDIChildCount - 1) downto 0 do
begin
if App.MainForm.MDIChildren[i].Caption = '活货管理' then
begin
BringWindowToTop(frmJYOrderCDListHHGL.Handle);
bFound := TRUE;
Break;
end;
end;
if not bFound then
begin
frmJYOrderCDListHHGL := TfrmJYOrderCDList.Create(application.MainForm);
with frmJYOrderCDListHHGL do
begin
Title := '活货管理';
canshu1 := '活货管理';
caption := Trim(Title);
FormStyle := mstyle;
windowState := mstate;
BorderStyle := mborderstyle;
//show;
end;
end
else
frmJYOrderCDListHHGL.BringToFront;
//句柄
mnewHandle := frmJYOrderCDListHHGL.Handle;
end;
417: //次品查询
begin
bFound := FALSE;
for i := (App.MainForm.MDIChildCount - 1) downto 0 do
begin
if App.MainForm.MDIChildren[i].Caption = '次品查询' then
begin
BringWindowToTop(frmJYOrderCDListCPCX.Handle);
bFound := TRUE;
Break;
end;
end;
if not bFound then
begin
frmJYOrderCDListCPCX := TfrmJYOrderCDList.Create(application.MainForm);
with frmJYOrderCDListCPCX do
begin
Title := '次品查询';
canshu1 := '次品查询';
caption := Trim(Title);
FormStyle := mstyle;
windowState := mstate;
BorderStyle := mborderstyle;
//show;
end;
end
else
frmJYOrderCDListCPCX.BringToFront;
//句柄
mnewHandle := frmJYOrderCDListCPCX.Handle;
end;
421: //检验信息汇总
begin
bFound := FALSE;
for i := (App.MainForm.MDIChildCount - 1) downto 0 do
begin
if App.MainForm.MDIChildren[i].Caption = '检验信息汇总' then
begin
BringWindowToTop(frmJYOrderCDListGH.Handle);
bFound := TRUE;
Break;
end;
end;
if not bFound then
begin
frmJYOrderCDListGH := TfrmJYOrderCDListGH.Create(application.MainForm);
with frmJYOrderCDListGH do
begin
Title := '检验信息汇总';
canshu1 := '检验信息汇总';
caption := Trim(Title);
FormStyle := mstyle;
windowState := mstate;
BorderStyle := mborderstyle;
//show;
end;
end
else
frmJYOrderCDListGH.BringToFront;
//句柄
mnewHandle := frmJYOrderCDListGH.Handle;
end;
end;
Result := mnewHandle;
// NewDllApp := Application;
end;
function GetsysParam(muserId: pchar; fparam1: pchar): Boolean;
begin
result := true;
//////////////////////////////
shortDateFormat := 'yyyy-MM-dd';
//服务器日期
with DataLink_DyeingFinishingPlan.AdoDataLink do
begin
close;
sql.Clear;
sql.Add('select getDate()as dt');
open;
DServerDate := fieldByName('dt').AsDatetime;
end;
result := true;
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_DyeingFinishingPlan) then
DataLink_DyeingFinishingPlan := TDataLink_DyeingFinishingPlan.Create(Application);
try
with DataLink_DyeingFinishingPlan.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_DyeingFinishingPlan.Free;
// Application := OldDllApp;
initialization
CoInitialize(nil);
dxUnitsLoader.Initialize;
finalization
DataLink_DyeingFinishingPlan.Free;
application := NewDllApp;
dxUnitsLoader.Finalize;
end.