364 lines
9.9 KiB
ObjectPascal
364 lines
9.9 KiB
ObjectPascal
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_ProductOrderNewList_New, U_ProductOrderNewList_BQNew,
|
||
U_MJManageNewFDNew_New, U_JYJT_New, U_OrderHCList, U_OrderList, U_JYRLList,
|
||
U_JYOrdColorList, U_CPDBAO, U_PRTLable, U_MJJYTH, U_CheJianXS;
|
||
|
||
/////////////////////////////////////////////////////////////////
|
||
// 功能说明:取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
|
||
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);
|
||
|
||
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;
|
||
|
||
|
||
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 frmProductOrderNewList_New = nil then
|
||
begin
|
||
frmProductOrderNewList_New := TfrmProductOrderNewList_New.Create(application.MainForm);
|
||
with frmProductOrderNewList_New do
|
||
begin
|
||
caption := Trim(Title);
|
||
FormStyle := mstyle;
|
||
windowState := mstate;
|
||
BorderStyle := mborderstyle;
|
||
//show;
|
||
end;
|
||
end
|
||
else
|
||
frmProductOrderNewList_New.BringToFront;
|
||
//句柄
|
||
mnewHandle := frmProductOrderNewList_New.Handle;
|
||
end;
|
||
|
||
111: //标签设置
|
||
begin
|
||
if frmProductOrderNewList_BQNew = nil then
|
||
begin
|
||
frmProductOrderNewList_BQNew := TfrmProductOrderNewList_BQNew.Create(application.MainForm);
|
||
with frmProductOrderNewList_BQNew do
|
||
begin
|
||
caption := Trim(Title);
|
||
FormStyle := mstyle;
|
||
windowState := mstate;
|
||
BorderStyle := mborderstyle;
|
||
//show;
|
||
end;
|
||
end
|
||
else
|
||
frmProductOrderNewList_BQNew.BringToFront;
|
||
//句柄
|
||
mnewHandle := frmProductOrderNewList_BQNew.Handle;
|
||
end;
|
||
201: // 成品检验
|
||
begin
|
||
if frmMJJYTH = nil then
|
||
begin
|
||
frmMJJYTH := TfrmMJJYTH.Create(application.MainForm);
|
||
with frmMJJYTH do
|
||
begin
|
||
fmanage := Trim(DataBase);
|
||
caption := Trim(Title);
|
||
FormStyle := mstyle;
|
||
windowState := mstate;
|
||
BorderStyle := mborderstyle;
|
||
//show;
|
||
end;
|
||
end
|
||
else
|
||
frmMJJYTH.BringToFront;
|
||
//句柄
|
||
mnewHandle := frmMJJYTH.Handle;
|
||
end;
|
||
202: // 标签重打
|
||
begin
|
||
if frmPRTLable = nil then
|
||
begin
|
||
frmPRTLable := TfrmPRTLable.Create(application.MainForm);
|
||
with frmPRTLable do
|
||
begin
|
||
caption := Trim(Title);
|
||
FormStyle := mstyle;
|
||
windowState := mstate;
|
||
BorderStyle := mborderstyle;
|
||
//show;
|
||
end;
|
||
end
|
||
else
|
||
frmPRTLable.BringToFront;
|
||
//句柄
|
||
mnewHandle := frmPRTLable.Handle;
|
||
end;
|
||
|
||
301: //检验信息管理
|
||
begin
|
||
if frmJYJT_New = nil then
|
||
begin
|
||
frmJYJT_New := TfrmJYJT_New.Create(application.MainForm);
|
||
with frmJYJT_New do
|
||
begin
|
||
caption := Trim(Title);
|
||
FormStyle := mstyle;
|
||
windowState := mstate;
|
||
BorderStyle := mborderstyle;
|
||
//show;
|
||
end;
|
||
end
|
||
else
|
||
frmJYJT_New.BringToFront;
|
||
//句柄
|
||
mnewHandle := frmJYJT_New.Handle;
|
||
end;
|
||
|
||
302: //订单核查表
|
||
begin
|
||
if frmOrderHCList = nil then
|
||
begin
|
||
frmOrderHCList := TfrmOrderHCList.Create(application.MainForm);
|
||
with frmOrderHCList do
|
||
begin
|
||
caption := Trim(Title);
|
||
FormStyle := mstyle;
|
||
windowState := mstate;
|
||
BorderStyle := mborderstyle;
|
||
//show;
|
||
end;
|
||
end
|
||
else
|
||
frmOrderHCList.BringToFront;
|
||
//句柄
|
||
mnewHandle := frmOrderHCList.Handle;
|
||
end;
|
||
303: //指示单查询
|
||
begin
|
||
if frmOrderList = nil then
|
||
begin
|
||
frmOrderList := TfrmOrderList.Create(application.MainForm);
|
||
with frmOrderList do
|
||
begin
|
||
caption := Trim(Title);
|
||
FormStyle := mstyle;
|
||
windowState := mstate;
|
||
BorderStyle := mborderstyle;
|
||
//show;
|
||
end;
|
||
end
|
||
else
|
||
frmOrderList.BringToFront;
|
||
//句柄
|
||
mnewHandle := frmOrderList.Handle;
|
||
end;
|
||
304: //打卷产量统计查询
|
||
begin
|
||
if frmJYRLList = nil then
|
||
begin
|
||
frmJYRLList := TfrmJYRLList.Create(application.MainForm);
|
||
with frmJYRLList do
|
||
begin
|
||
caption := Trim(Title);
|
||
FormStyle := mstyle;
|
||
windowState := mstate;
|
||
BorderStyle := mborderstyle;
|
||
//show;
|
||
end;
|
||
end
|
||
else
|
||
frmJYRLList.BringToFront;
|
||
//句柄
|
||
mnewHandle := frmJYRLList.Handle;
|
||
end;
|
||
305: //订单打卷查询
|
||
begin
|
||
if frmJYOrdColorList = nil then
|
||
begin
|
||
frmJYOrdColorList := TfrmJYOrdColorList.Create(application.MainForm);
|
||
with frmJYOrdColorList do
|
||
begin
|
||
caption := Trim(Title);
|
||
FormStyle := mstyle;
|
||
windowState := mstate;
|
||
BorderStyle := mborderstyle;
|
||
//show;
|
||
end;
|
||
end
|
||
else
|
||
frmJYOrdColorList.BringToFront;
|
||
//句柄
|
||
mnewHandle := frmJYOrdColorList.Handle;
|
||
end;
|
||
|
||
306: //打包管理
|
||
begin
|
||
if frmCPDBao = nil then
|
||
begin
|
||
frmCPDBao := TfrmCPDBao.Create(application.MainForm);
|
||
with frmCPDBao do
|
||
begin
|
||
caption := Trim(Title);
|
||
FormStyle := mstyle;
|
||
windowState := mstate;
|
||
BorderStyle := mborderstyle;
|
||
//show;
|
||
end;
|
||
end
|
||
else
|
||
frmCPDBao.BringToFront;
|
||
//句柄
|
||
mnewHandle := frmCPDBao.Handle;
|
||
end;
|
||
|
||
411: //车间线色设置
|
||
begin
|
||
if frmCheJianXS = nil then
|
||
begin
|
||
frmCheJianXS := TfrmCheJianXS.Create(application.MainForm);
|
||
with frmCheJianXS do
|
||
begin
|
||
caption := Trim(Title);
|
||
FormStyle := mstyle;
|
||
windowState := mstate;
|
||
BorderStyle := mborderstyle;
|
||
//show;
|
||
end;
|
||
end
|
||
else
|
||
frmCheJianXS.BringToFront;
|
||
//句柄
|
||
mnewHandle := frmCheJianXS.Handle;
|
||
end;
|
||
|
||
end;
|
||
|
||
Result := mnewHandle;
|
||
end;
|
||
//===========================================================
|
||
//建立数据库连接池
|
||
//===========================================================
|
||
|
||
function ConnData(): Boolean;
|
||
begin
|
||
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
|
||
CoInitialize(nil);
|
||
dxUnitsLoader.Initialize;
|
||
|
||
|
||
finalization
|
||
DataLink_DyeingFinishingPlan.Free;
|
||
application := NewDllApp;
|
||
dxUnitsLoader.Finalize;
|
||
|
||
end.
|
||
|