D7fhyuhan/员工管理(StaffManage.dll)/U_GetDllForm.pas
DESKTOP-E401PHE\Administrator fc7b44d7f6 移交
2025-09-21 08:59:38 +08:00

297 lines
8.0 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;
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_SxXnKcList, U_YGList, U_GXGL_List, U_YGCL_BZ, U_SYDept, U_GYGL,
U_YGCLList, U_BZCLList; //U_ProcessDesign
/////////////////////////////////////////////////////////////////
// 功能说明:取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 := 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 := 'sanshuidata';
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 frmSYDept = nil then
begin
frmSYDept := TfrmSYDept.Create(application.MainForm);
with frmSYDept do
begin
caption := Trim(Title);
FormStyle := mstyle;
windowState := mstate;
BorderStyle := mborderstyle;
//show;
end;
end
else
frmSYDept.BringToFront;
//句柄
mnewHandle := frmSYDept.Handle;
end;
102: //员工档案管理
begin
if frmYGList = nil then
begin
frmYGList := TfrmYGList.Create(application.MainForm);
with frmYGList do
begin
caption := Trim(Title);
FormStyle := mstyle;
windowState := mstate;
BorderStyle := mborderstyle;
//show;
end;
end
else
frmYGList.BringToFront;
//句柄
mnewHandle := frmYGList.Handle;
end;
201: //工序管理
begin
if frmGXGL_List = nil then
begin
frmGXGL_List := TfrmGXGL_List.Create(application.MainForm);
with frmGXGL_List do
begin
caption := Trim(Title);
FormStyle := mstyle;
windowState := mstate;
BorderStyle := mborderstyle;
//show;
end;
end
else
frmGXGL_List.BringToFront;
//句柄
mnewHandle := frmGXGL_List.Handle;
end;
211: //员工班组管理
begin
if frmYGCL_BZ = nil then
begin
frmYGCL_BZ := TfrmYGCL_BZ.Create(application.MainForm);
with frmYGCL_BZ do
begin
caption := Trim(Title);
FormStyle := mstyle;
windowState := mstate;
BorderStyle := mborderstyle;
//show;
end;
end
else
frmYGCL_BZ.BringToFront;
//句柄
mnewHandle := frmYGCL_BZ.Handle;
end;
212: //工艺管理
begin
if frmGYGL = nil then
begin
frmGYGL := TfrmGYGL.Create(application.MainForm);
with frmGYGL do
begin
caption := Trim(Title);
FormStyle := mstyle;
windowState := mstate;
BorderStyle := mborderstyle;
//show;
end;
end
else
frmGYGL.BringToFront;
//句柄
mnewHandle := frmGYGL.Handle;
end;
// 1: //工序管理
// begin
// if frmProcessDesign = nil then
// begin
// frmProcessDesign := TfrmProcessDesign.Create(application.MainForm);
// with frmProcessDesign do
// begin
// caption := Trim(Title);
// FormStyle := mstyle;
// windowState := mstate;
// BorderStyle := mborderstyle;
// //show;
// end;
// end
// else
// frmProcessDesign.BringToFront;
// //句柄
// mnewHandle := frmProcessDesign.Handle;
// end;
311: //班组产量
begin
if frmBZCLList = nil then
begin
frmBZCLList := TfrmBZCLList.Create(application.MainForm);
with frmBZCLList do
begin
caption := Trim(Title);
FormStyle := mstyle;
windowState := mstate;
BorderStyle := mborderstyle;
//show;
end;
end
else
frmBZCLList.BringToFront;
//句柄
mnewHandle := frmBZCLList.Handle;
end;
312: //员工产量
begin
if frmYGCLList = nil then
begin
frmYGCLList := TfrmYGCLList.Create(application.MainForm);
with frmYGCLList do
begin
caption := Trim(Title);
FormStyle := mstyle;
windowState := mstate;
BorderStyle := mborderstyle;
//show;
end;
end
else
frmYGCLList.BringToFront;
//句柄
mnewHandle := frmYGCLList.Handle;
end;
end;
Result := mnewHandle;
NewDllApp := Application;
end;
//===========================================================
//建立数据库连接池
//===========================================================
function ConnData(): Boolean;
begin
if not Assigned(DataLink_StaffManage) then
DataLink_StaffManage := TDataLink_StaffManage.Create(Application);
try
with DataLink_StaffManage.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_StaffManage.Free;
Application := OldDllApp;
end.