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_WJGMDList, U_WJGCKOutList, U_WJGCKKCList, U_DJBRKList,
  U_DJBCKOutList, U_DJBCKKCList, U_DJBCKKCHZList, U_WJGCKKCHZList, U_SXCKNewList,
  U_SXCKOutList, U_PBCKKCList, U_CPBRKList, U_CPBCKKCList, U_CPBCKOutList,
  U_PBTPTJLIST;

       /////////////////////////////////////////////////////////////////
      //         功能说明:取Dll中得窗体                              //
     //        参数说明：App>>调用应用程序；                        //
    //                 FormH>>调用窗口句柄 ；                      //
   //                 FormID>>窗口号;                             //
  //                 Language>>语言种类;                         //
 //                 WinStyle>>窗口类型；                        //
/////////////////////////////////////////////////////////////////

var
  frmCPBCKOutListSQ, frmCPBCKOutListQR, frmCPBCKOutListL: TfrmCPBCKOutList;
  frmWJGMDListh, frmWJGMDListL: TfrmWJGMDList;
  frmSXCKNewListGL, frmSXCKNewListLR: TfrmSXCKNewList;
  frmSXCKOutListGL, frmSXCKOutListlr: TfrmSXCKOutList;
  frmPBCKKCListGL, frmPBCKKCListLR: TfrmPBCKKCList;
  frmWJGCKOutListGL, frmWJGCKOutListL: TfrmWJGCKOutList;
  frmWJGCKKCListL, frmWJGCKKCListGL: TfrmWJGCKKCList;
  frmDJBRKListL, frmDJBRKListgl: TfrmDJBRKList;
  frmDJBCKOutListL, frmDJBCKOutListgL: tfrmDJBCKOutList;
  frmDJBCKKCListL, frmDJBCKKCListgl: tfrmDJBCKKCList;
  frmCPBRKListGL, frmCPBRKListL: TfrmCPBRKList;
  frmCPBCKKCListL, frmCPBCKKCListGL: TfrmCPBCKKCList;

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';
//  server := '.';
  dtbase := 'tuoxuan10data';
  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

    111:  //坯布入库管理
      begin
        bFound := FALSE;
        for i := (App.MainForm.MDIChildCount - 1) downto 0 do
        begin
          if App.MainForm.MDIChildren[i].Caption = '坯布入库管理' then
          begin
            BringWindowToTop(frmSXCKNewListGL.Handle);
            bFound := TRUE;
            Break;
          end;
        end;
        if not bFound then
        begin
          frmSXCKNewListGL := TfrmSXCKNewList.Create(application.MainForm);
          with frmSXCKNewListGL do
          begin
            Title := '坯布入库管理';
            canshu1 := '管理';
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmSXCKNewListGL.BringToFront;
       //句柄
        mnewHandle := frmSXCKNewListGL.Handle;
      end;

    112:  //坯布入库录入
      begin
        bFound := FALSE;
        for i := (App.MainForm.MDIChildCount - 1) downto 0 do
        begin
          if App.MainForm.MDIChildren[i].Caption = '坯布入库(低权限)' then
          begin
            BringWindowToTop(frmSXCKNewListLR.Handle);
            bFound := TRUE;
            Break;
          end;
        end;
        if not bFound then
        begin
          frmSXCKNewListLR := TfrmSXCKNewList.Create(application.MainForm);
          with frmSXCKNewListLR do
          begin
            Title := '坯布入库(低权限)';
            canshu1 := '低权限';
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmSXCKNewListLR.BringToFront;
       //句柄
        mnewHandle := frmSXCKNewListLR.Handle;
      end;

    121:  //坯布出库管理
      begin
        bFound := FALSE;
        for i := (App.MainForm.MDIChildCount - 1) downto 0 do
        begin
          if App.MainForm.MDIChildren[i].Caption = '坯布出库管理' then
          begin
            BringWindowToTop(frmSXCKOutListGL.Handle);
            bFound := TRUE;
            Break;
          end;
        end;
        if not bFound then
        begin
          frmSXCKOutListGL := TfrmSXCKOutList.Create(application.MainForm);
          with frmSXCKOutListGL do
          begin
            Title := '坯布出库管理';
            canshu1 := '管理';
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmSXCKOutListGL.BringToFront;
       //句柄
        mnewHandle := frmSXCKOutListGL.Handle;
      end;

    122:  //坯布出库录入
      begin
        bFound := FALSE;
        for i := (App.MainForm.MDIChildCount - 1) downto 0 do
        begin
          if App.MainForm.MDIChildren[i].Caption = '坯布出库(低权限)' then
          begin
            BringWindowToTop(frmSXCKOutListLR.Handle);
            bFound := TRUE;
            Break;
          end;
        end;
        if not bFound then
        begin
          frmSXCKOutListLR := TfrmSXCKOutList.Create(application.MainForm);
          with frmSXCKOutListLR do
          begin
            Title := '坯布出库(低权限)';
            canshu1 := '低权限';
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmSXCKOutListLR.BringToFront;
       //句柄
        mnewHandle := frmSXCKOutListLR.Handle;
      end;

    131:  //坯布库存管理
      begin
        bFound := FALSE;
        for i := (App.MainForm.MDIChildCount - 1) downto 0 do
        begin
          if App.MainForm.MDIChildren[i].Caption = '坯布库存管理' then
          begin
            BringWindowToTop(frmPBCKKCListGL.Handle);
            bFound := TRUE;
            Break;
          end;
        end;
        if not bFound then
        begin
          frmPBCKKCListGL := TfrmPBCKKCList.Create(application.MainForm);
          with frmPBCKKCListGL do
          begin
            Title := '坯布库存管理';
            canshu1 := '管理';
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmPBCKKCListGL.BringToFront;
       //句柄
        mnewHandle := frmPBCKKCListGL.Handle;
      end;

    132:  //坯布库存(低权限)
      begin
        bFound := FALSE;
        for i := (App.MainForm.MDIChildCount - 1) downto 0 do
        begin
          if App.MainForm.MDIChildren[i].Caption = '坯布库存(低权限)' then
          begin
            BringWindowToTop(frmPBCKKCListLR.Handle);
            bFound := TRUE;
            Break;
          end;
        end;
        if not bFound then
        begin
          frmPBCKKCListLR := TfrmPBCKKCList.Create(application.MainForm);
          with frmPBCKKCListLR do
          begin
            Title := '坯布库存(低权限)';
            canshu1 := '录入';
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmPBCKKCListLR.BringToFront;
       //句柄
        mnewHandle := frmPBCKKCListLR.Handle;
      end;
    141:  //坯布投坯统计
      begin
        if frmPBTPTJList = nil then
        begin
          frmPBTPTJList := TfrmPBTPTJList.Create(application.MainForm);
          with frmPBTPTJList do
          begin
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmPBTPTJList.BringToFront;
       //句柄
        mnewHandle := frmPBTPTJList.Handle;
      end;
//    211:  //外加工入库
//      begin
//        if frmWJGMDList = nil then
//        begin
//          frmWJGMDList := TfrmWJGMDList.Create(application.MainForm);
//          with frmWJGMDList do
//          begin
//            caption := Trim(Title);
//            FormStyle := mstyle;
//            windowState := mstate;
//            BorderStyle := mborderstyle;
//           //show;
//          end;
//        end
//        else
//          frmWJGMDList.BringToFront;
//       //句柄
//        mnewHandle := frmWJGMDList.Handle;
//      end;

    211:  //外加工入库
      begin
        bFound := FALSE;
        for i := (App.MainForm.MDIChildCount - 1) downto 0 do
        begin
          if App.MainForm.MDIChildren[i].Caption = '后加工入库审核价格' then
          begin
            BringWindowToTop(frmWJGMDListH.Handle);
            bFound := TRUE;
            Break;
          end;
        end;
        if not bFound then
        begin
          frmWJGMDListH := TfrmWJGMDList.Create(application.MainForm);
          with frmWJGMDListH do
          begin
            Title := '后加工入库审核价格';
            canshu1 := '录入';
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmWJGMDListH.BringToFront;
       //句柄
        mnewHandle := frmWJGMDListH.Handle;
      end;

    212:  //外加工入库 (低权限)
      begin
        bFound := FALSE;
        for i := (App.MainForm.MDIChildCount - 1) downto 0 do
        begin
          if App.MainForm.MDIChildren[i].Caption = '后加工入库(低权限)' then
          begin
            BringWindowToTop(frmWJGMDListL.Handle);
            bFound := TRUE;
            Break;
          end;
        end;
        if not bFound then
        begin
          frmWJGMDListL := TfrmWJGMDLisT.Create(application.MainForm);
          with frmWJGMDListL do
          begin
            Title := '后加工入库(低权限)';
            canshu1 := '低权限';
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmWJGMDListL.BringToFront;
       //句柄
        mnewHandle := frmWJGMDListL.Handle;
      end;

    221:  //外加工出库管理
      begin
        bFound := FALSE;
        for i := (App.MainForm.MDIChildCount - 1) downto 0 do
        begin
          if App.MainForm.MDIChildren[i].Caption = '后加工出库' then
          begin
            BringWindowToTop(frmWJGCKOutListGL.Handle);
            bFound := TRUE;
            Break;
          end;
        end;
        if not bFound then
        begin
          frmWJGCKOutListGL := TfrmWJGCKOutList.Create(application.MainForm);
          with frmWJGCKOutListGL do
          begin
            Title := '后加工出库';
            canshu1 := '管理';
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmWJGCKOutListGL.BringToFront;
       //句柄
        mnewHandle := frmWJGCKOutListGL.Handle;
      end;

    222:  //外加工出库(低权限)
      begin
        bFound := FALSE;
        for i := (App.MainForm.MDIChildCount - 1) downto 0 do
        begin
          if App.MainForm.MDIChildren[i].Caption = '后加工出库(低权限)' then
          begin
            BringWindowToTop(frmWJGCKOutListL.Handle);
            bFound := TRUE;
            Break;
          end;
        end;
        if not bFound then
        begin
          frmWJGCKOutListL := TfrmWJGCKOutList.Create(application.MainForm);
          with frmWJGCKOutListL do
          begin
            Title := '后加工出库(低权限)';
            canshu1 := '低权限';
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmWJGCKOutListL.BringToFront;
       //句柄
        mnewHandle := frmWJGCKOutListL.Handle;
      end;

    231:  //外加工库存管理
      begin
        bFound := FALSE;
        for i := (App.MainForm.MDIChildCount - 1) downto 0 do
        begin
          if App.MainForm.MDIChildren[i].Caption = '后加工库存管理' then
          begin
            BringWindowToTop(frmWJGCKKCListGL.Handle);
            bFound := TRUE;
            Break;
          end;
        end;
        if not bFound then
        begin
          frmWJGCKKCListGL := TfrmWJGCKKCList.Create(application.MainForm);
          with frmWJGCKKCListGL do
          begin
            Title := '后加工库存管理';
            canshu1 := '管理';
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmWJGCKKCListGL.BringToFront;
       //句柄
        mnewHandle := frmWJGCKKCListGL.Handle;
      end;

    232:  //外加工库存(低权限)
      begin
        bFound := FALSE;
        for i := (App.MainForm.MDIChildCount - 1) downto 0 do
        begin
          if App.MainForm.MDIChildren[i].Caption = '后加工库存(低权限)' then
          begin
            BringWindowToTop(frmWJGCKKCListL.Handle);
            bFound := TRUE;
            Break;
          end;
        end;
        if not bFound then
        begin
          frmWJGCKKCListL := TfrmWJGCKKCList.Create(application.MainForm);
          with frmWJGCKKCListL do
          begin
            Title := '后加工库存(低权限)';
            canshu1 := '低权限';
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmWJGCKKCListL.BringToFront;
       //句柄
        mnewHandle := frmWJGCKKCListL.Handle;
      end;




//    232:  //外加工库存汇总
//      begin
//        if frmWJGCKKCHZList = nil then
//        begin
//          frmWJGCKKCHZList := TfrmWJGCKKCHZList.Create(application.MainForm);
//          with frmWJGCKKCHZList do
//          begin
//            caption := Trim(Title);
//            FormStyle := mstyle;
//            windowState := mstate;
//            BorderStyle := mborderstyle;
//           //show;
//          end;
//        end
//        else
//          frmWJGCKKCHZList.BringToFront;
//       //句柄
//        mnewHandle := frmWJGCKKCHZList.Handle;
//      end;

    311:  //成品样布入库管理
      begin
        bFound := FALSE;
        for i := (App.MainForm.MDIChildCount - 1) downto 0 do
        begin
          if App.MainForm.MDIChildren[i].Caption = '成品样布入库管理' then
          begin
            BringWindowToTop(frmDJBRKListGL.Handle);
            bFound := TRUE;
            Break;
          end;
        end;
        if not bFound then
        begin
          frmDJBRKListGL := TfrmDJBRKList.Create(application.MainForm);
          with frmDJBRKListGL do
          begin
            Title := '成品样布入库管理';
            canshu1 := '管理';
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmDJBRKListGL.BringToFront;
       //句柄
        mnewHandle := frmDJBRKListGL.Handle;
      end;

    312:  //成品样布入库(低权限)
      begin
        bFound := FALSE;
        for i := (App.MainForm.MDIChildCount - 1) downto 0 do
        begin
          if App.MainForm.MDIChildren[i].Caption = '成品样布入库(低权限)' then
          begin
            BringWindowToTop(frmDJBRKListL.Handle);
            bFound := TRUE;
            Break;
          end;
        end;
        if not bFound then
        begin
          frmDJBRKListL := TfrmDJBRKList.Create(application.MainForm);
          with frmDJBRKListL do
          begin
            Title := '成品样布入库(低权限)';
            canshu1 := '低权限';
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmDJBRKListL.BringToFront;
       //句柄
        mnewHandle := frmDJBRKListL.Handle;
      end;

    321:  //成品样布出库管理
      begin
        bFound := FALSE;
        for i := (App.MainForm.MDIChildCount - 1) downto 0 do
        begin
          if App.MainForm.MDIChildren[i].Caption = '成品样布出库管理' then
          begin
            BringWindowToTop(frmDJBCKOutListGL.Handle);
            bFound := TRUE;
            Break;
          end;
        end;
        if not bFound then
        begin
          frmDJBCKOutListGL := TfrmDJBCKOutList.Create(application.MainForm);
          with frmDJBCKOutListGL do
          begin
            Title := '成品样布出库管理';
            canshu1 := '管理';
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmDJBCKOutListGL.BringToFront;
       //句柄
        mnewHandle := frmDJBCKOutListGL.Handle;
      end;
    322:  //成品样布出库(低权限)
      begin
        bFound := FALSE;
        for i := (App.MainForm.MDIChildCount - 1) downto 0 do
        begin
          if App.MainForm.MDIChildren[i].Caption = '成品样布出库(低权限)' then
          begin
            BringWindowToTop(frmDJBCKOutListL.Handle);
            bFound := TRUE;
            Break;
          end;
        end;
        if not bFound then
        begin
          frmDJBCKOutListL := TfrmDJBCKOutList.Create(application.MainForm);
          with frmDJBCKOutListL do
          begin
            Title := '成品样布入库(低权限)';
            canshu1 := '低权限';
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmDJBCKOutListL.BringToFront;
       //句柄
        mnewHandle := frmDJBCKOutListL.Handle;
      end;

    331:  //成品样布库存管理
      begin
        bFound := FALSE;
        for i := (App.MainForm.MDIChildCount - 1) downto 0 do
        begin
          if App.MainForm.MDIChildren[i].Caption = '成品样布库存管理' then
          begin
            BringWindowToTop(frmDJBCKKCListGL.Handle);
            bFound := TRUE;
            Break;
          end;
        end;
        if not bFound then
        begin
          frmDJBCKKCListGL := TfrmDJBCKKCList.Create(application.MainForm);
          with frmDJBCKKCListGL do
          begin
            Title := '成品样布库存管理';
            canshu1 := '管理';
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmDJBCKKCListGL.BringToFront;
       //句柄
        mnewHandle := frmDJBCKKCListGL.Handle;
      end;

    332:  //成品样布库存(低权限)
      begin
        bFound := FALSE;
        for i := (App.MainForm.MDIChildCount - 1) downto 0 do
        begin
          if App.MainForm.MDIChildren[i].Caption = '成品样布库存(低权限)' then
          begin
            BringWindowToTop(frmDJBCKKCListL.Handle);
            bFound := TRUE;
            Break;
          end;
        end;
        if not bFound then
        begin
          frmDJBCKKCListL := TfrmDJBCKKCList.Create(application.MainForm);
          with frmDJBCKKCListL do
          begin
            Title := '成品样布库存(低权限)';
            canshu1 := '低权限';
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmDJBCKKCListL.BringToFront;
       //句柄
        mnewHandle := frmDJBCKKCListL.Handle;
      end;
//    332:  //待检布汇总库存列表
//      begin
//        if frmDJBCKKCHZList = nil then
//        begin
//          frmDJBCKKCHZList := TfrmDJBCKKCHZList.Create(application.MainForm);
//          with frmDJBCKKCHZList do
//          begin
//            caption := Trim(Title);
//            FormStyle := mstyle;
//            windowState := mstate;
//            BorderStyle := mborderstyle;
//           //show;
//          end;
//        end
//        else
//          frmDJBCKKCHZList.BringToFront;
//       //句柄
//        mnewHandle := frmDJBCKKCHZList.Handle;
//      end;


    411:  //成品入库管理
      begin
        bFound := FALSE;
        for i := (App.MainForm.MDIChildCount - 1) downto 0 do
        begin
          if App.MainForm.MDIChildren[i].Caption = '成品入库管理' then
          begin
            BringWindowToTop(frmCPBRKListGL.Handle);
            bFound := TRUE;
            Break;
          end;
        end;
        if not bFound then
        begin
          frmCPBRKListGL := TfrmCPBRKList.Create(application.MainForm);
          with frmCPBRKListGL do
          begin
            Title := '成品入库管理';
            canshu1 := '管理';
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmCPBRKListGL.BringToFront;
       //句柄
        mnewHandle := frmCPBRKListGL.Handle;
      end;

    412:  //成品入库(低权限)
      begin
        bFound := FALSE;
        for i := (App.MainForm.MDIChildCount - 1) downto 0 do
        begin
          if App.MainForm.MDIChildren[i].Caption = '成品入库(低权限)' then
          begin
            BringWindowToTop(frmCPBRKListL.Handle);
            bFound := TRUE;
            Break;
          end;
        end;
        if not bFound then
        begin
          frmCPBRKListL := TfrmCPBRKList.Create(application.MainForm);
          with frmCPBRKListL do
          begin
            Title := '成品入库(低权限)';
            canshu1 := '低权限';
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmCPBRKListL.BringToFront;
       //句柄
        mnewHandle := frmCPBRKListL.Handle;
      end;

    441:  //直销布出库申请
      begin
        bFound := FALSE;
        for i := (App.MainForm.MDIChildCount - 1) downto 0 do
        begin
          if App.MainForm.MDIChildren[i].Caption = '直销布出库申请 ' then
          begin
            BringWindowToTop(frmCPBCKOutListSQ.Handle);
            bFound := TRUE;
            Break;
          end;
        end;
        if not bFound then
        begin
          frmCPBCKOutListSQ := TfrmCPBCKOutList.Create(application.MainForm);
          with frmCPBCKOutListSQ do
          begin
            Title := '直销布出库申请 ';
            caption := Trim(Title);
            canshu1 := '申请录入';
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmCPBCKOutListSQ.BringToFront;
       //句柄
        mnewHandle := frmCPBCKOutListSQ.Handle;
      end;
    421:  //成品出库
      begin
        bFound := FALSE;
        for i := (App.MainForm.MDIChildCount - 1) downto 0 do
        begin
          if App.MainForm.MDIChildren[i].Caption = '成品出库管理' then
          begin
            BringWindowToTop(frmCPBCKOutListQR.Handle);
            bFound := TRUE;
            Break;
          end;
        end;
        if not bFound then
        begin
          frmCPBCKOutListQR := TfrmCPBCKOutList.Create(application.MainForm);
          with frmCPBCKOutListQR do
          begin
            Title := '成品出库管理';
            caption := Trim(Title);
            canshu1 := '管理';
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmCPBCKOutListQR.BringToFront;
       //句柄
        mnewHandle := frmCPBCKOutListQR.Handle;
      end;

    422:  //成品出库(低权限)
      begin
        bFound := FALSE;
        for i := (App.MainForm.MDIChildCount - 1) downto 0 do
        begin
          if App.MainForm.MDIChildren[i].Caption = '成品出库(低权限)' then
          begin
            BringWindowToTop(frmCPBCKOutListL.Handle);
            bFound := TRUE;
            Break;
          end;
        end;
        if not bFound then
        begin
          frmCPBCKOutListL := TfrmCPBCKOutList.Create(application.MainForm);
          with frmCPBCKOutListL do
          begin
            Title := '成品出库(低权限)';
            caption := Trim(Title);
            canshu1 := '低权限';
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmCPBCKOutListL.BringToFront;
       //句柄
        mnewHandle := frmCPBCKOutListL.Handle;
      end;

    431:  //成品库存管理
      begin
        bFound := FALSE;
        for i := (App.MainForm.MDIChildCount - 1) downto 0 do
        begin
          if App.MainForm.MDIChildren[i].Caption = '成品库存管理' then
          begin
            BringWindowToTop(frmCPBCKKCListGL.Handle);
            bFound := TRUE;
            Break;
          end;
        end;
        if not bFound then
        begin
          frmCPBCKKCListGL := TfrmCPBCKKCList.Create(application.MainForm);
          with frmCPBCKKCListGL do
          begin
            Title := '成品库存管理';
            caption := Trim(Title);
            canshu1 := '管理';
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmCPBCKKCListGL.BringToFront;
       //句柄
        mnewHandle := frmCPBCKKCListGL.Handle;
      end;

    432:  //成品库存(低权限)
      begin
        bFound := FALSE;
        for i := (App.MainForm.MDIChildCount - 1) downto 0 do
        begin
          if App.MainForm.MDIChildren[i].Caption = '成品库存(低权限)' then
          begin
            BringWindowToTop(frmCPBCKKCListL.Handle);
            bFound := TRUE;
            Break;
          end;
        end;
        if not bFound then
        begin
          frmCPBCKKCListL := TfrmCPBCKKCList.Create(application.MainForm);
          with frmCPBCKKCListL do
          begin
            Title := '成品库存(低权限)';
            caption := Trim(Title);
            canshu1 := '低权限';
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmCPBCKKCListL.BringToFront;
       //句柄
        mnewHandle := frmCPBCKKCListL.Handle;
      end;

  end;

  Result := mnewHandle;
//  NewDllApp := Application;
end;
//===========================================================
  //建立数据库连接池
//===========================================================

function ConnData(): Boolean;
begin
  if not Assigned(DataLink_PBMDDJ) then
    DataLink_PBMDDJ := TDataLink_PBMDDJ.Create(Application);
  try
    with DataLink_PBMDDJ.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_PBMDDJ.Free;
//  Application := OldDllApp;

initialization
  CoInitialize(nil);
  dxUnitsLoader.Initialize;


finalization
  DataLink_PBMDDJ.Free;
  application := NewDllApp;
  dxUnitsLoader.Finalize;

end.

