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;          

function GetsysParam(muserId: pchar; fparam1: pchar): Boolean;

implementation

uses
  U_DataLink, U_iniParam, U_ProductOrderList, U_ProductOrderLBNameSet,
  U_DJBRKList, U_DJBCKList, U_DJBKKList, U_DJBKCList, U_MarkingInspection,
  U_JYOrderCDList, U_OrderProgress, U_JYOrderCDListGH, U_TableInspection,
  U_YCLView, U_JYOrderCDCPList, U_JYCYList, U_DJBKKListHD, U_BuDongKCList,U_KKKWCXList,
  U_ZDZGList, U_JYDayList, U_JYCXList,U_ProductSS,U_ProductSSGJB,U_ProductFYSS, U_BuDongBPKCList;

       /////////////////////////////////////////////////////////////////
      //         功能说明:取Dll中得窗体                              //
     //        参数说明：App>>调用应用程序；                        //
    //                 FormH>>调用窗口句柄 ；                      //
   //                 FormID>>窗口号;                             //
  //                 Language>>语言种类;                         //
 //                 WinStyle>>窗口类型；                        //
/////////////////////////////////////////////////////////////////
var
  frmProductOrderListLR, frmProductOrderListGL, frmProductOrderListCX, frmProductOrderListBZ: TfrmProductOrderList;
  frmProductSSGL, frmProductSSCX : TfrmProductSS;//缩水
  frmProductFYSSGL, frmProductFYSSCX : TfrmProductFYSS;//放样缩水
  frmProductOrderLBNameSetDQX, frmProductOrderLBNameSetGQX: TfrmProductOrderLBNameSet;
  frmDJBRKListLR, frmDJBRKListGL, frmDJBRKListCX: TfrmDJBRKList; //待检布入库
  frmDJBCKListLR, frmDJBCKListGL, frmDJBCKListCX: TfrmDJBCKList; //待检布出库
  frmDJBKCList: TfrmDJBKCList; //待检布库存
  frmDJBKKListLR, frmDJBKKListGL, frmDJBKKListCX, frmDJBKKListGQX: TfrmDJBKKList; //开卡
  frmJYOrderCDListDJG, frmJYOrderCDListCX, frmJYOrderCDListGL, frmJYOrderCDListCPGL, frmJYOrderCDListSHGL, frmJYOrderCDListHHGL, frmJYOrderCDListCFWSJ: TfrmJYOrderCDList;
  frmJYOrderCDListGH: TfrmJYOrderCDListGH; //检验信息汇总
  frmJYOrderCDListCPCX: TfrmJYOrderCDCPList; //检验次品整缸次品
  frmBuDongKCListLR, frmBuDongKCListCX: TfrmBuDongKCList; //不动库存
  frmBuDongBPKCListLR, frmBuDongBPKCListCX: TfrmBuDongBPKCList; //不动库存

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 := '139.196.189.214,7781';          
//  server := '.';
    dtbase := 'yongjindata';        //KHEWM
//  dtbase := 'yifudata';
    user := 'yifusa';
//  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:='高权限';

  end                                         
  else
  begin                                
    DConString := DataBaseStr;
  end;
  if not ConnData() then
  begin
    result := 0;
    exit;
  end;
  if IsINIFile() then
    ReadINIFile()
  else
    WriteINIFile;

  GetsysParam('', '');

   // 定义窗口类型 、状态
  if WinStyle = 0 then
  begin
    mstyle := fsMDIChild;
    mstate := wsMaximized;
    mborderstyle := bsSizeable;
  end
  else
  begin
    mstyle := fsNormal;
    mstate := wsNormal;
    mborderstyle := bsSizeable;
  end;
  /////////////////////
  //调用子模块窗口
  case FormID of
    921:  //订单进度
      begin
        if frmOrderProgress = nil then
        begin
          frmOrderProgress := TfrmOrderProgress.Create(application.MainForm);
          with frmOrderProgress do
          begin
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmOrderProgress.BringToFront;
       //句柄
        mnewHandle := frmOrderProgress.Handle;
      end;
    922:  //每日必查系统
      begin
        if frmJYDayList = nil then
        begin
          frmJYDayList := TfrmJYDayList.Create(application.MainForm);
          with frmJYDayList do
          begin
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmJYDayList.BringToFront;
       //句柄
        mnewHandle := frmJYDayList.Handle;
      end;
    999:  //品名管理
      begin
        if frmYCLView = nil then
        begin
          frmYCLView := TfrmYCLView.Create(application.MainForm);
          with frmYCLView do
          begin
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmYCLView.BringToFront;
       //句柄
        mnewHandle := frmYCLView.Handle;
      end;
    998:  //不动库存录入
      begin
        bFound := FALSE;
        for i := (App.MainForm.MDIChildCount - 1) downto 0 do
        begin
          if App.MainForm.MDIChildren[i].Caption = '不动库存录入' then
          begin
            BringWindowToTop(frmBuDongKCListLR.Handle);
            bFound := TRUE;
            Break;
          end;
        end;
        if not bFound then
        begin
          frmBuDongKCListLR := TfrmBuDongKCList.Create(application.MainForm);
          with frmBuDongKCListLR do
          begin
            canshu1 := '录入';
            Title := '不动库存录入';
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmBuDongKCListLR.BringToFront;
       //句柄
        mnewHandle := frmBuDongKCListLR.Handle;
      end;
    997:  //不动库存查询
      begin
        bFound := FALSE;
        for i := (App.MainForm.MDIChildCount - 1) downto 0 do
        begin
          if App.MainForm.MDIChildren[i].Caption = '不动库存查询' then
          begin
            BringWindowToTop(frmBuDongKCListCX.Handle);
            bFound := TRUE;
            Break;
          end;
        end;
        if not bFound then
        begin
          frmBuDongKCListCX := TfrmBuDongKCList.Create(application.MainForm);
          with frmBuDongKCListCX do
          begin
            canshu1 := '查询';
            Title := '不动库存查询';
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;                                                 
          end;
        end
        else
          frmBuDongKCListCX.BringToFront;
       //句柄
        mnewHandle := frmBuDongKCListCX.Handle;
      end;


    1001:  //不动白坯库存录入
      begin
        bFound := FALSE;
        for i := (App.MainForm.MDIChildCount - 1) downto 0 do
        begin
          if App.MainForm.MDIChildren[i].Caption = '不动白坯库存录入' then
          begin
            BringWindowToTop(frmBuDongBPKCListLR.Handle);
            bFound := TRUE;
            Break;
          end;
        end;
        if not bFound then
        begin
          frmBuDongBPKCListLR := TfrmBuDongBPKCList.Create(application.MainForm);
          with frmBuDongBPKCListLR do
          begin
            canshu1 := '录入';
            Title := '不动白坯库存录入';
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmBuDongBPKCListLR.BringToFront;
       //句柄
        mnewHandle := frmBuDongBPKCListLR.Handle;
      end;
    1002:  //不动白坯库存查询
      begin
        bFound := FALSE;
        for i := (App.MainForm.MDIChildCount - 1) downto 0 do
        begin
          if App.MainForm.MDIChildren[i].Caption = '不动白坯库存查询' then
          begin
            BringWindowToTop(frmBuDongBPKCListCX.Handle);
            bFound := TRUE;
            Break;
          end;
        end;
        if not bFound then
        begin
          frmBuDongBPKCListCX := TfrmBuDongBPKCList.Create(application.MainForm);
          with frmBuDongBPKCListCX do
          begin
            canshu1 := '查询';
            Title := '不动白坯库存查询';
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;                                                 
          end;
        end
        else
          frmBuDongBPKCListCX.BringToFront;
       //句柄
        mnewHandle := frmBuDongBPKCListCX.Handle;
      end;



    101:  //包装指示单录入
      begin
        bFound := FALSE;
        for i := (App.MainForm.MDIChildCount - 1) downto 0 do
        begin
          if App.MainForm.MDIChildren[i].Caption = '包装指示单录入' then
          begin
            BringWindowToTop(frmProductOrderListLR.Handle);
            bFound := TRUE;
            Break;
          end;
        end;
        if not bFound then
        begin
          frmProductOrderListLR := TfrmProductOrderList.Create(application.MainForm);
          with frmProductOrderListLR do
          begin
            canshu1 := '录入';
            Title := '包装指示单录入';
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmProductOrderListLR.BringToFront;
       //句柄
        mnewHandle := frmProductOrderListLR.Handle;
      end;
    102:  //包装指示单管理
      begin
        bFound := FALSE;
        for i := (App.MainForm.MDIChildCount - 1) downto 0 do
        begin
          if App.MainForm.MDIChildren[i].Caption = '包装指示单管理' then
          begin
            BringWindowToTop(frmProductOrderListGL.Handle);
            bFound := TRUE;
            Break;
          end;
        end;
        if not bFound then
        begin
          frmProductOrderListGL := TfrmProductOrderList.Create(application.MainForm);
          with frmProductOrderListGL do
          begin
            canshu1 := '高权限';
            Title := '包装指示单管理';
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmProductOrderListGL.BringToFront;
       //句柄
        mnewHandle := frmProductOrderListGL.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(frmProductOrderListCX.Handle);
            bFound := TRUE;
            Break;
          end;
        end;
        if not bFound then
        begin
          frmProductOrderListCX := TfrmProductOrderList.Create(application.MainForm);
          with frmProductOrderListCX do
          begin
            Title := '包装指示单查询';
            canshu1 := '查询';
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
          end;
        end
        else
          frmProductOrderListCX.BringToFront;
       //句柄
        mnewHandle := frmProductOrderListCX.Handle;
      end;
        2114:  //超级跟进表
      begin
        bFound := FALSE;
        for i := (App.MainForm.MDIChildCount - 1) downto 0 do
        begin
          if App.MainForm.MDIChildren[i].Caption = '跟进查询' then
          begin
            BringWindowToTop(frmProductSSGJB.Handle);
            bFound := TRUE;
            Break;
          end;
        end;
        if not bFound then
        begin
          frmProductSSGJB := TfrmProductSSGJB.Create(application.MainForm);
          with frmProductSSGJB do
          begin
            canshu1 := '管理';
            Title := '跟进查询';
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmProductSSGJB.BringToFront;
       //句柄
        mnewHandle := frmProductSSGJB.Handle;
      end;
         2111:  //缩水录入
      begin
        bFound := FALSE;
        for i := (App.MainForm.MDIChildCount - 1) downto 0 do
        begin
          if App.MainForm.MDIChildren[i].Caption = '缩水录入' then
          begin
            BringWindowToTop(frmProductSS.Handle);
            bFound := TRUE;
            Break;
          end;
        end;
        if not bFound then
        begin
          frmProductSS := TfrmProductSS.Create(application.MainForm);
          with frmProductSS do
          begin
            canshu1 := '录入';
            Title := '缩水录入';
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmProductSS.BringToFront;
       //句柄
        mnewHandle := frmProductSS.Handle;
      end;
        2112:  //缩水管理
      begin
        bFound := FALSE;
        for i := (App.MainForm.MDIChildCount - 1) downto 0 do
        begin
          if App.MainForm.MDIChildren[i].Caption = '缩水管理' then
          begin
            BringWindowToTop(frmProductSSGL.Handle);
            bFound := TRUE;
            Break;
          end;
        end;
        if not bFound then
        begin
          frmProductSSGL := TfrmProductSS.Create(application.MainForm);
          with frmProductSSGL do
          begin
            canshu1 := '高权限';
            Title := '缩水管理';
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmProductSSGL.BringToFront;
       //句柄
        mnewHandle := frmProductSSGL.Handle;
      end;
    2113:  //缩水查询
      begin
        bFound := FALSE;
        for i := (App.MainForm.MDIChildCount - 1) downto 0 do
        begin
          if App.MainForm.MDIChildren[i].Caption = '缩水查询' then
          begin
            BringWindowToTop(frmProductSSCX.Handle);
            bFound := TRUE;
            Break;
          end;
        end;
        if not bFound then
        begin
          frmProductSSCX := TfrmProductSS.Create(application.MainForm);
          with frmProductSSCX do
          begin
            Title := '缩水查询';            
            canshu1 := '查询';
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
          end;
        end
        else
          frmProductSSCX.BringToFront;
       //句柄
        mnewHandle := frmProductSSCX.Handle;
      end;
         2211:  //放样缩水录入
      begin
        bFound := FALSE;
        for i := (App.MainForm.MDIChildCount - 1) downto 0 do
        begin
          if App.MainForm.MDIChildren[i].Caption = '放样缩水录入' then
          begin
            BringWindowToTop(frmProductFYSS.Handle);
            bFound := TRUE;
            Break;
          end;
        end;
        if not bFound then
        begin
          frmProductFYSS := TFRMProductFYSS.Create(application.MainForm);
          with frmProductFYSS do
          begin
            canshu1 := '录入';
            Title := '放样缩水录入';
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmProductFYSS.BringToFront;
       //句柄
        mnewHandle := frmProductFYSS.Handle;
      end;
           2212:  //放样缩水管理
      begin
        bFound := FALSE;
        for i := (App.MainForm.MDIChildCount - 1) downto 0 do
        begin
          if App.MainForm.MDIChildren[i].Caption = '放样缩水管理' then
          begin
            BringWindowToTop(frmProductFYSSGL.Handle);
            bFound := TRUE;
            Break;
          end;
        end;
        if not bFound then
        begin
          frmProductFYSSGL := TFRMProductFYSS.Create(application.MainForm);
          with frmProductFYSSGL do
          begin
            canshu1 := '高权限';
            Title := '放样缩水管理';
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmProductFYSSGL.BringToFront;
       //句柄
        mnewHandle := frmProductFYSSGL.Handle;
      end;
    2213:  //放样缩水查询
      begin
        bFound := FALSE;
        for i := (App.MainForm.MDIChildCount - 1) downto 0 do
        begin
          if App.MainForm.MDIChildren[i].Caption = '放样缩水查询' then
          begin
            BringWindowToTop(frmProductFYSSCX.Handle);
            bFound := TRUE;
            Break;
          end;
        end;
        if not bFound then
        begin
          frmProductFYSSCX := TFRMProductFYSS.Create(application.MainForm);
          with frmProductFYSSCX do
          begin
            Title := '放样缩水查询';
            canshu1 := '查询';
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
          end;
        end
        else
          frmProductFYSSCX.BringToFront;
       //句柄
        mnewHandle := frmProductFYSSCX.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(frmProductOrderListBZ.Handle);
            bFound := TRUE;
            Break;
          end;
        end;
        if not bFound then
        begin
          frmProductOrderListBZ := TfrmProductOrderList.Create(application.MainForm);
          with frmProductOrderListBZ do
          begin
            Title := '特殊包装';
            canshu1 := '包装';
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
          end;
        end
        else
          frmProductOrderListBZ.BringToFront;
       //句柄
        mnewHandle := frmProductOrderListBZ.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(frmProductOrderLBNameSetDQX.Handle);
            bFound := TRUE;
            Break;
          end;
        end;
        if not bFound then
        begin
          frmProductOrderLBNameSetDQX := TfrmProductOrderLBNameSet.Create(application.MainForm);
          with frmProductOrderLBNameSetDQX do
          begin
            Title := '卷标签设置';
            canshu1 := '低权限';
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
          end;
        end
        else
          frmProductOrderLBNameSetDQX.BringToFront;
       //句柄
        mnewHandle := frmProductOrderLBNameSetDQX.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(frmProductOrderLBNameSetGQX.Handle);
            bFound := TRUE;
            Break;
          end;
        end;
        if not bFound then
        begin
          frmProductOrderLBNameSetGQX := TfrmProductOrderLBNameSet.Create(application.MainForm);
          with frmProductOrderLBNameSetGQX do
          begin
            Title := '卷标签设置(高权限)';
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmProductOrderLBNameSetGQX.BringToFront;
       //句柄
        mnewHandle := frmProductOrderLBNameSetGQX.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(frmDJBKKListLR.Handle);
            bFound := TRUE;
            Break;
          end;
        end;
        if not bFound then
        begin
          frmDJBKKListLR := TfrmDJBKKList.Create(application.MainForm);
          with frmDJBKKListLR do
          begin
            Title := '开卡录入';
            canshu1 := '录入';
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmDJBKKListLR.BringToFront;
       //句柄
        mnewHandle := frmDJBKKListLR.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(frmDJBKKListGL.Handle);
            bFound := TRUE;
            Break;
          end;
        end;
        if not bFound then
        begin
          frmDJBKKListGL := TfrmDJBKKList.Create(application.MainForm);
          with frmDJBKKListGL do
          begin
            Title := '开卡管理';
            canshu1 := '管理';
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmDJBKKListGL.BringToFront;
       //句柄
        mnewHandle := frmDJBKKListGL.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(frmDJBKKListCX.Handle);
            bFound := TRUE;
            Break;
          end;
        end;
        if not bFound then
        begin
          frmDJBKKListCX := TfrmDJBKKList.Create(application.MainForm);
          with frmDJBKKListCX do
          begin
            Title := '开卡查询';
            canshu1 := '查询';
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmDJBKKListCX.BringToFront;
       //句柄
        mnewHandle := frmDJBKKListCX.Handle;
      end;

    214:  //开卡管理(高权限)
      begin
        bFound := FALSE;
        for i := (App.MainForm.MDIChildCount - 1) downto 0 do
        begin
          if App.MainForm.MDIChildren[i].Caption = '开卡管理(高权限)' then
          begin
            BringWindowToTop(frmDJBKKListGQX.Handle);
            bFound := TRUE;
            Break;
          end;
        end;
        if not bFound then
        begin
          frmDJBKKListGQX := TfrmDJBKKList.Create(application.MainForm);
          with frmDJBKKListGQX do
          begin
            Title := '开卡管理(高权限)';
            canshu1 := '高权限';
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmDJBKKListGQX.BringToFront;
       //句柄
        mnewHandle := frmDJBKKListGQX.Handle;
      end;
        2141:  //开卡库位查询
      begin
        if frmKKKWCXList = nil then
        begin
          frmKKKWCXList := TfrmKKKWCXList.Create(application.MainForm);
          with frmKKKWCXList do
          begin
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmKKKWCXList.BringToFront;
       //句柄
        mnewHandle := frmKKKWCXList.Handle;
      end;
    215:  //开卡核对
      begin
        if frmDJBKKListHD = nil then
        begin
          frmDJBKKListHD := TfrmDJBKKListHD.Create(application.MainForm);
          with frmDJBKKListHD do
          begin
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmDJBKKListHD.BringToFront;
       //句柄
        mnewHandle := frmDJBKKListHD.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(frmDJBCKListLR.Handle);
            bFound := TRUE;
            Break;
          end;
        end;
        if not bFound then
        begin
          frmDJBCKListLR := TfrmDJBCKList.Create(application.MainForm);
          with frmDJBCKListLR do
          begin
            Title := '待检布出库';
            canshu1 := '管理';
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmDJBCKListLR.BringToFront;
       //句柄
        mnewHandle := frmDJBCKListLR.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(frmDJBCKListCX.Handle);
            bFound := TRUE;
            Break;
          end;
        end;
        if not bFound then
        begin
          frmDJBCKListCX := TfrmDJBCKList.Create(application.MainForm);
          with frmDJBCKListCX do
          begin
            Title := '待检布出库查询';
            canshu1 := '查询';
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmDJBCKListCX.BringToFront;
       //句柄
        mnewHandle := frmDJBCKListCX.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(frmDJBKCList.Handle);
            bFound := TRUE;
            Break;
          end;
        end;
        if not bFound then
        begin
          frmDJBKCList := TfrmDJBKCList.Create(application.MainForm);
          with frmDJBKCList do
          begin
            Title := '待检布库存';
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmDJBKCList.BringToFront;
       //句柄
        mnewHandle := frmDJBKCList.Handle;
      end;
    311:  //成品检验
      begin
        if frmMarkingInspection = nil then
        begin
          frmMarkingInspection := TfrmMarkingInspection.Create(application.MainForm);
          with frmMarkingInspection do
          begin
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmMarkingInspection.BringToFront;
       //句柄
        mnewHandle := frmMarkingInspection.Handle;
      end;

    312:  //翻布检验
      begin
        if frmTableInspection = nil then
        begin
          frmTableInspection := TfrmTableInspection.Create(application.MainForm);
          with frmTableInspection do
          begin
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmTableInspection.BringToFront;
       //句柄
        mnewHandle := frmTableInspection.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(frmJYOrderCDListGL.Handle);
            bFound := TRUE;
            Break;
          end;
        end;
        if not bFound then
        begin
          frmJYOrderCDListGL := TfrmJYOrderCDList.Create(application.MainForm);
          with frmJYOrderCDListGL do
          begin
            Title := '检验信息管理';
            canshu1 := '管理';
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmJYOrderCDListGL.BringToFront;
       //句柄
        mnewHandle := frmJYOrderCDListGL.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(frmJYOrderCDListDJG.Handle);
            bFound := TRUE;
            Break;
          end;
        end;
        if not bFound then
        begin
          frmJYOrderCDListDJG := TfrmJYOrderCDList.Create(application.MainForm);
          with frmJYOrderCDListDJG do
          begin
            Title := '打卷工检验信息';
            canshu1 := '打卷工';
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmJYOrderCDListDJG.BringToFront;
       //句柄
        mnewHandle := frmJYOrderCDListDJG.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(frmJYOrderCDListCX.Handle);
            bFound := TRUE;
            Break;
          end;
        end;
        if not bFound then
        begin
          frmJYOrderCDListCX := TfrmJYOrderCDList.Create(application.MainForm);
          with frmJYOrderCDListCX do
          begin
            Title := '检验信息查询';
            canshu1 := '查询';
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmJYOrderCDListCX.BringToFront;
       //句柄
        mnewHandle := frmJYOrderCDListCX.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(frmJYOrderCDListCPGL.Handle);
            bFound := TRUE;
            Break;
          end;
        end;
        if not bFound then
        begin
          frmJYOrderCDListCPGL := TfrmJYOrderCDList.Create(application.MainForm);
          with frmJYOrderCDListCPGL do
          begin
            Title := '次品管理';
            canshu1 := '次品管理';
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmJYOrderCDListCPGL.BringToFront;
       //句柄
        mnewHandle := frmJYOrderCDListCPGL.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(frmJYOrderCDListSHGL.Handle);
            bFound := TRUE;
            Break;
          end;
        end;
        if not bFound then
        begin
          frmJYOrderCDListSHGL := TfrmJYOrderCDList.Create(application.MainForm);
          with frmJYOrderCDListSHGL do
          begin
            Title := '死货管理';
            canshu1 := '死货管理';
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmJYOrderCDListSHGL.BringToFront;
       //句柄
        mnewHandle := frmJYOrderCDListSHGL.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(frmJYOrderCDListHHGL.Handle);
            bFound := TRUE;
            Break;
          end;
        end;
        if not bFound then
        begin
          frmJYOrderCDListHHGL := TfrmJYOrderCDList.Create(application.MainForm);
          with frmJYOrderCDListHHGL do
          begin
            Title := '活货管理';
            canshu1 := '活货管理';
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmJYOrderCDListHHGL.BringToFront;
       //句柄
        mnewHandle := frmJYOrderCDListHHGL.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(frmJYOrderCDListCPCX.Handle);
            bFound := TRUE;
            Break;
          end;
        end;
        if not bFound then
        begin
          frmJYOrderCDListCPCX := TfrmJYOrderCDCPList.Create(application.MainForm);
          with frmJYOrderCDListCPCX do
          begin
            Title := '次品查询';
            canshu1 := '次品查询';
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmJYOrderCDListCPCX.BringToFront;
       //句柄
        mnewHandle := frmJYOrderCDListCPCX.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(frmJYOrderCDListCFWSJ.Handle);
            bFound := TRUE;
            Break;
          end;
        end;
        if not bFound then
        begin
          frmJYOrderCDListCFWSJ := TfrmJYOrderCDList.Create(application.MainForm);
          with frmJYOrderCDListCFWSJ do
          begin
            Title := '成品超范围数据查询';
            canshu1 := '超范围';
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmJYOrderCDListCFWSJ.BringToFront;
       //句柄
        mnewHandle := frmJYOrderCDListCFWSJ.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(frmJYOrderCDListGH.Handle);
            bFound := TRUE;
            Break;
          end;
        end;
        if not bFound then
        begin
          frmJYOrderCDListGH := TfrmJYOrderCDListGH.Create(application.MainForm);
          with frmJYOrderCDListGH do
          begin
            Title := '检验信息汇总';
            canshu1 := '检验信息汇总';
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmJYOrderCDListGH.BringToFront;
       //句柄
        mnewHandle := frmJYOrderCDListGH.Handle;
      end;
    422:  //剪最重船样
      begin
        if frmJYCYList = nil then
        begin
          frmJYCYList := TfrmJYCYList.Create(application.MainForm);
          with frmJYCYList do
          begin
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmJYCYList.BringToFront;
       //句柄
        mnewHandle := frmJYCYList.Handle;
      end;
    423:  //转单转缸记录查询
      begin
        if frmZDZGList = nil then
        begin
          frmZDZGList := TfrmZDZGList.Create(application.MainForm);
          with frmZDZGList do
          begin
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmZDZGList.BringToFront;
       //句柄
        mnewHandle := frmZDZGList.Handle;
      end;
    425:  //打卷撤销
      begin
        if frmJYCXList = nil then
        begin
          frmJYCXList := TfrmJYCXList.Create(application.MainForm);
          with frmJYCXList do
          begin
            caption := Trim(Title);
            FormStyle := mstyle;
            windowState := mstate;
            BorderStyle := mborderstyle;
           //show;
          end;
        end
        else
          frmJYCXList.BringToFront;
       //句柄
        mnewHandle := frmJYCXList.Handle;
      end;
  end;

  Result := mnewHandle;
end;

function GetsysParam(muserId: pchar; fparam1: pchar): Boolean;
begin
  result := true;
  //////////////////////////////
  shortDateFormat := 'yyyy-MM-dd';
  //服务器日期
  with DataLink_DyeingFinishingPlan.AdoDataLink do
  begin
    close;
    sql.Clear;
    sql.Add('select getDate()as dt');
    open;
    DServerDate := fieldByName('dt').AsDatetime;
  end;
  result := true;
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');
    UserDataFlag := IniFile.ReadString('SERVER', '服务器地址类型', '-1');
  finally
    IniFile.Free;
  end;

  if not Assigned(DataLink_DyeingFinishingPlan) then
    DataLink_DyeingFinishingPlan := TDataLink_DyeingFinishingPlan.Create(Application);
  try
    with DataLink_DyeingFinishingPlan.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_DyeingFinishingPlan.Free;
  application := NewDllApp;
  dxUnitsLoader.Finalize;

end.

