Advertisement
filhotecmail

ArrayDml

Mar 27th, 2018
334
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 6.45 KB | None | 0 0
  1. procedure TAplicacargaUsuarios.AplicacargaUsuarios(Gauge: TGauge);
  2. var DatasetServer,DatasetLocal: TFDQuery;
  3.      sComandoSql: string; iNumInserts: Integer; wait: TFDGUIxWaitCursor; FWaitCounter: Integer; dlg:TFDGUIxAsyncExecuteDialog;
  4. begin
  5.  
  6.    wait := TFDGUIxWaitCursor.Create(nil);
  7.    wait.ScreenCursor:= gcrAppWait;
  8.    dlg:= TFDGUIxAsyncExecuteDialog.Create(nil);
  9.  
  10.  DatasetServer:= TFDQuery.Create(nil);
  11.  DatasetServer.Connection := TDtmConexao.FDServidorConexao;
  12.  DatasetServer.SQL.Text   :=   'select ID, DATA, HORA, USUARIO, SYST_NOME, SYST_NOMEUSER, PDV_PODEACESSAR, SYST_SITUACAO, PDV_USERPDVTIPO, '+
  13.   'PDV_PODEEMIRZ, PDV_PODEABRIRCAIXA, PDV_PODEEMITLX, PDV_PODETROCO, PDV_PODESANGRIA, PDV_PODEFECHARSIST, '+
  14.    'PDV_PODEFECHARCAIXA, PDV_PODEOPERAR, PDV_CODACESSO, MOD_ACESSOSISTGER, MOD_ACESSOCADPROD, MOD_ACESSOCADCLI, '+
  15.     'MOD_ACESSOCADFORNE, FOTO, PASSWORD_CEANCOD, PASSWORD_SENHA, PDV_PODEDESCONTO, PDV_DESCPERCENT, PDV_PODEESTORNAR, '+
  16.      'PODEABRIRGAVETA, PODE_ABRFECHARCAIXA, PODE_PESQUISARVENDASPDV, PODE_CANCELARVENDA, PODE_CANCELARITENVENDA '+
  17.       ',( select Count(id) from usersys WHERE SYST_SITUACAO =  ''ATIVO'' ) as RecordCount '+
  18.        'from USERSYS where SYST_SITUACAO =  ''ATIVO'' order by ID asc ';
  19.  DatasetServer.Open;
  20.  DatasetServer.FieldByName('ID').Required:= False;
  21.  iNumInserts := DatasetServer.FieldByName('REcordCount').AsInteger;
  22.  Gauge.MaxValue := iNumInserts;
  23.  Gauge.Visible := True;
  24.  
  25.  DatasetLocal:= TFDquery.Create(nil);
  26.  DatasetLocal.Connection := TDtmConexao.FDMasterPdv;
  27.  DatasetLocal.SQL.Text := 'Delete from USUARIOS';
  28.  DatasetLocal.ExecSQL;
  29.  DatasetLocal.SQL.Clear;
  30.  DatasetLocal.SQL.Text :=
  31.    'update or insert into USUARIOS (IDUSUARIO, USER_SITUACAO, USERPDV_TIPO, USERPDV_PODEEMIRZ, USERPDV_PODEABRIRCAIXA, '+
  32.     'USERPDV_PODEEMITLX, USERPDV_PODETROCO, USERPDV_PODESANGRIA, USERPDV_PODEFECHARSIST, '+
  33.      'USERPDV_PODEFECHARCAIXA, USERPDV_PODEOPERAR, USERPDV_CODACESSO, USERPDV_NOME, '+
  34.       'USERPDV_NOMEUSER, PASSWORD_SENHA, PDV_PODEDESCONTO, PDV_DESCPERCENT, PDV_PODEESTORNAR, '+
  35.        'PODEABRIRGAVETA, PODE_ABRFECHARCAIXA, PODE_PESQUISARVENDASPDV, PODE_CANCELARVENDA, '+
  36.         'PODE_CANCELARITENVENDA) '+
  37.          'values (:IDUSUARIO, :USER_SITUACAO, :USERPDV_TIPO, :USERPDV_PODEEMIRZ, :USERPDV_PODEABRIRCAIXA, :USERPDV_PODEEMITLX, '+
  38.           ':USERPDV_PODETROCO, :USERPDV_PODESANGRIA, :USERPDV_PODEFECHARSIST, :USERPDV_PODEFECHARCAIXA, '+
  39.            ':USERPDV_PODEOPERAR, :USERPDV_CODACESSO, :USERPDV_NOME, :USERPDV_NOMEUSER, :PASSWORD_SENHA, :PDV_PODEDESCONTO, '+
  40.             ':PDV_DESCPERCENT, :PDV_PODEESTORNAR, :PODEABRIRGAVETA, :PODE_ABRFECHARCAIXA, :PODE_PESQUISARVENDASPDV, '+
  41.              ':PODE_CANCELARVENDA, :PODE_CANCELARITENVENDA) '+
  42.               'matching (IDUSUARIO) ';
  43.  
  44.  Datasetserver.DisableControls;
  45.  DatasetServer.First;
  46.  DatasetLocal.Params.ArraySize := iNumInserts;
  47.  SistemaClass.RichVenda.Lines.Add(stringofchar('.',80));
  48.  SistemaClass.RichVenda.Lines.Add('Iniciando carga de usuarios do sistema');
  49.    while not Datasetserver.Eof do
  50.    begin
  51.     DatasetLocal.Params[0].AsIntegers[Datasetserver.RecNo-1] := Datasetserver.FieldByName('ID').AsInteger;
  52.     DatasetLocal.Params[1].AsStrings[Datasetserver.RecNo-1] :=  Datasetserver.FieldByName('SYST_SITUACAO').AsString;
  53.     DatasetLocal.Params[2].AsStrings[Datasetserver.RecNo-1] :=  Datasetserver.FieldByName('PDV_USERPDVTIPO').AsString;
  54.     DatasetLocal.Params[3].AsStrings[Datasetserver.RecNo-1] :=  Datasetserver.FieldByName('PDV_PODEEMIRZ').AsString;
  55.     DatasetLocal.Params[4].AsStrings[Datasetserver.RecNo-1] :=  Datasetserver.FieldByName('PDV_PODEABRIRCAIXA').AsString;
  56.     DatasetLocal.Params[5].AsStrings[Datasetserver.RecNo-1] :=  Datasetserver.FieldByName('PDV_PODEEMITLX').AsString;
  57.     DatasetLocal.Params[6].AsStrings[Datasetserver.RecNo-1] :=  Datasetserver.FieldByName('PDV_PODETROCO').AsString;
  58.     DatasetLocal.Params[7].AsIntegers[Datasetserver.RecNo-1] :=  Datasetserver.FieldByName('PDV_PODESANGRIA').AsString.ToInteger;
  59.     DatasetLocal.Params[8].AsStrings[Datasetserver.RecNo-1] :=  Datasetserver.FieldByName('PDV_PODEFECHARSIST').AsString;
  60.     DatasetLocal.Params[9].AsStrings[Datasetserver.RecNo-1] :=  Datasetserver.FieldByName('PDV_PODEFECHARCAIXA').AsString;
  61.     DatasetLocal.Params[10].AsStrings[Datasetserver.RecNo-1] :=  Datasetserver.FieldByName('PDV_PODEOPERAR').AsString;
  62.     DatasetLocal.Params[11].AsStrings[Datasetserver.RecNo-1] :=  Datasetserver.FieldByName('PDV_CODACESSO').AsString;
  63.     DatasetLocal.Params[12].AsStrings[Datasetserver.RecNo-1] :=  Datasetserver.FieldByName('SYST_NOME').AsString;
  64.     DatasetLocal.Params[13].AsStrings[Datasetserver.RecNo-1] :=  Datasetserver.FieldByName('SYST_NOMEUSER').AsString;
  65.     DatasetLocal.Params[14].AsStrings[Datasetserver.RecNo-1] :=  Datasetserver.FieldByName('PASSWORD_SENHA').AsString;
  66.     DatasetLocal.Params[15].AsIntegers[Datasetserver.RecNo-1] :=  Datasetserver.FieldByName('PDV_PODEDESCONTO').AsInteger;
  67.     DatasetLocal.Params[16].AsCurrencys[Datasetserver.RecNo-1] :=  Datasetserver.FieldByName('PDV_DESCPERCENT').AsCurrency;
  68.     DatasetLocal.Params[17].AsIntegers[Datasetserver.RecNo-1] :=  Datasetserver.FieldByName('pdv_podeestornar').AsInteger;
  69.     DatasetLocal.Params[18].AsIntegers[Datasetserver.RecNo-1] :=  Datasetserver.FieldByName('podeabrirgaveta').AsInteger;
  70.     DatasetLocal.Params[19].AsIntegers[Datasetserver.RecNo-1] :=  Datasetserver.FieldByName('pode_abrfecharcaixa').AsInteger;
  71.     DatasetLocal.Params[20].AsIntegers[Datasetserver.RecNo-1] :=  Datasetserver.FieldByName('pode_pesquisarvendaspdv').AsInteger;
  72.     DatasetLocal.Params[21].AsIntegers[Datasetserver.RecNo-1] :=  Datasetserver.FieldByName('pode_cancelarvenda').AsInteger;
  73.     DatasetLocal.Params[22].AsIntegers[Datasetserver.RecNo-1] :=  Datasetserver.FieldByName('pode_cancelaritenvenda').AsInteger;
  74.     Gauge.Progress := Datasetserver.RecNo;
  75.  
  76.     SistemaClass.RichVenda.Lines.Add( '... ' +Datasetserver.FieldByName('SYST_NOMEUSER').asstring);
  77.     Datasetserver.Next;
  78.    end;
  79.     Gauge.Progress := 0;
  80.     Gauge.Visible:= False;
  81.  
  82.     DatasetLocal.ResourceOptions.CmdExecMode := amCancelDialog;
  83.     dlg.Provider := 'Forms';
  84.     dlg.Caption := 'Leopard Report PDV- Frente de caixa';
  85.     dlg.Prompt  := 'Carga de tabelas...aguarde';
  86.  
  87.  
  88.    if iNumInserts > 0 then
  89.    begin
  90.     try
  91.       DatasetLocal.Execute(iNumInserts, 0);
  92.     finally
  93.       DatasetLocal.DisposeOf;
  94.       Datasetserver.DisposeOf;
  95.     end;
  96.     end;
  97.      dlg.DisposeOf;
  98.      wait.DisposeOf;
  99.  
  100. end;
  101.  
  102. { TAplicacargaVendedores }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement