Ver Mensaje Individual
  #3  
Antiguo 20-04-2019
Avatar de oscarac
[oscarac] oscarac is offline
Miembro Premium
 
Registrado: sep 2006
Ubicación: Lima - Perú
Posts: 2.010
Reputación: 20
oscarac Va por buen camino
al parecer no explique bien el problema,
existen diferentes tipos de documento (F,B,T)

pero ya lo soluciones de esta manera

Código Delphi [-]
  SqlStr := 'Select TDC, DOC ' +
            'From TblFacturasC ' +
            'Where Empresa = ' + QuotedStr(dmGlobal.g_CodigoEmpresa) +
            ' and Periodo = ' + QuotedStr(dmGlobal.g_Periodo) +
            ' order by TDC, DOC' ;

  CdsCorrelativoVenta.EmptyDataSet;
  CdsCorrelativoVenta.Open;
  qryVerCorrelativoVenta.Close;
  qryVerCorrelativoVenta.SQL.Clear;
  qryVerCorrelativoVenta.SQL.Add(SqlStr);
  qryVerCorrelativoVenta.Open;
  qryVerCorrelativoVenta.First;
  ProgressBarXls.Max := qryVerCorrelativoVenta.RecordCount;
  ProgressBarXls.Position := 0;
  ProgressBarXls.Visible := True;
  _TDC := qryVerCorrelativoVentaTDC.AsString;
  _DOC := qryVerCorrelativoVentaDOC.AsString;
  qryVerCorrelativoVenta.Next;
  While not qryVerCorrelativoVenta.eof Do
  Begin
    Application.ProcessMessages;
    if Izquierda(_DOC, Pos('-', _DOC)) <> Izquierda(qryVerCorrelativoVentaDOC.AsString, pos ('-', qryVerCorrelativoVentaDOC.AsString)) then
    Begin
      _TDC := qryVerCorrelativoVentaTDC.AsString;
      _DOC := qryVerCorrelativoVentaDOC.AsString;
    End
    Else
    if StrToInt(Desde(_DOC, Pos('-', _DOC)+1)) + 1 <> StrToInt(Desde(qryVerCorrelativoVentaDOC.AsString, Pos('-', qryVerCorrelativoVentaDOC.AsString)+1)) then
    begin
      x_DOC := StrToInt(Desde(_DOC, Pos('-', _DOC)+1)) + 1;
      while StrToInt(Desde(qryVerCorrelativoVentaDOC.AsString, Pos('-', qryVerCorrelativoVentaDOC.AsString)+1)) > x_DOC do
      begin
        CdsCorrelativoVenta.Append;
        CdsCorrelativoVentaTDC.AsString := _TDC;
        CdsCorrelativoVentaDOC.AsString := IntToStr(x_DOC);
        CdsCorrelativoVenta.Post;
        Inc(x_DOC);
      end;
      _DOC := qryVerCorrelativoVentaDOC.AsString;
    end
    else
    begin
      _TDC := qryVerCorrelativoVentaTDC.AsString;
      _DOC := qryVerCorrelativoVentaDOC.AsString;
    end;
    qryVerCorrelativoVenta.Next;
    ProgressBarXls.Position := ProgressBarXls.Position + 1;
  End;
__________________
Dulce Regalo que Satanas manda para mi.....
Responder Con Cita