D7myYunxiang/样品新云翔(YPGLBOM.dll)/U_GetDllForm.pas
DESKTOP-E401PHE\Administrator 452c7e6140 样品新云翔修改
2025-09-25 15:36:55 +08:00

509 lines
13 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;
implementation
uses
U_DataLink, U_MLMange, U_CPType_TP, U_CPManage_TP, U_SLT_BF1,
U_BPZdy_LRSHK_BF, U_MLMangeRS, U_ZdyAttachGYSX, U_BPZdy_LRGX, U_BPZdy_LRPB,
U_BPZdy_LRSHK, U_MLMangeRS_SMCX, U_BPZdy_TJHXK, U_CPType_TJTP,
U_ZdyAttachmentX, U_ZdyAttachGYSX_WL, U_ZdyAttachGYSX_FL, U_ZdyAttachGYSX_RC,
U_ZdyAttachGYSX_SJG, U_BPZdy_LRTJ, U_MLMangeTJ, U_BPZdy_LRYH, U_BPZdy_LRPB_M,
U_BPZdy_LRSHK_M, U_BPZdy_Panel_RSCX, U_BPZdy_Panel_TJCX, U_MLMangeYH,
U_BPZdy_LRXH_M, U_MLMangeXH, U_BPZdy_TJHXK_M3, U_HXKYH, U_HXKTJ, U_HXKYHK,
U_GYSelect, U_MLMange_XH, U_MLHZGL,U_iniParam;
/////////////////////////////////////////////////////////////////
// 功能说明:取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);
if Trim(DataBaseStr) = '' then
begin
server := '106.14.113.234,7781';
dtbase := 'yunxiangdata';
user := 'sa';
pswd := 'rightsoft@123';
DConString := 'Provider=SQLOLEDB.1;Password=' + pswd + ';Persist Security Info=True;User ID=' + user + ';Initial Catalog=' + dtbase + ';Data Source=' + server;
end
else
begin
DConString := DataBaseStr;
end;
// DParameters1 := '高权限';
// DParameters3:='1';
if not ConnData() then
begin
result := 0;
exit;
end;
if IsINIFile() then
ReadINIFile()
else
WriteINIFile;
// 定义窗口类型 、状态
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 frmBPZDY_LRPB = nil then
begin
frmBPZDY_LRPB := TfrmBPZDY_LRPB.Create(application.MainForm);
with frmBPZDY_LRPB do
begin
flag := 'PBName';
flagName := '坯布';
ToolButton1.Visible := False;
caption := Trim(Title);
FormStyle := mstyle;
windowState := mstate;
BorderStyle := mborderstyle;
//show;
end;
end
else
frmBPZDY_LRPB.BringToFront;
//句柄
mnewHandle := frmBPZDY_LRPB.Handle;
end;
2: // 工艺库管理
begin
if frmGYSelect = nil then
begin
frmGYSelect := TfrmGYSelect.Create(application.MainForm);
with frmGYSelect do
begin
caption := Trim(Title);
FormStyle := mstyle;
windowState := mstate;
BorderStyle := mborderstyle;
//show;
end;
end
else
frmGYSelect.BringToFront;
//句柄
mnewHandle := frmGYSelect.Handle;
end;
5001: //烫金花型管理
begin
if frmHXKTJ = nil then
begin
frmHXKTJ := TfrmHXKTJ.Create(application.MainForm);
with frmHXKTJ do
begin
caption := Trim(Title);
FormStyle := mstyle;
windowState := mstate;
BorderStyle := mborderstyle;
//show;
end;
end
else
frmHXKTJ.BringToFront;
//句柄
mnewHandle := frmHXKTJ.Handle;
end;
5002: //印花花型管理
begin
if frmHXKYHK = nil then
begin
frmHXKYHK := TfrmHXKYHK.Create(application.MainForm);
with frmHXKYHK do
begin
caption := Trim(Title);
FormStyle := mstyle;
windowState := mstate;
BorderStyle := mborderstyle;
//show;
end;
end
else
frmHXKYHK.BringToFront;
//句柄
mnewHandle := frmHXKYHK.Handle;
end;
300: // 坯布色号库管理
begin
if frmBPZDY_LRSHK = nil then
begin
frmBPZDY_LRSHK := TfrmBPZDY_LRSHK.Create(application.MainForm);
with frmBPZDY_LRSHK do
begin
caption := Trim(Title);
FormStyle := mstyle;
windowState := mstate;
BorderStyle := mborderstyle;
//show;
end;
end
else
frmBPZDY_LRSHK.BringToFront;
//句柄
mnewHandle := frmBPZDY_LRSHK.Handle;
end;
4: // 染色面料
begin
if frmMLMangeRS = nil then
begin
frmMLMangeRS := TfrmMLMangeRS.Create(application.MainForm);
with frmMLMangeRS do
begin
caption := Trim(Title);
FormStyle := mstyle;
windowState := mstate;
BorderStyle := mborderstyle;
//show;
end;
end
else
frmMLMangeRS.BringToFront;
//句柄
mnewHandle := frmMLMangeRS.Handle;
end;
5: // 扫描查询
begin
if frmMLMangeRS_SMCX = nil then
begin
frmMLMangeRS_SMCX := TfrmMLMangeRS_SMCX.Create(application.MainForm);
with frmMLMangeRS_SMCX do
begin
caption := Trim(Title);
FormStyle := mstyle;
windowState := mstate;
BorderStyle := mborderstyle;
//show;
end;
end
else
frmMLMangeRS_SMCX.BringToFront;
//句柄
mnewHandle := frmMLMangeRS_SMCX.Handle;
end;
6: // 印花花型库管理
begin
if frmBPZDY_LRPB_M = nil then
begin
frmBPZDY_LRPB_M := TfrmBPZDY_LRPB_M.Create(application.MainForm);
with frmBPZDY_LRPB_M do
begin
flag := 'MName';
flagName := '膜库';
ToolButton1.Visible := False;
caption := Trim(Title);
FormStyle := mstyle;
windowState := mstate;
BorderStyle := mborderstyle;
//show;
end;
end
else
frmBPZDY_LRPB_M.BringToFront;
//句柄
mnewHandle := frmBPZDY_LRPB_M.Handle;
end;
7: // 印花色号库管理
begin
if frmBPZDY_LRSHK_M = nil then
begin
frmBPZDY_LRSHK_M := TfrmBPZDY_LRSHK_M.Create(application.MainForm);
with frmBPZDY_LRSHK_M do
begin
caption := Trim(Title);
FormStyle := mstyle;
windowState := mstate;
BorderStyle := mborderstyle;
//show;
end;
end
else
frmBPZDY_LRSHK_M.BringToFront;
//句柄
mnewHandle := frmBPZDY_LRSHK_M.Handle;
end;
9: // 绣花花型库录入
begin
if frmBPZDY_XHPB_M = nil then
begin
frmBPZDY_XHPB_M := TfrmBPZDY_XHPB_M.Create(application.MainForm);
with frmBPZDY_XHPB_M do
begin
flag := 'XHName';
flagName := '绣花';
ToolButton1.Visible := False;
caption := Trim(Title);
FormStyle := mstyle;
windowState := mstate;
BorderStyle := mborderstyle;
//show;
end;
end
else
frmBPZDY_XHPB_M.BringToFront;
//句柄
mnewHandle := frmBPZDY_XHPB_M.Handle;
end;
21: // 新样品档案
begin
if frmMLMange = nil then
begin
frmMLMange := TfrmMLMange.Create(application.MainForm);
with frmMLMange do
begin
caption := Trim(Title);
FormStyle := mstyle;
windowState := mstate;
BorderStyle := mborderstyle;
//show;
end;
end
else
frmMLMange.BringToFront;
//句柄
mnewHandle := frmMLMange.Handle;
end;
26: //烫金花型管理
begin
if frmBPZDY_TJHXK_M3 = nil then
begin
frmBPZDY_TJHXK_M3 := TfrmBPZDY_TJHXK_M3.Create(application.MainForm);
with frmBPZDY_TJHXK_M3 do
begin
caption := Trim(Title);
FormStyle := mstyle;
windowState := mstate;
BorderStyle := mborderstyle;
//show;
end;
end
else
frmBPZDY_TJHXK_M3.BringToFront;
//句柄
mnewHandle := frmBPZDY_TJHXK_M3.Handle;
end;
27: //烫金面料管理
begin
if frmMLMangeTJ = nil then
begin
frmMLMangeTJ := TfrmMLMangeTJ.Create(application.MainForm);
with frmMLMangeTJ do
begin
caption := Trim(Title);
FormStyle := mstyle;
windowState := mstate;
BorderStyle := mborderstyle;
//show;
end;
end
else
frmMLMangeTJ.BringToFront;
//句柄
mnewHandle := frmMLMangeTJ.Handle;
end;
28: //印花面料管理
begin
if frmMLMangeYH = nil then
begin
frmMLMangeYH := TfrmMLMangeYH.Create(application.MainForm);
with frmMLMangeYH do
begin
caption := Trim(Title);
FormStyle := mstyle;
windowState := mstate;
BorderStyle := mborderstyle;
//show;
end;
end
else
frmMLMangeYH.BringToFront;
//句柄
mnewHandle := frmMLMangeYH.Handle;
end;
29: //绣花面料管理
begin
if frmMLMange_XH = nil then
begin
frmMLMange_XH := TfrmMLMange_XH.Create(application.MainForm);
with frmMLMange_XH do
begin
caption := Trim(Title);
FormStyle := mstyle;
windowState := mstate;
BorderStyle := mborderstyle;
//show;
end;
end
else
frmMLMange_XH.BringToFront;
//句柄
mnewHandle := frmMLMange_XH.Handle;
end;
30: //面料汇总管理
begin
if frmMLHZGL = nil then
begin
frmMLHZGL := TfrmMLHZGL.Create(application.MainForm);
with frmMLHZGL do
begin
caption := Trim(Title);
FormStyle := mstyle;
windowState := mstate;
BorderStyle := mborderstyle;
//show;
end;
end
else
frmMLHZGL.BringToFront;
//句柄
mnewHandle := frmMLHZGL.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');
UserDataFlag := IniFile.ReadString('SERVER', '服务器地址类型', '-1');
finally
IniFile.Free;
end;
if not Assigned(DataLink_YPGLBOM) then
DataLink_YPGLBOM := TDataLink_YPGLBOM.Create(Application);
try
with DataLink_YPGLBOM.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_YPGLBOM.Free;
// Application := OldDllApp;
initialization
CoInitialize(nil);
dxUnitsLoader.Initialize;
finalization
DataLink_YPGLBOM.Free;
application := NewDllApp;
dxUnitsLoader.Finalize;
end.