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_Fun, U_YFCRSave, U_FKCRSave, U_YFMXlist, U_YFFPSave, U_YSCRSave,
  U_SKCRSave, U_YSSKList, U_YSMXlist, U_ZZYSCRSave, U_ZZSKCRSave, U_ZZYSSKList,
  U_ZZYSMXTaiToulist, U_YSFPSave, U_ZZYSSKYFFKList, U_OtherFeeSave,
  U_OtherFeeSaveMenShi, U_YFFKListTaiTou, U_YFMXlistTaiTou, U_YSSKListTaiTou,
  U_YSMXlistTaiTou, U_YSCRSaveQC, U_XSPriceChk, U_XSQtyeChk, U_KHSKList,
  U_YSSKListRMBMJ, U_YSMXlistMonDay, U_KHSKChkList, U_BankMoneyQCList,
  U_BankMoneyKHList, U_CGPriceChk, U_YFCRSaveQC, U_GYSFKList, U_GYSFKChkList,
  U_YFFKList, U_YFMXlistMonDay, U_YFMXlistMonDayGQX, U_YFFKListDZ,
  U_YSSKListRMBMJDZ, U_BankMoneyGYSList, U_YSSKListRMBMJDZEY, U_YFFKListDZEY,
  U_YWJSList, U_CaiWuHuilV, U_FuFeeList, U_GYSRFList, U_KHTop, U_YWYTop,
  U_WorkerPayListB, U_TJWorkerPayListB;


       /////////////////////////////////////////////////////////////////
      //         功能说明:取Dll中得窗体                              //
     //        参数说明：App>>调用应用程序；                        //
    //                 FormH>>调用窗口句柄 ；                      //
   //                 FormID>>窗口号;                             //
  //                 Language>>语言种类;                         //
 //                 WinStyle>>窗口类型；                        //
/////////////////////////////////////////////////////////////////
var
  frmOtherFeeSaveLR, frmOtherFeeSaveCX: TfrmOtherFeeSave;
  frmOtherFeeSaveMenShiLRGY, frmOtherFeeSaveMenShiLRXN, frmOtherFeeSaveMenShiLRLX: TfrmOtherFeeSaveMenShi;
  frmOtherFeeSaveMenShiLRGYCX, frmOtherFeeSaveMenShiLRXNCX, frmOtherFeeSaveMenShiLRLXCX: TfrmOtherFeeSaveMenShi;
  frmOtherFeeSaveMenShiCX: TfrmOtherFeeSaveMenShi;
  frmBankMoneyKHListLR, frmBankMoneyKHListGL: TfrmBankMoneyKHList;
  frmBankMoneyGYSListLR, frmBankMoneyGYSListGL: TfrmBankMoneyGYSList;
  frmYSSKListRMBMJDZEY, frmYSSKListRMBMJDZEYCX: TfrmYSSKListRMBMJDZEY;
  frmYFFKListDZEY, frmYFFKListDZEYCX: TfrmYFFKListDZEY;
  frmYWJSListLR, frmYWJSListGL: TfrmYWJSList;
  frmFuFeeListLR, frmFuFeeListGL: TfrmFuFeeList;
  frmGYSRFListLR, frmGYSRFListGL: TfrmGYSRFList;
  frmWorkerPayListBGL, frmWorkerPayListBCX: TfrmWorkerPayListB;

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 := 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;


   //赋值链接字符串
  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;
  //DName:='罗梦';  DCode:='LM';

  if not ConnData() then
  begin
    result := 0;
    exit;
  end;
  { if IsINIFile() then
      ReadINIFile()
   else
      WriteINIFile ;}
   // 定义窗口类型 、状态
  if WinStyle = 0 then
  begin
    mstyle := fsMDIChild;
    mstate := wsMaximized;
    mborderstyle := bsSizeable;
  end
  else
  begin
    mstyle := fsNormal;
    mstate := wsNormal;
    mborderstyle := bsSizeable;
  end;
   ////////////////////
  { GetSWLDZ('192.168.1.246');
   if IpCall<>0 then
   begin
     Result:=0;
     Application.MessageBox('！！网络不通！！','提示',0);
     Exit;
   end;
   if Trim(IpWLDZStr)<>'D4:AE:52:BE:9F:02'  then
   begin
     Result:=0;
     Application.MessageBox('！！数据库连接失败！！','提示',0);
     Exit;
   end; }
  /////////////////////
  //调用子模块窗口
  case FormID of

    -101:  //客户销售排行榜
      begin
        if frmKHTop = nil then
        begin
          frmKHTop := TfrmKHTop.Create(application.MainForm);
          with frmKHTop do
          begin
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmKHTop.BringToFront;
       //句柄
        mnewHandle := frmKHTop.Handle;
      end;
    -102:  //业务员销售排行榜
      begin
        if frmYWYTop = nil then
        begin
          frmYWYTop := TfrmYWYTop.Create(application.MainForm);
          with frmYWYTop do
          begin
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmYWYTop.BringToFront;
       //句柄
        mnewHandle := frmYWYTop.Handle;
      end;
    -1103:  //员工工资汇总查询
      begin
        if frmTJWorkerPayListB = nil then
        begin
          frmTJWorkerPayListB := TfrmTJWorkerPayListB.Create(application.MainForm);    
          with frmTJWorkerPayListB do
          begin
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmTJWorkerPayListB.BringToFront;
       //句柄
        mnewHandle := frmTJWorkerPayListB.Handle;
      end;
    -103:  //固定工资管理*
      begin
        bFound := FALSE;
        for i := (App.MainForm.MDIChildCount - 1) downto 0 do
        begin
          if App.MainForm.MDIChildren[i].Caption = '固定工资管理*' then
          begin
            BringWindowToTop(frmWorkerPayListBGL.Handle);
            bFound := TRUE;
            Break;
          end;
        end;
        if not bFound then
       //if frmBaoGuanListBGZL=nil then
        begin
          frmWorkerPayListBGL := TfrmWorkerPayListB.Create(application.MainForm);
          with frmWorkerPayListBGL do
          begin
            Title := '固定工资管理*';
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmWorkerPayListBGL.BringToFront;
       //句柄
        mnewHandle := frmWorkerPayListBGL.Handle;
      end;
    -104:  //固定工资查询*
      begin
        bFound := FALSE;
        for i := (App.MainForm.MDIChildCount - 1) downto 0 do
        begin
          if App.MainForm.MDIChildren[i].Caption = '固定工资查询*' then
          begin
            BringWindowToTop(frmWorkerPayListBCX.Handle);
            bFound := TRUE;
            Break;
          end;
        end;
        if not bFound then
       //if frmBaoGuanListBGZL=nil then
        begin
          frmWorkerPayListBCX := TfrmWorkerPayListB.Create(application.MainForm);
          with frmWorkerPayListBCX do
          begin
            Title := '固定工资查询*';
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmWorkerPayListBCX.BringToFront;
       //句柄
        mnewHandle := frmWorkerPayListBCX.Handle;
      end;
    -1:  //汇率设置
      begin
        if frmCaiWuHuiLV = nil then
        begin
          frmCaiWuHuiLV := TfrmCaiWuHuiLV.Create(application.MainForm);
          with frmCaiWuHuiLV do
          begin
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmCaiWuHuiLV.BringToFront;
       //句柄
        mnewHandle := frmCaiWuHuiLV.Handle;
      end;
    0:  //期初应付款登记 有保存按钮
      begin
        if frmYFCRSaveQC = nil then
        begin
          frmYFCRSaveQC := TfrmYFCRSaveQC.Create(application.MainForm);
          with frmYFCRSaveQC do
          begin
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmYFCRSaveQC.BringToFront;
       //句柄
        mnewHandle := frmYFCRSaveQC.Handle;
      end;
    402:  //应付款对账*
      begin
        bFound := FALSE;
        for i := (App.MainForm.MDIChildCount - 1) downto 0 do
        begin
          if App.MainForm.MDIChildren[i].Caption = '应付款对账*' then
          begin
            BringWindowToTop(frmYFFKListDZEY.Handle);
            bFound := TRUE;
            Break;
          end;
        end;
        if not bFound then
       //if frmBaoGuanListBGZL=nil then
        begin
          frmYFFKListDZEY := TfrmYFFKListDZEY.Create(application.MainForm);
          with frmYFFKListDZEY do
          begin
            Title := '应付款对账*';
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmYFFKListDZEY.BringToFront;
       //句柄
        mnewHandle := frmYFFKListDZEY.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(frmYFFKListDZEYCX.Handle);
            bFound := TRUE;
            Break;
          end;
        end;
        if not bFound then
       //if frmBaoGuanListBGZL=nil then
        begin
          frmYFFKListDZEYCX := TfrmYFFKListDZEY.Create(application.MainForm);
          with frmYFFKListDZEYCX do
          begin
            Title := '供应商对账单查询*';
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmYFFKListDZEYCX.BringToFront;
       //句柄
        mnewHandle := frmYFFKListDZEYCX.Handle;
      end;

    501:  //期初应收款登记 有保存按钮
      begin
        if frmYSCRSaveQC = nil then
        begin
          frmYSCRSaveQC := TfrmYSCRSaveQC.Create(application.MainForm);
          with frmYSCRSaveQC do
          begin
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmYSCRSaveQC.BringToFront;
       //句柄
        mnewHandle := frmYSCRSaveQC.Handle;

      end;
    602:  //应收款对账*
      begin
        bFound := FALSE;
        for i := (App.MainForm.MDIChildCount - 1) downto 0 do
        begin
          if App.MainForm.MDIChildren[i].Caption = '应收款对账*' then
          begin
            BringWindowToTop(frmYSSKListRMBMJDZEY.Handle);
            bFound := TRUE;
            Break;
          end;
        end;
        if not bFound then
       //if frmBaoGuanListBGZL=nil then
        begin
          frmYSSKListRMBMJDZEY := TfrmYSSKListRMBMJDZEY.Create(application.MainForm);
          with frmYSSKListRMBMJDZEY do
          begin
            Title := '应收款对账*';
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmYSSKListRMBMJDZEY.BringToFront;
       //句柄
        mnewHandle := frmYSSKListRMBMJDZEY.Handle;
      end;
    7:  //客户对账单查询*
      begin
        bFound := FALSE;
        for i := (App.MainForm.MDIChildCount - 1) downto 0 do
        begin
          if App.MainForm.MDIChildren[i].Caption = '客户对账单查询*' then
          begin
            BringWindowToTop(frmYSSKListRMBMJDZEYCX.Handle);
            bFound := TRUE;
            Break;
          end;
        end;
        if not bFound then
       //if frmBaoGuanListBGZL=nil then
        begin
          frmYSSKListRMBMJDZEYCX := TfrmYSSKListRMBMJDZEY.Create(application.MainForm);
          with frmYSSKListRMBMJDZEYCX do
          begin
            Title := '客户对账单查询*';
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmYSSKListRMBMJDZEYCX.BringToFront;
       //句柄
        mnewHandle := frmYSSKListRMBMJDZEYCX.Handle;
      end;

    9:  //账户期初余额录入
      begin
        if frmBankMoneyQCList = nil then
        begin
          frmBankMoneyQCList := TfrmBankMoneyQCList.Create(application.MainForm);
          with frmBankMoneyQCList do
          begin
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmBankMoneyQCList.BringToFront;
       //句柄
        mnewHandle := frmBankMoneyQCList.Handle;
      end;
    10:  //客户费用录入*
      begin
        bFound := FALSE;
        for i := (App.MainForm.MDIChildCount - 1) downto 0 do
        begin
          if App.MainForm.MDIChildren[i].Caption = '客户费用录入*' then
          begin
            BringWindowToTop(frmBankMoneyKHListLR.Handle);
            bFound := TRUE;
            Break;
          end;
        end;
        if not bFound then
       //if frmBaoGuanListBGZL=nil then
        begin
          frmBankMoneyKHListLR := TfrmBankMoneyKHList.Create(application.MainForm);
          with frmBankMoneyKHListLR do
          begin
            Title := '客户费用录入*';
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmBankMoneyKHListLR.BringToFront;
       //句柄
        mnewHandle := frmBankMoneyKHListLR.Handle;
      end;
    11:  //客户费用管理*
      begin
        bFound := FALSE;
        for i := (App.MainForm.MDIChildCount - 1) downto 0 do
        begin
          if App.MainForm.MDIChildren[i].Caption = '客户费用管理*' then
          begin
            BringWindowToTop(frmBankMoneyKHListGL.Handle);
            bFound := TRUE;
            Break;
          end;
        end;
        if not bFound then
       //if frmBaoGuanListBGZL=nil then
        begin
          frmBankMoneyKHListGL := TfrmBankMoneyKHList.Create(application.MainForm);
          with frmBankMoneyKHListGL do
          begin
            Title := '客户费用管理*';
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmBankMoneyKHListGL.BringToFront;
       //句柄
        mnewHandle := frmBankMoneyKHListGL.Handle;
      end;
    1101:  //客户费用付款录入*
      begin
        bFound := FALSE;
        for i := (App.MainForm.MDIChildCount - 1) downto 0 do
        begin
          if App.MainForm.MDIChildren[i].Caption = '客户费用付款录入*' then
          begin
            BringWindowToTop(frmFuFeeListLR.Handle);
            bFound := TRUE;
            Break;
          end;
        end;
        if not bFound then
       //if frmBaoGuanListBGZL=nil then
        begin
          frmFuFeeListLR := TfrmFuFeeList.Create(application.MainForm);
          with frmFuFeeListLR do
          begin
            Title := '客户费用付款录入*';
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmFuFeeListLR.BringToFront;
       //句柄
        mnewHandle := frmFuFeeListLR.Handle;
      end;
    1102:  //客户费用付款管理*
      begin
        bFound := FALSE;
        for i := (App.MainForm.MDIChildCount - 1) downto 0 do
        begin
          if App.MainForm.MDIChildren[i].Caption = '客户费用付款管理*' then
          begin
            BringWindowToTop(frmFuFeeListGL.Handle);
            bFound := TRUE;
            Break;
          end;
        end;
        if not bFound then
       //if frmBaoGuanListBGZL=nil then
        begin
          frmFuFeeListGL := TfrmFuFeeList.Create(application.MainForm);
          with frmFuFeeListGL do
          begin
            Title := '客户费用付款管理*';
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmFuFeeListGL.BringToFront;
       //句柄
        mnewHandle := frmFuFeeListGL.Handle;
      end;
    12:  //供应商费用录入*
      begin
        bFound := FALSE;
        for i := (App.MainForm.MDIChildCount - 1) downto 0 do
        begin
          if App.MainForm.MDIChildren[i].Caption = '供应商费用录入*' then
          begin
            BringWindowToTop(frmBankMoneyGYSListLR.Handle);
            bFound := TRUE;
            Break;
          end;
        end;
        if not bFound then
       //if frmBaoGuanListBGZL=nil then
        begin
          frmBankMoneyGYSListLR := TfrmBankMoneyGYSList.Create(application.MainForm);
          with frmBankMoneyGYSListLR do
          begin
            Title := '供应商费用录入*';
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmBankMoneyGYSListLR.BringToFront;
       //句柄
        mnewHandle := frmBankMoneyGYSListLR.Handle;
      end;
    13:  //供应商费用管理*
      begin
        bFound := FALSE;
        for i := (App.MainForm.MDIChildCount - 1) downto 0 do
        begin
          if App.MainForm.MDIChildren[i].Caption = '供应商费用管理*' then
          begin
            BringWindowToTop(frmBankMoneyGYSListGL.Handle);
            bFound := TRUE;
            Break;
          end;
        end;
        if not bFound then
       //if frmBaoGuanListBGZL=nil then
        begin
          frmBankMoneyGYSListGL := TfrmBankMoneyGYSList.Create(application.MainForm);
          with frmBankMoneyGYSListGL do
          begin
            Title := '供应商费用管理*';
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmBankMoneyGYSListGL.BringToFront;
       //句柄
        mnewHandle := frmBankMoneyGYSListGL.Handle;
      end;
    1:  //采购单价审核
      begin
        if frmCGPriceChk = nil then
        begin
          frmCGPriceChk := TfrmCGPriceChk.Create(application.MainForm);
          with frmCGPriceChk do
          begin
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmCGPriceChk.BringToFront;
       //句柄
        mnewHandle := frmCGPriceChk.Handle;

      end;
    2:  //付款登记  有保存按钮
      begin
        if frmGYSFKList = nil then
        begin
          frmGYSFKList := TfrmGYSFKList.Create(application.MainForm);
          with frmGYSFKList do
          begin
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmGYSFKList.BringToFront;
       //句柄
        mnewHandle := frmGYSFKList.Handle;

      end;
    3:  //付款审核
      begin
        if frmGYSFKChkList = nil then
        begin
          frmGYSFKChkList := TfrmGYSFKChkList.Create(application.MainForm);
          with frmGYSFKChkList do
          begin
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmGYSFKChkList.BringToFront;
       //句柄
        mnewHandle := frmGYSFKChkList.Handle;

      end;
    401:  //应付款对账单
      begin
        if frmYFMXlistMonDay = nil then
        begin
          frmYFMXlistMonDay := TfrmYFMXlistMonDay.Create(application.MainForm);
          with frmYFMXlistMonDay do
          begin
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmYFMXlistMonDay.BringToFront;
       //句柄
        mnewHandle := frmYFMXlistMonDay.Handle;

      end;
    6:  //收款登记  有保存按钮
      begin
        if frmKHSKList = nil then
        begin
          frmKHSKList := TfrmKHSKList.Create(application.MainForm);
          with frmKHSKList do
          begin
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmKHSKList.BringToFront;
       //句柄
        mnewHandle := frmKHSKList.Handle;

      end;
    601:  //收款审核
      begin
        if frmKHSKChkList = nil then
        begin
          frmKHSKChkList := TfrmKHSKChkList.Create(application.MainForm);
          with frmKHSKChkList do
          begin
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmKHSKChkList.BringToFront;
       //句柄
        mnewHandle := frmKHSKChkList.Handle;

      end;
    701:  //染费录入*
      begin
        bFound := FALSE;
        for i := (App.MainForm.MDIChildCount - 1) downto 0 do
        begin
          if App.MainForm.MDIChildren[i].Caption = '染费录入*' then
          begin
            BringWindowToTop(frmGYSRFListLR.Handle);
            bFound := TRUE;
            Break;
          end;
        end;
        if not bFound then
       //if frmBaoGuanListBGZL=nil then
        begin
          frmGYSRFListLR := TfrmGYSRFList.Create(application.MainForm);
          with frmGYSRFListLR do
          begin
            Title := '染费录入*';
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmGYSRFListLR.BringToFront;
       //句柄
        mnewHandle := frmGYSRFListLR.Handle;
      end;
    702:  //染费管理*
      begin
        bFound := FALSE;
        for i := (App.MainForm.MDIChildCount - 1) downto 0 do
        begin
          if App.MainForm.MDIChildren[i].Caption = '染费管理*' then
          begin
            BringWindowToTop(frmGYSRFListGL.Handle);
            bFound := TRUE;
            Break;
          end;
        end;
        if not bFound then
       //if frmBaoGuanListBGZL=nil then
        begin
          frmGYSRFListGL := TfrmGYSRFList.Create(application.MainForm);
          with frmGYSRFListGL do
          begin
            Title := '染费管理*';
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmGYSRFListGL.BringToFront;
       //句柄
        mnewHandle := frmGYSRFListGL.Handle;
      end;
    901:  //业务结算录入*
      begin
        bFound := FALSE;
        for i := (App.MainForm.MDIChildCount - 1) downto 0 do
        begin
          if App.MainForm.MDIChildren[i].Caption = '业务结算录入*' then
          begin
            BringWindowToTop(frmYWJSListLR.Handle);
            bFound := TRUE;
            Break;
          end;
        end;
        if not bFound then
       //if frmBaoGuanListBGZL=nil then
        begin
          frmYWJSListLR := TfrmYWJSList.Create(application.MainForm);
          with frmYWJSListLR do
          begin
            Title := '业务结算录入*';
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmYWJSListLR.BringToFront;
       //句柄
        mnewHandle := frmYWJSListLR.Handle;
      end;
    902:  //业务结算管理*
      begin
        bFound := FALSE;
        for i := (App.MainForm.MDIChildCount - 1) downto 0 do
        begin
          if App.MainForm.MDIChildren[i].Caption = '业务结算管理*' then
          begin
            BringWindowToTop(frmYWJSListGL.Handle);
            bFound := TRUE;
            Break;
          end;
        end;
        if not bFound then
       //if frmBaoGuanListBGZL=nil then
        begin
          frmYWJSListGL := TfrmYWJSList.Create(application.MainForm);
          with frmYWJSListGL do
          begin
            Title := '业务结算管理*';
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmYWJSListGL.BringToFront;
       //句柄
        mnewHandle := frmYWJSListGL.Handle;
      end;
     {402:  //应付款对账
     begin
       if frmYFFKListDZ=nil then
       begin
         frmYFFKListDZ:= TfrmYFFKListDZ.Create(application.MainForm);
         with frmYFFKListDZ do
         begin
           caption:=Trim(Title);
           FormStyle := mstyle ;
           windowState := mstate ;
           BorderStyle := mborderstyle;
           //show;
         end;
       end
       else
         frmYFFKListDZ.BringToFront;
       //句柄
       mNewHandle:=frmYFFKListDZ.Handle;

     end ;}
     {5:  //销售单价审核
     begin
       if frmXSPriceChk=nil then
       begin
         frmXSPriceChk:= TfrmXSPriceChk.Create(application.MainForm);
         with frmXSPriceChk do
         begin
           caption:=Trim(Title);
           FormStyle := mstyle ;
           windowState := mstate ;
           BorderStyle := mborderstyle;
           //show;
         end;
       end
       else
         frmXSPriceChk.BringToFront;
       //句柄
       mNewHandle:=frmXSPriceChk.Handle;

     end ;}
     {502:  //销售数量审核
     begin
       if frmXSQtyChk=nil then
       begin
         frmXSQtyChk:= TfrmXSQtyChk.Create(application.MainForm);
         with frmXSQtyChk do
         begin
           caption:=Trim(Title);
           FormStyle := mstyle ;
           windowState := mstate ;
           BorderStyle := mborderstyle;
           //show;
         end;
       end
       else
         frmXSQtyChk.BringToFront;
       //句柄
       mNewHandle:=frmXSQtyChk.Handle;

     end ; }
     {7:  //应收款收款统计
     begin
       if frmYSSKList=nil then
       begin
         frmYSSKList:= TfrmYSSKList.Create(application.MainForm);
         with frmYSSKList do
         begin
           caption:=Trim(Title);
           FormStyle := mstyle ;
           windowState := mstate ;
           BorderStyle := mborderstyle;
           //show;
         end;
       end
       else
         frmYSSKList.BringToFront;
       //句柄
       mNewHandle:=frmYSSKList.Handle;
     end ;}
     {602:  //应收款对账
     begin
       if frmYSSKListRMBMJDZEY=nil then
       begin
         frmYSSKListRMBMJDZEY:= TfrmYSSKListRMBMJDZEY.Create(application.MainForm);
         with frmYSSKListRMBMJDZEY do
         begin
           caption:=Trim(Title);
           FormStyle := mstyle ;
           windowState := mstate ;
           BorderStyle := mborderstyle;
           //show;
         end;
       end
       else
         frmYSSKListRMBMJDZEY.BringToFront;
       //句柄
       mNewHandle:=frmYSSKListRMBMJDZEY.Handle;
     end ;
     7:  //对账单查询
     begin
       if frmYSSKListRMBMJ=nil then
       begin
         frmYSSKListRMBMJ:= TfrmYSSKListRMBMJ.Create(application.MainForm);
         with frmYSSKListRMBMJ do
         begin
           caption:=Trim(Title);
           FormStyle := mstyle ;
           windowState := mstate ;
           BorderStyle := mborderstyle;
           //show;
         end;
       end
       else
         frmYSSKListRMBMJ.BringToFront;
       //句柄
       mNewHandle:=frmYSSKListRMBMJ.Handle;
     end ;}
     {8:  //应收款对账单
     begin
       if frmYSMXlistMonDay=nil then
       begin
         frmYSMXlistMonDay:= TfrmYSMXlistMonDay.Create(application.MainForm);
         with frmYSMXlistMonDay do
         begin
           caption:=Trim(Title);
           FormStyle := mstyle ;
           windowState := mstate ;
           BorderStyle := mborderstyle;
           //show;
         end;
       end
       else
         frmYSMXlistMonDay.BringToFront;
       //句柄
       mNewHandle:=frmYSMXlistMonDay.Handle;
     end ; }
    { 10:  //客户费用录入
     begin
       if frmBankMoneyKHList=nil then
       begin
         frmBankMoneyKHList:= TfrmBankMoneyKHList.Create(application.MainForm);
         with frmBankMoneyKHList do
         begin
           caption:=Trim(Title);
           FormStyle := mstyle ;
           windowState := mstate ;
           BorderStyle := mborderstyle;
           //show;
         end;
       end
       else
         frmBankMoneyKHList.BringToFront;
       //句柄
       mNewHandle:=frmBankMoneyKHList.Handle;
     end ; }
     {10:  //进项发票登记
     begin
       if frmYFFPSave=nil then
       begin
         frmYFFPSave:= TfrmYFFPSave.Create(application.MainForm);
         with frmYFFPSave do
         begin
           caption:=Trim(Title);
           FormStyle := mstyle ;
           windowState := mstate ;
           BorderStyle := mborderstyle;
           //show;
         end;
       end
       else
         frmYFFPSave.BringToFront;
       //句柄
       mNewHandle:=frmYFFPSave.Handle;

     end;
     11:  //销项发票登记
     begin
       if frmYSFPSave=nil then
       begin
         frmYSFPSave:= TfrmYSFPSave.Create(application.MainForm);
         with frmYSFPSave do
         begin
           caption:=Trim(Title);
           FormStyle := mstyle ;
           windowState := mstate ;
           BorderStyle := mborderstyle;
           //show;
         end;
       end
       else
         frmYSFPSave.BringToFront;
       //句柄
       mNewHandle:=frmYSFPSave.Handle;

     end;

     12:  //费用登记
     begin
       bFound := FALSE;
       for i := (App.MainForm.MDIChildCount - 1) downto 0 do
       begin
         if App.MainForm.MDIChildren[i].Caption = '费用登记' then
         begin
           BringWindowToTop(frmOtherFeeSaveLR.Handle);
           bFound := TRUE;
           Break;
         end;
       end;
       if not bFound then
       //if frmBaoGuanListBGZL=nil then
       begin
         frmOtherFeeSaveLR:= TfrmOtherFeeSave.Create(application.MainForm);
         with frmOtherFeeSaveLR do
         begin
           Title:='费用登记';
           caption:=Trim(Title);
           FormStyle := mstyle ;
           windowState := mstate ;
           BorderStyle := mborderstyle;
           //show;
         end;
       end
       else
         frmOtherFeeSaveLR.BringToFront;
       //句柄
       mNewHandle:=frmOtherFeeSaveLR.Handle;
     end ;
     13:  //费用查询
     begin
       bFound := FALSE;
       for i := (App.MainForm.MDIChildCount - 1) downto 0 do
       begin
         if App.MainForm.MDIChildren[i].Caption = '费用查询' then
         begin
           BringWindowToTop(frmOtherFeeSaveCX.Handle);
           bFound := TRUE;
           Break;
         end;
       end;
       if not bFound then
       //if frmBaoGuanListBGZL=nil then
       begin
         frmOtherFeeSaveCX:= TfrmOtherFeeSave.Create(application.MainForm);
         with frmOtherFeeSaveCX do
         begin
           Title:='费用查询';
           caption:=Trim(Title);
           FormStyle := mstyle ;
           windowState := mstate ;
           BorderStyle := mborderstyle;
           //show;
         end;
       end
       else
         frmOtherFeeSaveCX.BringToFront;
       //句柄
       mNewHandle:=frmOtherFeeSaveCX.Handle;
     end ; }
  end;  // end case

  Result := mnewHandle;

end;
//===========================================================
  //建立数据库连接池
//===========================================================

function ConnData(): Boolean;
begin
  if not Assigned(DataLink_Money) then
    DataLink_Money := TDataLink_Money.Create(Application);
  try
    with DataLink_Money.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_Money.Free;
  application := NewDllApp;
  dxUnitsLoader.Finalize;

end.

