D7myYunxiang/基础资料维护(BaseInfo.dll)/U_GetDllForm.pas

316 lines
8.7 KiB
ObjectPascal
Raw Normal View History

2025-01-20 13:04:03 +08:00
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_KHInfo, U_ZdyAttachment, U_ZdyAttachGYS, U_ZdyAttachCP,
U_NengHaoList, U_CPKWlist, U_ZdyAttachCP10, U_ZdyAttachCP_HX;
/////////////////////////////////////////////////////////////////
// <20><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5>:ȡDll<6C>еô<D0B5><C3B4><EFBFBD> //
// <20><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5><EFBFBD><EFBFBD>App>><3E><><EFBFBD><EFBFBD>Ӧ<EFBFBD>ó<EFBFBD><C3B3><EFBFBD><EFBFBD><EFBFBD> //
// FormH>><3E><><EFBFBD>ô<EFBFBD><C3B4>ھ<EFBFBD><DABE><EFBFBD> <20><> //
// FormID>><3E><><EFBFBD>ں<EFBFBD>; //
// Language>><3E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>; //
// WinStyle>><3E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͣ<EFBFBD> //
/////////////////////////////////////////////////////////////////
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:<3A>Ӵ<EFBFBD><D3B4><EFBFBD>; 1<><31><EFBFBD><EFBFBD>ͨ<EFBFBD><CDA8><EFBFBD><EFBFBD>
mstate: TWindowState;
mborderstyle: TFormBorderStyle;
begin
mnewHandle := 0;
DName := GName;
DCode := 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;
//<2F><>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>
SetLength(server, 255);
SetLength(dtbase, 255);
SetLength(user, 255);
SetLength(pswd, 255);
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;
// DConString := DataBaseStr;
if trim(DataBaseStr) <> '' then
DConString := DataBaseStr;
// DParameters1 := '<27><>Ȩ<EFBFBD><C8A8>';
//DName:='ADMIN';
//DataBase:='<27>ӹ<EFBFBD><D3B9><EFBFBD>';
if not ConnData() then
begin
result := 0;
exit;
end;
// <20><><EFBFBD><EFBFBD><E5B4B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>״̬
if WinStyle = 0 then
begin
mstyle := fsMDIChild;
mstate := wsMaximized;
mborderstyle := bsSizeable;
end
else
begin
mstyle := fsNormal;
mstate := wsNormal;
mborderstyle := bsSizeable;
end;
/////////////////////
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģ<EFBFBD><EFBFBD><E9B4B0>
case FormID of
1: //<2F>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>ά<EFBFBD><CEAC>
begin
if frmZdyAttachment = nil then
begin
frmZdyAttachment := TfrmZdyAttachment.Create(application.MainForm);
with frmZdyAttachment do
begin
caption := Trim(Title);
// fkhType:=trim(DataBase);
FormStyle := mstyle;
windowState := mstate;
BorderStyle := mborderstyle;
//show;
end;
end
else
frmZdyAttachment.BringToFront;
//<2F><><EFBFBD><EFBFBD>
mnewHandle := frmZdyAttachment.Handle;
end;
2: //<2F><>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ά<EFBFBD><CEAC>
begin
if frmZdyAttachGYS = nil then
begin
frmZdyAttachGYS := TfrmZdyAttachGYS.Create(application.MainForm);
with frmZdyAttachGYS do
begin
caption := Trim(Title);
FormStyle := mstyle;
windowState := mstate;
BorderStyle := mborderstyle;
//show;
end;
end
else
frmZdyAttachGYS.BringToFront;
//<2F><><EFBFBD><EFBFBD>
mnewHandle := frmZdyAttachGYS.Handle;
end;
3: //<2F><>Ʒ<EFBFBD><C6B7>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD><C7B0>
begin
if frmZdyAttachCP = nil then
begin
frmZdyAttachCP := TfrmZdyAttachCP.Create(application.MainForm);
with frmZdyAttachCP do
begin
caption := Trim(Title);
// fkhType:='';
fkhType := trim(DataBase);
FormStyle := mstyle;
windowState := mstate;
BorderStyle := mborderstyle;
//show;
end;
end
else
frmZdyAttachCP.BringToFront;
//<2F><><EFBFBD><EFBFBD>
mnewHandle := frmZdyAttachCP.Handle;
end;
31: //<2F><>Ʒ<EFBFBD><C6B7><EFBFBD><EFBFBD>ά<EFBFBD><CEAC>
begin
if frmZdyAttachCP10 = nil then
begin
frmZdyAttachCP10 := TfrmZdyAttachCP10.Create(application.MainForm);
with frmZdyAttachCP10 do
begin
caption := Trim(Title);
FormStyle := mstyle;
windowState := mstate;
BorderStyle := mborderstyle;
//show;
end;
end
else
frmZdyAttachCP10.BringToFront;
//<2F><><EFBFBD><EFBFBD>
mnewHandle := frmZdyAttachCP10.Handle;
end;
4: //<2F>ܺĵǼ<C4B5>
begin
if frmNengHaoList = nil then
begin
frmNengHaoList := TfrmNengHaoList.Create(application.MainForm);
with frmNengHaoList do
begin
caption := Trim(Title);
FormStyle := mstyle;
windowState := mstate;
BorderStyle := mborderstyle;
//show;
end;
end
else
frmNengHaoList.BringToFront;
//<2F><><EFBFBD><EFBFBD>
mnewHandle := frmNengHaoList.Handle;
end;
{ 5: //ͳ<>ƻ<EFBFBD><C6BB>ܲ<EFBFBD>ѯ
begin
if frmHZViewList=nil then
begin
frmHZViewList:= TfrmHZViewList.Create(application.MainForm);
with frmHZViewList do
begin
caption:=Trim(Title);
FormStyle := mstyle ;
windowState := mstate ;
BorderStyle := mborderstyle;
//show;
end;
end
else
frmHZViewList.BringToFront;
//<2F><><EFBFBD><EFBFBD>
mNewHandle:=frmHZViewList.Handle;
end ; }
6: //ͳ<>ƻ<EFBFBD><C6BB>ܲ<EFBFBD>ѯ
begin
if frmCPKWList = nil then
begin
frmCPKWList := TfrmCPKWList.Create(application.MainForm);
with frmCPKWList do
begin
caption := Trim(Title);
FormStyle := mstyle;
windowState := mstate;
BorderStyle := mborderstyle;
//show;
end;
end
else
frmCPKWList.BringToFront;
//<2F><><EFBFBD><EFBFBD>
mnewHandle := frmCPKWList.Handle;
end;
7: //<2F><><EFBFBD>͹<EFBFBD><CDB9><EFBFBD>
begin
if frmZdyAttachCP_HX <> nil then
frmZdyAttachCP_HX.Free;
if frmZdyAttachCP_HX = nil then
begin
frmZdyAttachCP_HX := TfrmZdyAttachCP_HX.Create(application.MainForm);
with frmZdyAttachCP_HX do
begin
caption := Trim(Title);
FormStyle := mstyle;
windowState := mstate;
BorderStyle := mborderstyle;
//show;
end;
end
else
frmZdyAttachCP_HX.BringToFront;
//<2F><><EFBFBD><EFBFBD>
mnewHandle := frmZdyAttachCP_HX.Handle;
end;
end; // end case
Result := mnewHandle;
end;
//===========================================================
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD><EFBFBD>ӳ<EFBFBD>
//===========================================================
function ConnData(): Boolean;
var
IniFile: TIniFile;
begin
try
IniFile := TIniFile.Create(ExtractFilePath(Application.ExeName) + 'SYSTEMSET.INI');
PicSvr := IniFile.ReadString('SERVER', '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ', '127.0.0.1');
UserDataFlag := IniFile.ReadString('SERVER', '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD>', '-1');
finally
IniFile.Free;
end;
if not Assigned(DataLink_BaseInfo) then
DataLink_BaseInfo := TDataLink_BaseInfo.Create(Application);
try
with DataLink_BaseInfo.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('<27><><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>', '<27><><EFBFBD><EFBFBD>', mb_Ok + MB_ICONERROR);
end;
end;
initialization
CoInitialize(nil);
dxUnitsLoader.Initialize;
finalization
DataLink_BaseInfo.Free;
application := NewDllApp;
dxUnitsLoader.Finalize;
end.