378 lines
11 KiB
ObjectPascal
378 lines
11 KiB
ObjectPascal
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_BaoGuanList, U_BaoGuanListZXD, U_BaoGuanXSList, U_BaoGuanCRKCX;
|
||
|
||
var
|
||
frmBaoGuanList, frmBaoGuanListGQX, frmBaoGuanListCXGQX, frmBaoGuanListZL: TfrmBaoGuanList;
|
||
frmBaoGuanListHT, frmBaoGuanListFP, frmBaoGuanListZXD, frmBaoGuanListBGD: TfrmBaoGuanList;
|
||
frmBaoGuanListSBYS, frmBaoGuanListHD, frmBaoGuanListSH, frmBaoGuanListDJ: TfrmBaoGuanList;
|
||
/////////////////////////////////////////////////////////////////
|
||
// 功能说明:取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);
|
||
|
||
//server:='121.40.233.100,7781'; //192.168.1.113
|
||
server := '101.132.146.12,7781'; //192.168.1.113
|
||
dtbase := 'shengfangData';
|
||
user := 'shengfangsa';
|
||
pswd := 'rightsoft@4400';
|
||
DConString := 'Provider=SQLOLEDB.1;Password=' + pswd + ';Persist Security Info=True;User ID=' + user + ';Initial Catalog=' + dtbase + ';Data Source=' + server;
|
||
|
||
if trim(DataBaseStr) <> '' then
|
||
DConString := DataBaseStr;
|
||
|
||
//DName:='ADMIN';
|
||
|
||
DParameters1 := '高权限'; //
|
||
//DParameters2:='';
|
||
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;
|
||
//Title:='报关管理';
|
||
/////////////////////
|
||
//调用子模块窗口
|
||
case FormID of
|
||
-1: //报关资料录入
|
||
begin
|
||
bFound := FALSE;
|
||
for i := (App.MainForm.MDIChildCount - 1) downto 0 do
|
||
begin
|
||
if App.MainForm.MDIChildren[i].Caption = '报关资料录入' then
|
||
begin
|
||
BringWindowToTop(frmBaoGuanList.Handle);
|
||
bFound := TRUE;
|
||
Break;
|
||
end;
|
||
end;
|
||
if not bFound then
|
||
//if frmBaoGuanList=nil then
|
||
begin
|
||
frmBaoGuanList := TfrmBaoGuanList.Create(application.MainForm);
|
||
with frmBaoGuanList do
|
||
begin
|
||
Title := '报关资料录入';
|
||
caption := Trim(Title);
|
||
FormStyle := mstyle;
|
||
windowState := mstate;
|
||
BorderStyle := mborderstyle;
|
||
//show;
|
||
end;
|
||
end
|
||
else
|
||
frmBaoGuanList.BringToFront;
|
||
//句柄
|
||
mnewHandle := frmBaoGuanList.Handle;
|
||
end;
|
||
-2: //报关资料录入(高权限)
|
||
begin
|
||
bFound := FALSE;
|
||
for i := (App.MainForm.MDIChildCount - 1) downto 0 do
|
||
begin
|
||
if App.MainForm.MDIChildren[i].Caption = '报关资料录入(高权限)' then
|
||
begin
|
||
BringWindowToTop(frmBaoGuanListGQX.Handle);
|
||
bFound := TRUE;
|
||
Break;
|
||
end;
|
||
end;
|
||
if not bFound then
|
||
//if frmBaoGuanList=nil then
|
||
begin
|
||
frmBaoGuanListGQX := TfrmBaoGuanList.Create(application.MainForm);
|
||
with frmBaoGuanListGQX do
|
||
begin
|
||
Title := '报关资料录入(高权限)';
|
||
caption := Trim(Title);
|
||
FormStyle := mstyle;
|
||
windowState := mstate;
|
||
BorderStyle := mborderstyle;
|
||
//show;
|
||
end;
|
||
end
|
||
else
|
||
frmBaoGuanListGQX.BringToFront;
|
||
//句柄
|
||
mnewHandle := frmBaoGuanListGQX.Handle;
|
||
end;
|
||
-3: //报关资料核对
|
||
begin
|
||
bFound := FALSE;
|
||
for i := (App.MainForm.MDIChildCount - 1) downto 0 do
|
||
begin
|
||
if App.MainForm.MDIChildren[i].Caption = '报关资料核对' then
|
||
begin
|
||
BringWindowToTop(frmBaoGuanListHD.Handle);
|
||
bFound := TRUE;
|
||
Break;
|
||
end;
|
||
end;
|
||
if not bFound then
|
||
//if frmBaoGuanListSBYS=nil then
|
||
begin
|
||
frmBaoGuanListHD := TfrmBaoGuanList.Create(application.MainForm);
|
||
with frmBaoGuanListHD do
|
||
begin
|
||
Title := '报关资料核对';
|
||
caption := Trim(Title);
|
||
FormStyle := mstyle;
|
||
windowState := mstate;
|
||
BorderStyle := mborderstyle;
|
||
//show;
|
||
end;
|
||
end
|
||
else
|
||
frmBaoGuanListHD.BringToFront;
|
||
//句柄
|
||
mnewHandle := frmBaoGuanListHD.Handle;
|
||
end;
|
||
-4: //报关资料审核
|
||
begin
|
||
bFound := FALSE;
|
||
for i := (App.MainForm.MDIChildCount - 1) downto 0 do
|
||
begin
|
||
if App.MainForm.MDIChildren[i].Caption = '报关资料审核' then
|
||
begin
|
||
BringWindowToTop(frmBaoGuanListSH.Handle);
|
||
bFound := TRUE;
|
||
Break;
|
||
end;
|
||
end;
|
||
if not bFound then
|
||
//if frmBaoGuanListSBYS=nil then
|
||
begin
|
||
frmBaoGuanListSH := TfrmBaoGuanList.Create(application.MainForm);
|
||
with frmBaoGuanListSH do
|
||
begin
|
||
Title := '报关资料审核';
|
||
caption := Trim(Title);
|
||
FormStyle := mstyle;
|
||
windowState := mstate;
|
||
BorderStyle := mborderstyle;
|
||
//show;
|
||
end;
|
||
end
|
||
else
|
||
frmBaoGuanListSH.BringToFront;
|
||
//句柄
|
||
mnewHandle := frmBaoGuanListSH.Handle;
|
||
end;
|
||
-5: //报关资料查询(高权限)
|
||
begin
|
||
bFound := FALSE;
|
||
for i := (App.MainForm.MDIChildCount - 1) downto 0 do
|
||
begin
|
||
if App.MainForm.MDIChildren[i].Caption = '报关资料查询(高权限)' then
|
||
begin
|
||
BringWindowToTop(frmBaoGuanListCXGQX.Handle);
|
||
bFound := TRUE;
|
||
Break;
|
||
end;
|
||
end;
|
||
if not bFound then
|
||
//if frmBaoGuanListBGZL=nil then
|
||
begin
|
||
frmBaoGuanListCXGQX := TfrmBaoGuanList.Create(application.MainForm);
|
||
with frmBaoGuanListCXGQX do
|
||
begin
|
||
Title := '报关资料查询(高权限)';
|
||
caption := Trim(Title);
|
||
FormStyle := mstyle;
|
||
windowState := mstate;
|
||
BorderStyle := mborderstyle;
|
||
//show;
|
||
end;
|
||
end
|
||
else
|
||
frmBaoGuanListCXGQX.BringToFront;
|
||
//句柄
|
||
mnewHandle := frmBaoGuanListCXGQX.Handle;
|
||
end;
|
||
-6: //报关销售资料
|
||
begin
|
||
if frmBaoGuanXSList = nil then
|
||
begin
|
||
frmBaoGuanXSList := TfrmBaoGuanXSList.Create(application.MainForm);
|
||
with frmBaoGuanXSList do
|
||
begin
|
||
caption := Trim(Title);
|
||
FormStyle := mstyle;
|
||
windowState := mstate;
|
||
BorderStyle := mborderstyle;
|
||
//show;
|
||
end;
|
||
end
|
||
else
|
||
frmBaoGuanXSList.BringToFront;
|
||
//句柄
|
||
mnewHandle := frmBaoGuanXSList.Handle;
|
||
end;
|
||
|
||
1: //报关管理(单机)
|
||
begin
|
||
bFound := FALSE;
|
||
for i := (App.MainForm.MDIChildCount - 1) downto 0 do
|
||
begin
|
||
if App.MainForm.MDIChildren[i].Caption = '报关管理' then
|
||
begin
|
||
BringWindowToTop(frmBaoGuanListDJ.Handle);
|
||
bFound := TRUE;
|
||
Break;
|
||
end;
|
||
end;
|
||
if not bFound then
|
||
//if frmBaoGuanList=nil then
|
||
begin
|
||
frmBaoGuanListDJ := TfrmBaoGuanList.Create(application.MainForm);
|
||
with frmBaoGuanListDJ do
|
||
begin
|
||
Title := '报关管理';
|
||
caption := Trim(Title);
|
||
FormStyle := mstyle;
|
||
windowState := mstate;
|
||
BorderStyle := mborderstyle;
|
||
//show;
|
||
end;
|
||
end
|
||
else
|
||
frmBaoGuanListDJ.BringToFront;
|
||
//句柄
|
||
mnewHandle := frmBaoGuanListDJ.Handle;
|
||
end;
|
||
|
||
2: //报关出入库查询
|
||
begin
|
||
if frmBaoGuanCRKCX = nil then
|
||
begin
|
||
frmBaoGuanCRKCX := TfrmBaoGuanCRKCX.Create(application.MainForm);
|
||
with frmBaoGuanCRKCX do
|
||
begin
|
||
caption := Trim(Title);
|
||
FormStyle := mstyle;
|
||
windowState := mstate;
|
||
BorderStyle := mborderstyle;
|
||
//show;
|
||
end;
|
||
end
|
||
else
|
||
frmBaoGuanCRKCX.BringToFront;
|
||
//句柄
|
||
mnewHandle := frmBaoGuanCRKCX.Handle;
|
||
end;
|
||
|
||
end; // end case
|
||
|
||
Result := mnewHandle;
|
||
// NewDllApp:=Application ;
|
||
end;
|
||
//===========================================================
|
||
//建立数据库连接池
|
||
//===========================================================
|
||
|
||
function ConnData(): Boolean;
|
||
begin
|
||
if not Assigned(DataLink_DDMD) then
|
||
DataLink_DDMD := TDataLink_DDMD.Create(Application);
|
||
try
|
||
with DataLink_DDMD.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_DDMD.Free;
|
||
application := NewDllApp;
|
||
dxUnitsLoader.Finalize;
|
||
|
||
end.
|
||
|