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_Fun, U_YFCR, U_FKCR, U_YFFKList, U_YSCR, U_SKCR, U_YSSKList,
  U_YSCRJZC, U_YSCR_Gd, U_SKCR_Gd, U_YFZDList_MX, U_YSZDList_MX, U_YFMXlist,
  U_YSMXlist, U_YFCRMXList, U_FDINVOICE, U_FPINVOICE_TJ, U_FDINVOICE_X,
  U_FDINVOICE_XMX, U_FDINVOICE_S, U_YF_Money_LL, U_YF_Money_LL_list,
  U_XXFPINVOICE_TJ, U_CostCR, U_YSCRMXList, U_OtherFeeSave, U_YSMXHZlist,
  U_YfMXHZlist;

       /////////////////////////////////////////////////////////////////
      //         功能说明:取Dll中得窗体                              //
     //        参数说明：App>>调用应用程序；                        //
    //                 FormH>>调用窗口句柄 ；                      //
   //                 FormID>>窗口号;                             //
  //                 Language>>语言种类;                         //
 //                 WinStyle>>窗口类型；                        //
/////////////////////////////////////////////////////////////////
var
  frmOtherFeeSaveLR: TfrmOtherFeeSave;
  frmYSCRGL, frmYSCRl: TfrmYSCR;
  frmYSCRMXListGL, frmYSCRMXListL: tfrmYSCRMXList;
  frmSKCRL, frmSKCRGL: TfrmSKCR;
  frmYFCRGL, frmYFCRl: TfrmYfCR;
  frmFKCRl, frmFKCRGl: TfrmFKCR;
  frmYFMXlistGL, frmYFMXlistcx: TfrmYFMXlist;
  frmYFFKList, frmYFFKListYW: TfrmYFFKList;
  frmYfMXlHZistYW, frmYfMXlHZist: TfrmYfMXlHZist;
  frmYSSKList, frmYSSKListYW: TfrmYSSKList;
  frmYSMXlist, frmYSMXlistYW: TfrmYSMXlist;
  frmYSMXlHZistYW, frmYSMXlHZist: tfrmYSMXlHZist;

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);
  if trim(DataBaseStr) = '' then
  begin
    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;


//  DName := '蔡丽雯';
//  DParameters1 := '管理';
//  DParameters2 := '';
//  DParameters2 := '绍兴御函纺织品有限公司';
  end
  else
  begin
    DConString := DataBaseStr;
  end;

  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;

  //调用子模块窗口
  case FormID of
    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;

    110:  //应付款登记
      begin
        bFound := FALSE;
        for i := (App.MainForm.MDIChildCount - 1) downto 0 do
        begin
          if App.MainForm.MDIChildren[i].Caption = '应付款登记' then
          begin
            BringWindowToTop(frmYFCRL.Handle);
            bFound := TRUE;
            Break;
          end;
        end;
        if not bFound then
        begin
          frmYFCRL := TfrmYFCR.Create(application.MainForm);
          with frmYFCRL do
          begin
            Title := '应付款登记';
            canshu1 := '低权限';
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmYFCRL.BringToFront;
       //句柄
        mnewHandle := frmYFCRL.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(frmYFCRGL.Handle);
            bFound := TRUE;
            Break;
          end;
        end;
        if not bFound then
        begin
          frmYFCRGL := TfrmYFCR.Create(application.MainForm);
          with frmYFCRGL do
          begin
            Title := '应付款管理';
            canshu1 := '管理';
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmYFCRGL.BringToFront;
       //句柄
        mnewHandle := frmYFCRGL.Handle;
      end;
    112:  //应付款明细查询
      begin
        if frmYFCRMXList = nil then
        begin
          frmYFCRMXList := TfrmYFCRMXList.Create(application.MainForm);
          with frmYFCRMXList do
          begin
            fmanage := trim(Parameters1);
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmYFCRMXList.BringToFront;
       //句柄
        mnewHandle := frmYFCRMXList.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(frmFKCRl.Handle);
            bFound := TRUE;
            Break;
          end;
        end;
        if not bFound then
        begin
          frmFKCRl := TfrmFKCR.Create(application.MainForm);
          with frmFKCRl do
          begin
            Title := '付款登记';
            canshu1 := '低权限';
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmFKCRl.BringToFront;
       //句柄
        mnewHandle := frmFKCRl.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(frmFKCRgl.Handle);
            bFound := TRUE;
            Break;
          end;
        end;
        if not bFound then
        begin
          frmFKCRgl := TfrmFKCR.Create(application.MainForm);
          with frmFKCRgl do
          begin
            Title := '付款管理';
            canshu1 := '管理';
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmFKCRgl.BringToFront;
       //句柄
        mnewHandle := frmFKCRgl.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(frmYFFKList.Handle);
            bFound := TRUE;
            Break;
          end;
        end;
        if not bFound then
        begin
          frmYFFKList := tfrmYFFKList.Create(application.MainForm);
          with frmYFFKList do
          begin
            Title := '应付已付汇总';
            canshu1 := '管理';
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmYFFKList.BringToFront;
       //句柄
        mnewHandle := frmYFFKList.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(frmYFFKListyw.Handle);
            bFound := TRUE;
            Break;
          end;
        end;
        if not bFound then
        begin
          frmYFFKListyw := tfrmYFFKList.Create(application.MainForm);
          with frmYFFKListyw do
          begin
            Title := '应付已付汇总(业务)';
            canshu1 := '业务';
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmYFFKListyw.BringToFront;
       //句柄
        mnewHandle := frmYFFKListyw.Handle;
      end;


//    131:  //应付款付款统计
//      begin
//        if frmYFFKList = nil then
//        begin
//          frmYFFKList := TfrmYFFKList.Create(application.MainForm);
//          with frmYFFKList do
//          begin
//            caption := Trim(Title);
//            fDParameters1 := trim(DParameters1);
//            FormStyle := mstyle;
//            windowState := mstate;
//            BorderStyle := mborderstyle;
//           //show;
//          end;
//        end
//        else
//          frmYFFKList.BringToFront;
//       //句柄
//        mnewHandle := frmYFFKList.Handle;
//      end;

    141:  //应付对账单
      begin
        bFound := FALSE;
        for i := (App.MainForm.MDIChildCount - 1) downto 0 do
        begin
          if App.MainForm.MDIChildren[i].Caption = '应付款对账单' then
          begin
            BringWindowToTop(frmYFMXlistGL.Handle);
            bFound := TRUE;
            Break;
          end;
        end;
        if not bFound then
        begin
          frmYFMXlistGL := TfrmYFMXlist.Create(application.MainForm);
          with frmYFMXlistGL do
          begin
            Title := '应付款对账单';
            canshu1 := '管理';
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmYFMXlistGL.BringToFront;
       //句柄
        mnewHandle := frmYFMXlistGL.Handle;
      end;
    1411:  //应付对账单(低)
      begin
        bFound := FALSE;
        for i := (App.MainForm.MDIChildCount - 1) downto 0 do
        begin
          if App.MainForm.MDIChildren[i].Caption = '应付款对账单(低)' then
          begin
            BringWindowToTop(frmYFMXlistCX.Handle);
            bFound := TRUE;
            Break;
          end;
        end;
        if not bFound then
        begin
          frmYFMXlistCX := TfrmYFMXlist.Create(application.MainForm);
          with frmYFMXlistCX do
          begin
            Title := '应付款对账单(低)';
            canshu1 := '查询';
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmYFMXlistCX.BringToFront;
       //句柄
        mnewHandle := frmYFMXlistCX.Handle;
      end;

    142:  //应付对账单
      begin
        bFound := FALSE;
        for i := (App.MainForm.MDIChildCount - 1) downto 0 do
        begin
          if App.MainForm.MDIChildren[i].Caption = '应收款对账汇总查询' then
          begin
            BringWindowToTop(frmYfMXlHZist.Handle);
            bFound := TRUE;
            Break;
          end;
        end;
        if not bFound then
        begin
          frmYfMXlHZist := TfrmYfMXlHZist.Create(application.MainForm);
          with frmYfMXlHZist do
          begin
            Title := '应收款对账汇总查询';
            canshu1 := '管理';
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmYfMXlHZist.BringToFront;
       //句柄
        mnewHandle := frmYfMXlHZist.Handle;
      end;
    1421:  //应收款对账汇总查询(业务)
      begin
        bFound := FALSE;
        for i := (App.MainForm.MDIChildCount - 1) downto 0 do
        begin
          if App.MainForm.MDIChildren[i].Caption = '应收款对账汇总查询(业务)' then
          begin
            BringWindowToTop(frmYfMXlHZistYW.Handle);
            bFound := TRUE;
            Break;
          end;
        end;
        if not bFound then
        begin
          frmYfMXlHZistYW := TfrmYfMXlHZist.Create(application.MainForm);
          with frmYfMXlHZistYW do
          begin
            Title := '应收款对账汇总查询(业务)';
            canshu1 := '业务';
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmYfMXlHZistYW.BringToFront;
       //句柄
        mnewHandle := frmYfMXlHZistYW.Handle;
      end;

    210:  //应收款登记
      begin
        bFound := FALSE;
        for i := (App.MainForm.MDIChildCount - 1) downto 0 do
        begin
          if App.MainForm.MDIChildren[i].Caption = '应收款登记' then
          begin
            BringWindowToTop(frmYSCRL.Handle);
            bFound := TRUE;
            Break;
          end;
        end;
        if not bFound then
        begin
          frmYSCRL := TfrmYSCR.Create(application.MainForm);
          with frmYSCRL do
          begin
            Title := '应收款登记';
            canshu1 := '低权限';
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmYSCRL.BringToFront;
       //句柄
        mnewHandle := frmYSCRL.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(frmYSCRGL.Handle);
            bFound := TRUE;
            Break;
          end;
        end;
        if not bFound then
        begin
          frmYSCRGL := TfrmYSCR.Create(application.MainForm);
          with frmYSCRGL do
          begin
            Title := '应收款管理';
            canshu1 := '管理';

            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmYSCRGL.BringToFront;
       //句柄
        mnewHandle := frmYSCRGL.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(frmYSCRMXListGL.Handle);
            bFound := TRUE;
            Break;
          end;
        end;
        if not bFound then
        begin
          frmYSCRMXListGL := TfrmYSCRMXList.Create(application.MainForm);
          with frmYSCRMXListGL do
          begin
            Title := '应收款明细查询';
            canshu1 := '管理';

            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmYSCRMXListGL.BringToFront;
       //句柄
        mnewHandle := frmYSCRMXListGL.Handle;
      end;
    213:  //应收款明细查询（低权限）
      begin
        bFound := FALSE;
        for i := (App.MainForm.MDIChildCount - 1) downto 0 do
        begin
          if App.MainForm.MDIChildren[i].Caption = '应收款明细查询(低权限)' then
          begin
            BringWindowToTop(frmYSCRMXListL.Handle);
            bFound := TRUE;
            Break;
          end;
        end;
        if not bFound then
        begin
          frmYSCRMXListL := TfrmYSCRMXList.Create(application.MainForm);
          with frmYSCRMXListL do
          begin
            Title := '应收款明细查询(低权限)';
            canshu1 := '低权限';
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmYSCRMXListL.BringToFront;
       //句柄
        mnewHandle := frmYSCRMXListL.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(frmSKCRGL.Handle);
            bFound := TRUE;
            Break;
          end;
        end;
        if not bFound then
        begin
          frmSKCRGL := TfrmSKCR.Create(application.MainForm);
          with frmSKCRGL do
          begin
            Title := '收款管理';
            canshu1 := '管理';
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmSKCRGL.BringToFront;
       //句柄
        mnewHandle := frmSKCRGL.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(frmSKCRL.Handle);
            bFound := TRUE;
            Break;
          end;
        end;
        if not bFound then
        begin
          frmSKCRL := TfrmSKCR.Create(application.MainForm);
          with frmSKCRL do
          begin
            Title := '收款登记';
            canshu1 := '低权限';
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmSKCRL.BringToFront;
       //句柄
        mnewHandle := frmSKCRL.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(frmYSSKList.Handle);
            bFound := TRUE;
            Break;
          end;
        end;
        if not bFound then
        begin
          frmYSSKList := TfrmYSSKList.Create(application.MainForm);
          with frmYSSKList do
          begin
            Title := '应收已收汇总';
            canshu1 := '管理';
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmYSSKList.BringToFront;
       //句柄
        mnewHandle := frmYSSKList.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(frmYSSKListyw.Handle);
            bFound := TRUE;
            Break;
          end;
        end;
        if not bFound then
        begin
          frmYSSKListyw := TfrmYSSKList.Create(application.MainForm);
          with frmYSSKListyw do
          begin
            Title := '应收已收汇总(业务)';
            canshu1 := '业务';
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmYSSKListyw.BringToFront;
       //句柄
        mnewHandle := frmYSSKListyw.Handle;
      end;

     //////////////////////
          ///////////////////////

    241:  //应收对账单
      begin
        bFound := FALSE;
        for i := (App.MainForm.MDIChildCount - 1) downto 0 do
        begin
          if App.MainForm.MDIChildren[i].Caption = '应收款对账单' then
          begin
            BringWindowToTop(frmYSMXlist.Handle);
            bFound := TRUE;
            Break;
          end;
        end;
        if not bFound then
        begin
          frmYSMXlist := tfrmYSMXlist.Create(application.MainForm);
          with frmYSMXlist do
          begin
            Title := '应收款对账单';
            canshu1 := '管理';
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmYSMXlist.BringToFront;
       //句柄
        mnewHandle := frmYSMXlist.Handle;
      end;
    2411:  //应收对账单(业务)
      begin
        bFound := FALSE;
        for i := (App.MainForm.MDIChildCount - 1) downto 0 do
        begin
          if App.MainForm.MDIChildren[i].Caption = '应收款对账单(业务)' then
          begin
            BringWindowToTop(frmYSMXlistyw.Handle);
            bFound := TRUE;
            Break;
          end;
        end;
        if not bFound then
        begin
          frmYSMXlistyw := TfrmYSMXlist.Create(application.MainForm);
          with frmYSMXlistyw do
          begin
            Title := '应收款对账单(业务)';
            canshu1 := '业务';
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmYSMXlistyw.BringToFront;
       //句柄
        mnewHandle := frmYSMXlistyw.Handle;
      end;

     //////////////////////


    242:  //应收对账单
      begin
        bFound := FALSE;
        for i := (App.MainForm.MDIChildCount - 1) downto 0 do
        begin
          if App.MainForm.MDIChildren[i].Caption = '应收对账单' then
          begin
            BringWindowToTop(frmYSMXlHZist.Handle);
            bFound := TRUE;
            Break;
          end;
        end;
        if not bFound then
        begin
          frmYSMXlHZist := TfrmYSMXlHZist.Create(application.MainForm);
          with frmYSMXlHZist do
          begin
            Title := '应收对账单';
            canshu1 := '管理';
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmYSMXlHZist.BringToFront;
       //句柄
        mnewHandle := frmYSMXlHZist.Handle;
      end;
    2421:  //应收对账单(业务)
      begin
        bFound := FALSE;
        for i := (App.MainForm.MDIChildCount - 1) downto 0 do
        begin
          if App.MainForm.MDIChildren[i].Caption = '应收对账单(业务)' then
          begin
            BringWindowToTop(frmYSMXlHZistYW.Handle);
            bFound := TRUE;
            Break;
          end;
        end;
        if not bFound then
        begin
          frmYSMXlHZistYW := TfrmYSMXlHZist.Create(application.MainForm);
          with frmYSMXlHZistYW do
          begin
            Title := '应收对账单(业务)';
            canshu1 := '业务';
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmYSMXlHZistYW.BringToFront;
       //句柄
        mnewHandle := frmYSMXlHZistYW.Handle;
      end;

    311:  //进项发票管理
      begin           //应付
        if frmFDINVOICE = nil then
        begin
          frmFDINVOICE := TfrmFDINVOICE.Create(application.MainForm);
          with frmFDINVOICE do
          begin
            fInvoiceFlag := '0';
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmFDINVOICE.BringToFront;
       //句柄
        mnewHandle := frmFDINVOICE.Handle;
      end;

    321:  //进项发票统计查询
      begin
        if frmFPInvoice_TJ = nil then
        begin
          frmFPInvoice_TJ := TfrmFPInvoice_TJ.Create(application.MainForm);
          with frmFPInvoice_TJ do
          begin
            fInvoiceFlag := '0';
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmFPInvoice_TJ.BringToFront;
       //句柄
        mnewHandle := frmFPInvoice_TJ.Handle;
      end;
    411:  //销项发票
      begin
        if frmFDINVOICE_X = nil then
        begin
          frmFDINVOICE_X := TfrmFDINVOICE_X.Create(application.MainForm);
          with frmFDINVOICE_X do
          begin
            fInvoiceFlag := '1';

            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle; 
           //show;
          end;
        end
        else
          frmFDINVOICE_X.BringToFront;
       //句柄
        mnewHandle := frmFDINVOICE_X.Handle;
      end;
    412:  //销项发票明细
      begin
        if frmFDINVOICE_XMX = nil then
        begin
          frmFDINVOICE_XMX := TfrmFDINVOICE_XMX.Create(application.MainForm);
          with frmFDINVOICE_XMX do
          begin
            fInvoiceFlag := '1';

            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle; 
           //show;
          end;
        end
        else
          frmFDINVOICE_XMX.BringToFront;
       //句柄
        mnewHandle := frmFDINVOICE_XMX.Handle;
      end;
    421:  //销项发票统计查询
      begin
        if frmXXFPInvoice_TJ = nil then
        begin
          frmXXFPInvoice_TJ := TfrmXXFPInvoice_TJ.Create(application.MainForm);
          with frmXXFPInvoice_TJ do
          begin
            fInvoiceFlag := '1';
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmXXFPInvoice_TJ.BringToFront;
       //句柄
        mnewHandle := frmXXFPInvoice_TJ.Handle;
      end;

    511:  //费用登记
      begin
        if frmCostCR = nil then
        begin
          frmCostCR := TfrmCostCR.Create(application.MainForm);
          with frmCostCR do
          begin
            caption := Trim(Title);
            fflag := strtointdef(trim(DataBase), 0);
            fmanage := trim(Parameters1);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmCostCR.BringToFront;
       //句柄
        mnewHandle := frmCostCR.Handle;

      end;
  end;  // end case

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

function ConnData(): Boolean;
var
  IniFile: TIniFile;
begin
  try
    IniFile := TIniFile.Create(ExtractFilePath(Application.ExeName) + 'SYSTEMSET.INI');
    PicSvr := IniFile.ReadString('SERVER', '服务器地址', '127.0.0.1');
  finally
    IniFile.Free;
  end;
  if not Assigned(DataLink_YSYF) then
    DataLink_YSYF := TDataLink_YSYF.Create(Application);
  try
    with DataLink_YSYF.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_YSYF.Free;
//  Application := OldDllApp;

initialization
  CoInitialize(nil);
  dxUnitsLoader.Initialize;


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

end.

