Ver Mensaje Individual
  #10  
Antiguo 02-06-2006
CamiloU CamiloU is offline
Miembro
 
Registrado: dic 2005
Ubicación: Sincelejo - COlombia
Posts: 59
Reputación: 19
CamiloU Va por buen camino
No me funciona.

Presento todo el proceso. En el primer procedimiento recorro la Tabla Nomina y lleno los StringGrid (Ingresos y Descuentos) de acuerdo al tipo. Después estan los procedimientos de alineacion, pero no hace nada.

Antes de estos procedimientos es necesario realizar alguna declaración o algun paso anterior.

Código Delphi [-]
procedure TComPagoDetalleACD.MPerSelect(Sender: TObject);
var
  i, suming, sumegr : integer;
begin
  for i := 0 to Ingresos.RowCount do
      Ingresos.Rows[i].Clear;
  for i := 0 to Descuentos.RowCount do
      Descuentos.Rows[i].Clear;
  SuelDocente.Clear;
  DescDocente.Clear;
  NetoRecibido.Clear;
  pmes := MPer.Text;
  pper := concat(pmes,'/',pano);
  TNomina.First;
  cont1 := 0;
  cont2 := 0;
  suming := 0;
  sumegr := 0;
  while (Not TNomina.Eof) do
    begin
      if (TNomina.FieldByName('cedula').AsString = ceddocente) and
         (TNomina.FieldByName('periodo').AsString = pper) then
        begin
          if TNomina.FieldByName('clase').AsString = 'D' then
            begin
              Ingresos.Cells[0,cont1] := TNomina.FieldByName('codigo').AsString;
              Ingresos.Cells[1,cont1] := TNomina.FieldByName('factor').AsString;
              suming := suming + strtoint(TNomina.FieldByName('valor').AsString);
              Ingresos.Cells[2,cont1] := TNomina.FieldByName('valor').AsString;
              cont1 := cont1 + 1;
            end;
          if TNomina.FieldByName('clase').AsString = 'C' then
            begin
              Descuentos.Cells[0,cont2] := TNomina.FieldByName('codigo').AsString;
              Descuentos.Cells[1,cont2] := TNomina.FieldByName('factor').AsString;
              sumegr := sumegr + strtoint(TNomina.FieldByName('valor').AsString);
              Descuentos.Cells[2,cont2] := TNomina.FieldByName('valor').AsString;
              cont2 := cont2 + 1;
            end
        end;
      TNomina.Next;
    end;
  SuelDocente.Text := inttostr(suming);
  DescDocente.Text := inttostr(sumegr);
  NetoRecibido.Text := inttostr(suming - sumegr);
end;

procedure TComPagoDetalleACD.IngresosDrawCell(Sender: TObject; ACol,
  ARow: Integer; Rect: TRect; State: TGridDrawState);
begin
  if ACol = 0 then
      Display(Ingresos, Ingresos.Cells[ACol,ARow], taCenter);
  if ACol = 2 then
      Display(Ingresos, Ingresos.Cells[ACol,ARow], taRightJustify);
end;

procedure TComPagoDetalleACD.WriteText(StringGrid: TStringGrid; ACanvas: TCanvas; const ARect: TRect;
     const Text: string; Format: Word);
const
  DX = 2;
  DY = 2;
var
  S: array[0..255] of Char;
begin
  with StringGrid, ACanvas, ARect do
    begin
      case Format of
          DT_LEFT: ExtTextOut(Handle, Left + DX, Top + DY,
             ETO_OPAQUE or ETO_CLIPPED, @ARect, StrPCopy(S, Text), Length(Text), nil);
          DT_RIGHT: ExtTextOut(Handle, Right - TextWidth(Text) - 3, Top + DY,
             ETO_OPAQUE or ETO_CLIPPED, @ARect, StrPCopy(S, Text),
             Length(Text), nil);
          DT_CENTER: ExtTextOut(Handle, Left + (Right - Left - TextWidth(Text)) div 2,
             Top + DY, ETO_OPAQUE or ETO_CLIPPED, @ARect,
             StrPCopy(S, Text), Length(Text), nil);
      end;
    end;
end;

procedure TComPagoDetalleACD.Display(StringGrid: TStringGrid; const S: string; Alignment: TAlignment);
const
  Formats: array[TAlignment] of Word = (DT_LEFT, DT_RIGHT, DT_CENTER);
begin
  WriteText(StringGrid, StringGrid.Canvas, ARect, S, Formats[Alignment]);
end;

Muchas gracias y peronen por tanta molestadera.
Responder Con Cita