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_FinishedClothInspection, U_FinishedClothOutList,
  U_FinishedClothInList, U_FinishedClothKCList, U_FCSMCK, U_CPSQSMCK,
  U_CPFHSQList, U_CPCKMdList, U_FinishedClothStatistical, U_FinishedClothDCheG,
  U_FinishedClothZJing, U_FinishedClothSZhou, U_FinishedClothXZhou,
  U_FinishedClothCZong, U_FinishedClothTJing, U_FinishedClothJTou,
  U_FinishedClothKBan, U_FinishedClothKBanMonth, U_BDKuWei, U_FinishedCloth_PZ,
  U_YCFinishedClothInspection;

       /////////////////////////////////////////////////////////////////
      //         功能说明:取Dll中得窗体                              //
     //        参数说明：App>>调用应用程序；                        //
    //                 FormH>>调用窗口句柄 ；                      //
   //                 FormID>>窗口号;                             //
  //                 Language>>语言种类;                         //
 //                 WinStyle>>窗口类型；                        //
/////////////////////////////////////////////////////////////////
var
  frmFinishedClothInListGL, frmFinishedClothInListCX: TfrmFinishedClothInList;
  frmFinishedClothOutListGL, frmFinishedClothOutListCX: TfrmFinishedClothOutList;
  frmFinishedClothKCListGL, frmFinishedClothKCListCX: TfrmFinishedClothKCList;
  frmFinishedClothInspectionGL, frmFinishedClothInspectionCX: TfrmFinishedClothInspection;
  frmCPFHSQListLR, frmCPFHSQListSH, frmCPFHSQListCX: TfrmCPFHSQList;
  frmFinishedClothStatistical: TfrmFinishedClothStatistical;
  frmFinishedClothDCheG: TfrmFinishedClothDCheG;
  frmFinishedClothZJing: TfrmFinishedClothZJing;
  frmFinishedClothSZhou: TfrmFinishedClothSZhou;
  frmFinishedClothXZhou: TfrmFinishedClothXZhou;
  frmFinishedClothCZong: TfrmFinishedClothCZong;
  frmFinishedClothTJing: TfrmFinishedClothTJing;
  frmFinishedClothJTou: TfrmFinishedClothJTou;
  frmFinishedClothKBan: TfrmFinishedClothKBan;
  frmFinishedClothKBanMonth: TfrmFinishedClothKBanMonth;
  frmYCFinishedClothInspectionGL: TfrmYCFinishedClothInspection;

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 := '101.132.143.144,7781';
//  server := '.';
    dtbase := 'yiduidata';
    user := 'rtsa';
    pswd := 'rightsoft@5740';
    DConString := 'Provider=SQLOLEDB.1;Password=' + pswd + ';Persist Security Info=True;User ID=' + user + ';Initial Catalog=' + dtbase + ';Data Source=' + server;

  end
  else
    DConString := DataBaseStr;

  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
    400:  //异常数据
      begin
        bFound := FALSE;
        for i := (App.MainForm.MDIChildCount - 1) downto 0 do
        begin
          if App.MainForm.MDIChildren[i].Caption = '异常数据管理' then
          begin
            BringWindowToTop(frmYCFinishedClothInspectionGL.Handle);
            bFound := TRUE;
            Break;
          end;
        end;
        if not bFound then
        begin
          frmYCFinishedClothInspectionGL := TfrmYCFinishedClothInspection.Create(application.MainForm);
          with frmYCFinishedClothInspectionGL do
          begin
            Title := '异常数据管理';
            canshu1 := '管理';
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmYCFinishedClothInspectionGL.BringToFront;
       //句柄
        mnewHandle := frmYCFinishedClothInspectionGL.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(frmFinishedClothInspectionGL.Handle);
            bFound := TRUE;
            Break;
          end;
        end;
        if not bFound then
        begin
          frmFinishedClothInspectionGL := TfrmFinishedClothInspection.Create(application.MainForm);
          with frmFinishedClothInspectionGL do
          begin
            Title := '检验信息管理';
            canshu1 := '管理';
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmFinishedClothInspectionGL.BringToFront;
       //句柄
        mnewHandle := frmFinishedClothInspectionGL.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(frmFinishedClothInspectionCX.Handle);
            bFound := TRUE;
            Break;
          end;
        end;
        if not bFound then
        begin
          frmFinishedClothInspectionCX := TfrmFinishedClothInspection.Create(application.MainForm);
          with frmFinishedClothInspectionCX do
          begin
            Title := '检验信息查询';
            canshu1 := '查询';
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmFinishedClothInspectionCX.BringToFront;
       //句柄
        mnewHandle := frmFinishedClothInspectionCX.Handle;
      end;
    413:  //验布工产量统计
      begin
        bFound := FALSE;
        for i := (App.MainForm.MDIChildCount - 1) downto 0 do
        begin
          if App.MainForm.MDIChildren[i].Caption = '验布工产量统计' then
          begin
            BringWindowToTop(frmFinishedClothStatistical.Handle);
            bFound := TRUE;
            Break;
          end;
        end;
        if not bFound then
        begin
          frmFinishedClothStatistical := TfrmFinishedClothStatistical.Create(application.MainForm);
          with frmFinishedClothStatistical do
          begin
            Title := '验布工产量统计';
            canshu1 := '验布工';
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmFinishedClothStatistical.BringToFront;
       //句柄
        mnewHandle := frmFinishedClothStatistical.Handle;
      end;

    414:  //挡车工产量统计
      begin
        bFound := FALSE;
        for i := (App.MainForm.MDIChildCount - 1) downto 0 do
        begin
          if App.MainForm.MDIChildren[i].Caption = '挡车工产量统计' then
          begin
            BringWindowToTop(frmFinishedClothDCheG.Handle);
            bFound := TRUE;
            Break;
          end;
        end;
        if not bFound then
        begin
          frmFinishedClothDCheG := TfrmFinishedClothDCheG.Create(application.MainForm);
          with frmFinishedClothDCheG do
          begin
            Title := '挡车工产量统计';
            canshu1 := '挡车工';
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmFinishedClothDCheG.BringToFront;
       //句柄
        mnewHandle := frmFinishedClothDCheG.Handle;
      end;

    511:  //品种汇总统计
      begin
        if frmFinishedCloth_PZ = nil then
        begin
          frmFinishedCloth_PZ := TfrmFinishedCloth_PZ.Create(application.MainForm);
          with frmFinishedCloth_PZ do
          begin
            Title := '品种汇总统计';
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmFinishedCloth_PZ.BringToFront;
       //句柄
        mnewHandle := frmFinishedCloth_PZ.Handle;
      end;
    415:  //整经产量统计
      begin
        bFound := FALSE;
        for i := (App.MainForm.MDIChildCount - 1) downto 0 do
        begin
          if App.MainForm.MDIChildren[i].Caption = '整经产量统计' then
          begin
            BringWindowToTop(frmFinishedClothZJing.Handle);
            bFound := TRUE;
            Break;
          end;
        end;
        if not bFound then
        begin
          frmFinishedClothZJing := TfrmFinishedClothZJing.Create(application.MainForm);
          with frmFinishedClothZJing do
          begin
            Title := '整经产量统计';
            canshu1 := '扦经工';
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmFinishedClothZJing.BringToFront;
       //句柄
        mnewHandle := frmFinishedClothZJing.Handle;
      end;
    416:  //上轴产量统计
      begin
        bFound := FALSE;
        for i := (App.MainForm.MDIChildCount - 1) downto 0 do
        begin
          if App.MainForm.MDIChildren[i].Caption = '上轴产量统计' then
          begin
            BringWindowToTop(frmFinishedClothSZhou.Handle);
            bFound := TRUE;
            Break;
          end;
        end;
        if not bFound then
        begin
          frmFinishedClothSZhou := TfrmFinishedClothSZhou.Create(application.MainForm);
          with frmFinishedClothSZhou do
          begin
            Title := '上轴产量统计';
            canshu1 := '上轴工';
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmFinishedClothSZhou.BringToFront;
       //句柄
        mnewHandle := frmFinishedClothSZhou.Handle;
      end;
    417:  //下轴产量统计
      begin
        bFound := FALSE;
        for i := (App.MainForm.MDIChildCount - 1) downto 0 do
        begin
          if App.MainForm.MDIChildren[i].Caption = '下轴产量统计' then
          begin
            BringWindowToTop(frmFinishedClothXZhou.Handle);
            bFound := TRUE;
            Break;
          end;
        end;
        if not bFound then
        begin
          frmFinishedClothXZhou := TfrmFinishedClothXZhou.Create(application.MainForm);
          with frmFinishedClothXZhou do
          begin
            Title := '下轴产量统计';
            canshu1 := '下轴工';
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmFinishedClothXZhou.BringToFront;
       //句柄
        mnewHandle := frmFinishedClothXZhou.Handle;
      end;
    418:  //穿综产量统计
      begin
        bFound := FALSE;
        for i := (App.MainForm.MDIChildCount - 1) downto 0 do
        begin
          if App.MainForm.MDIChildren[i].Caption = '穿综产量统计' then
          begin
            BringWindowToTop(frmFinishedClothCZong.Handle);
            bFound := TRUE;
            Break;
          end;
        end;
        if not bFound then
        begin
          frmFinishedClothCZong := TfrmFinishedClothCZong.Create(application.MainForm);
          with frmFinishedClothCZong do
          begin
            Title := '穿综产量统计';
            canshu1 := '穿综工';
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmFinishedClothCZong.BringToFront;
       //句柄
        mnewHandle := frmFinishedClothCZong.Handle;
      end;
    419:  //停经产量统计
      begin
        bFound := FALSE;
        for i := (App.MainForm.MDIChildCount - 1) downto 0 do
        begin
          if App.MainForm.MDIChildren[i].Caption = '停经产量统计' then
          begin
            BringWindowToTop(frmFinishedClothTJing.Handle);
            bFound := TRUE;
            Break;
          end;
        end;
        if not bFound then
        begin
          frmFinishedClothTJing := TfrmFinishedClothTJing.Create(application.MainForm);
          with frmFinishedClothTJing do
          begin
            Title := '停经产量统计';
            canshu1 := '停经工';
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmFinishedClothTJing.BringToFront;
       //句柄
        mnewHandle := frmFinishedClothTJing.Handle;
      end;
    420:  //接头产量统计
      begin
        bFound := FALSE;
        for i := (App.MainForm.MDIChildCount - 1) downto 0 do
        begin
          if App.MainForm.MDIChildren[i].Caption = '接头产量统计' then
          begin
            BringWindowToTop(frmFinishedClothJTou.Handle);
            bFound := TRUE;
            Break;
          end;
        end;
        if not bFound then
        begin
          frmFinishedClothJTou := TfrmFinishedClothJTou.Create(application.MainForm);
          with frmFinishedClothJTou do
          begin
            Title := '接头产量统计';
            canshu1 := '接头工';
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmFinishedClothJTou.BringToFront;
       //句柄
        mnewHandle := frmFinishedClothJTou.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(frmFinishedClothKBan.Handle);
            bFound := TRUE;
            Break;
          end;
        end;
        if not bFound then
        begin
          frmFinishedClothKBan := TfrmFinishedClothKBan.Create(application.MainForm);
          with frmFinishedClothKBan do
          begin
            Title := '每日看板统计';
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmFinishedClothKBan.BringToFront;
       //句柄
        mnewHandle := frmFinishedClothKBan.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(frmFinishedClothKBanMonth.Handle);
            bFound := TRUE;
            Break;
          end;
        end;
        if not bFound then
        begin
          frmFinishedClothKBanMonth := TfrmFinishedClothKBanMonth.Create(application.MainForm);
          with frmFinishedClothKBanMonth do
          begin
            Title := '月报表统计';
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmFinishedClothKBanMonth.BringToFront;
       //句柄
        mnewHandle := frmFinishedClothKBanMonth.Handle;
      end;
    111:  //成品入库管理
      begin
        bFound := FALSE;
        for i := (App.MainForm.MDIChildCount - 1) downto 0 do
        begin
          if App.MainForm.MDIChildren[i].Caption = '成品入库管理' then
          begin
            BringWindowToTop(frmFinishedClothInListGL.Handle);
            bFound := TRUE;
            Break;
          end;
        end;
        if not bFound then
        begin
          frmFinishedClothInListGL := TfrmFinishedClothInList.Create(application.MainForm);
          with frmFinishedClothInListGL do
          begin
            canshu1 := '管理';
            Title := '成品入库管理';
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmFinishedClothInListGL.BringToFront;
       //句柄
        mnewHandle := frmFinishedClothInListGL.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(frmFinishedClothInListCX.Handle);
            bFound := TRUE;
            Break;
          end;
        end;
        if not bFound then
        begin
          frmFinishedClothInListCX := TfrmFinishedClothInList.Create(application.MainForm);
          with frmFinishedClothInListCX do
          begin
            canshu1 := '查询';
            Title := '成品入库查询';
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmFinishedClothInListCX.BringToFront;
       //句柄
        mnewHandle := frmFinishedClothInListCX.Handle;
      end;
    113:  //绑定库位
      begin
        if frmBDKuWei = nil then
        begin
          frmBDKuWei := TfrmBDKuWei.Create(application.MainForm);
          with frmBDKuWei do
          begin
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;           
           //show;
          end;
        end
        else
          frmBDKuWei.BringToFront;
       //句柄
        mnewHandle := frmBDKuWei.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(frmCPFHSQListLR.Handle);
            bFound := TRUE;
            Break;
          end;
        end;
        if not bFound then
        begin
          frmCPFHSQListLR := TfrmCPFHSQList.Create(application.MainForm);
          with frmCPFHSQListLR do
          begin
            canshu1 := '录入';
            Title := '成品发货申请录入';
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmCPFHSQListLR.BringToFront;
       //句柄
        mnewHandle := frmCPFHSQListLR.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(frmCPFHSQListSH.Handle);
            bFound := TRUE;
            Break;
          end;
        end;
        if not bFound then
        begin
          frmCPFHSQListSH := TfrmCPFHSQList.Create(application.MainForm);
          with frmCPFHSQListSH do
          begin
            canshu1 := '审核';
            Title := '成品发货申请审核';
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmCPFHSQListSH.BringToFront;
       //句柄
        mnewHandle := frmCPFHSQListSH.Handle;
      end;
    223:  //成品发货申请查询
      begin
        bFound := FALSE;
        for i := (App.MainForm.MDIChildCount - 1) downto 0 do
        begin
          if App.MainForm.MDIChildren[i].Caption = '成品发货申请查询' then
          begin
            BringWindowToTop(frmCPFHSQListCX.Handle);
            bFound := TRUE;
            Break;
          end;
        end;
        if not bFound then
        begin
          frmCPFHSQListCX := TfrmCPFHSQList.Create(application.MainForm);
          with frmCPFHSQListCX do
          begin
            canshu1 := '查询';
            Title := '成品发货申请查询';
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmCPFHSQListCX.BringToFront;
       //句柄
        mnewHandle := frmCPFHSQListCX.Handle;
      end;

    231:  //扫描出库
      begin
        if frmCPSQSMCK = nil then
        begin
          frmCPSQSMCK := TfrmCPSQSMCK.Create(application.MainForm);
          with frmCPSQSMCK do
          begin
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;           
           //show;
          end;
        end
        else
          frmCPSQSMCK.BringToFront;
       //句柄
        mnewHandle := frmCPSQSMCK.Handle;
      end;

    232:  //扫描出库
      begin
        if frmFCSMCK = nil then
        begin
          frmFCSMCK := TfrmFCSMCK.Create(application.MainForm);
          with frmFCSMCK do
          begin
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmFCSMCK.BringToFront;
       //句柄
        mnewHandle := frmFCSMCK.Handle;
      end;

    241:  //码单打印
      begin
        if frmCPCKMdList = nil then
        begin
          frmCPCKMdList := TfrmCPCKMdList.Create(application.MainForm);
          with frmCPCKMdList do
          begin
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmCPCKMdList.BringToFront;
       //句柄
        mnewHandle := frmCPCKMdList.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(frmFinishedClothOutListGL.Handle);
            bFound := TRUE;
            Break;
          end;
        end;
        if not bFound then
        begin
          frmFinishedClothOutListGL := TfrmFinishedClothOutList.Create(application.MainForm);
          with frmFinishedClothOutListGL do
          begin
            canshu1 := '管理';
            Title := '成品出库管理';
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmFinishedClothOutListGL.BringToFront;
       //句柄
        mnewHandle := frmFinishedClothOutListGL.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(frmFinishedClothOutListCX.Handle);
            bFound := TRUE;
            Break;
          end;
        end;
        if not bFound then
        begin
          frmFinishedClothOutListCX := TfrmFinishedClothOutList.Create(application.MainForm);
          with frmFinishedClothOutListCX do
          begin
            canshu1 := '查询';
            Title := '成品出库查询';
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
          end;
        end
        else
          frmFinishedClothOutListCX.BringToFront;
       //句柄
        mnewHandle := frmFinishedClothOutListCX.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(frmFinishedClothKCListGL.Handle);
            bFound := TRUE;
            Break;
          end;
        end;
        if not bFound then
        begin
          frmFinishedClothKCListGL := TfrmFinishedClothKCList.Create(application.MainForm);
          with frmFinishedClothKCListGL do
          begin
            canshu1 := '管理';
            Title := '成品库存管理';
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
          end;
        end
        else
          frmFinishedClothKCListGL.BringToFront;
       //句柄
        mnewHandle := frmFinishedClothKCListGL.Handle;
      end;
  end;

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

function ConnData(): Boolean;
begin
  if not Assigned(DataLink_FinishedClothWarehouse) then
    DataLink_FinishedClothWarehouse := TDataLink_FinishedClothWarehouse.Create(Application);
  try
    with DataLink_FinishedClothWarehouse.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_FinishedClothWarehouse.Free;
//  Application := OldDllApp;
initialization
  CoInitialize(nil);
  dxUnitsLoader.Initialize;


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

end.

