Ver Mensaje Individual
  #4  
Antiguo 05-08-2014
Chaja Chaja is offline
No confirmado
 
Registrado: ago 2004
Ubicación: Mar del Plata
Posts: 238
Reputación: 0
Chaja Va por buen camino
Estimado Neftali.

El Procedimiento Principal es

Código Delphi [-]

procedure TFormTasasRet_Perc.CargarPadron;
VAR Tipo,S:String;
aux:Real;
posicion:Integer;
begin
  inherited;

  if MemoText.Lines.Count<=0 Then
    Raise Exception.Create('No hay datos para procesar...');
 // GifProceso.Visible:=True;
 // GifProceso.Animate:=True;
  if chbBorrarDatos.Checked then
    begin
      Borrar.Execute;
    end;
  btBorrar.Enabled:=False;
  CDSTasas.Close;
  CDSTasas.Open;
  btCancelar.Enabled:=True;
  btSalir.Enabled   :=False;
  if ComboBox1.ItemIndex=0 Then
    DecimalSeparator:=','
  else
  if ComboBox1.ItemIndex=1 Then
    DecimalSeparator:='.';

  Cancelado:=False;
  TotalReg:=0;
  TotalProcesado:=0;
  Minutos:=0;
  lbinicio.Caption:=TimeToStr(Now);
  pgProceso.Min:=0;
  pgProceso.Max:=MemoText.Lines.Count-1;
  pgProceso.Position:=0;
  TotalReg:=MemoText.Lines.Count-1;
  Timer1.Enabled:=True;
  for posicion:=0 to MemoText.Lines.Count-1 do
    begin
      TotalxMinuto     := TotalxMinuto+1; // este se resetea..
      TotalProcesado   := posicion;
      lbNroReg.Caption := IntToStr(posicion);
      lbRestan.Caption := FormatDateTime('hh:mm',Tiempo);
      lbMinutos.Caption:= FormatDateTime('ss',Now);
      s:=MemoText.Lines[posicion];
      pgProceso.Position:=posicion;
  //    Application.ProcessMessages;
      if cancelado=False Then
        begin
          spGravar_2.close;
          Tipo:=copy(s,1,1);
          spGravar_2.ParamByName('TIPO_PERCECPION').Value  := copy(s,1,1);
          delete(s,1,2);
          spGravar_2.ParamByName('desde').AsDate  := StrToDateTime(FormatDateTime('dd/mm/yyyy',StrToDate( (Copy(s,10,2) +'/'+ Copy(s,12,2) +'/'+ Copy(s,14,4) ))));
          spGravar_2.ParamByName('hasta').AsDate  := StrToDateTime(FormatDateTime('dd/mm/yyyy',StrToDate( (Copy(s,19,2) +'/'+ Copy(s,21,2) +'/'+ Copy(s,23,4) ))));
          spGravar_2.ParamByName('fecha').AsDate  := StrToDateTime(FormatDateTime('dd/mm/yyyy',StrToDate( (Copy(s,1,2)  +'/'+ Copy(s,3,2)  +'/'+ Copy(s,5,4) ))));
          spGravar_2.ParamByName('cuit').Value    := Copy(s,28,2)+'-'+Copy(s,30,8)+'-'+copy(s,38,1);
          spGravar_2.ParamByName('tipo').Value    := Copy(s,40,1);  // tipo de contribuyente
          spGravar_2.ParamByName('estado').Value  := Copy(S,42,1);  // se se da de alta o baja
          spGravar_2.ParamByName('cambio').Value  := Copy(s,44,1);  // si cambio la alicuota
          if Tipo='P' then
            spGravar_2.ParamByName('tasa_perc').AsFloat := StrToFloat(copy(s,46,4))
          else
            if Tipo='R' then
               spGravar_2.ParamByName('tasa_ret').AsFloat  :=  StrToFloat(copy(s,46,4));

          spGravar_2.ParamByName('g_per').Value := StrToInt(Copy(s,51,2));
          spGravar_2.ParamByName('g_ret').Value := StrToInt(Copy(s,51,2));
     //    spGravar.ParamByName('g_ret').Value := StrToInt(Copy(s,59,2));
          spGravar_2.ExecProc;
          spGravar_2.close;
        end
      else
        if MessageDlg('continua ?',mtConfirmation, [mbYes, mbNo], 0) = mrYes then
          begin
            btCancelar.Enabled:=True;
            btSalir.Enabled   :=False;
           // GifProceso.Visible:=True;
           // GifProceso.Animate:=True;
            btBorrar.Enabled:=False;
            cancelado:=False;
         //    Application.ProcessMessages;
          end
        else
          begin
            DecimalSeparator  :='.';
           // GifProceso.Visible:=False;
           // GifProceso.Animate:=False;
             pgProceso.Position:=0;
            lbfin.Caption     :=TimeToStr(now);
            btCancelar.Enabled:=False;
            btBorrar.Enabled  :=True;
            btSalir.Enabled   :=True;
            Timer1.Enabled:=False;
        //    Application.ProcessMessages;
            exit;
          end;
      
    end;
  DecimalSeparator  :='.';
 // GifProceso.Visible:=False;
 // GifProceso.Animate:=False;
  lbfin.Caption     :=TimeToStr(now);

  btCancelar.Enabled:=False;
  btBorrar.Enabled  :=True;
  btSalir.Enabled   :=True;
  Timer1.Enabled:=False;
end;

previeamente hago leer el tx para cargarlo al memo.

que hace a la cargar del padron, lo puse dentro de un trhead por que si no se me congelaba la maquina.
Lo q nunca hice es leer desde el disco el txt....????? se puede hacer eso?
Responder Con Cita