Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   Varios (https://www.clubdelphi.com/foros/forumdisplay.php?f=11)
-   -   ¿Cómo mostrar la información en una celda de un clientdataset? (https://www.clubdelphi.com/foros/showthread.php?t=77864)

jomah 01-03-2012 23:41:38

¿Cómo mostrar la información en una celda de un clientdataset?
 
bueno espero puedan ayudarme gracias de antemano

tengo un codigo en el cual utilizo un clientdataset para mostrar la informacion en una dbgrid llamo los campos y me muestra la mayoria excepto los nuevos que quiero agregar en estos dos campos nuevos quiero que se muestren un campo de la tabla original pero con la informacion dividida, las tablas son Paradox
ejemplo:
Código PHP:

tabla->Campo1->tipo    campo2->monto 
             
-----              -------
       
informa->h                134
                d                200
                h                20 

y lo que quiero mostrar es segun la primera tabla separar la segunda, si en la primera sale h que lo ponga en haber y si sale d que lo ponga en debe ejemplo:
Código PHP:

campo1->debe        campo2->haber
     
------                  ------
         
0                   134
         200                 0
         0                   20 

y elk codigo que tengo es el siguiente:

Código Delphi [-]
unit frmModelo;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, DB, DBTables, StdCtrls, Buttons, Grids, DBGrids, ComCtrls, Mask,
  DBCtrls, DBClient, XPMan, Provider;

type
  TfrmModelo1 = class(TForm)
    DBGrid1: TDBGrid;
    IMPRIMIR: TBitBtn;
    SALIR: TBitBtn;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    dbedtNUM_REG: TDBEdit;
    dbedtNUM_REG1: TDBEdit;
    dbedtFECHA_POL: TDBEdit;
    DataSource1: TDataSource;
    Query2: TQuery;
    xpmnfst1: TXPManifest;
    dtstprvdr1: TDataSetProvider;
    ds1: TClientDataSet;
    strngfldds1NUM_CTA: TStringField;
    smlntfldds1NUMDEPTO: TSmallintField;
    strngfldds1CONCEP_PO: TStringField;
    fltfldds1TIPCAMBIO: TFloatField;
    strngfldds1DEBE_HABER: TStringField;
    fltfldds1MONTOMOV: TFloatField;
    strngfldds1DEBE: TStringField;
    strngfldds1HABER: TStringField;
    intgrfldds1NUM_REG: TIntegerField;
    strngfldds1TIPO_POLI: TStringField;
    dtmfldds1FECHA_POL: TDateTimeField;
    strngfldds1NUM_POLIZ: TStringField;
    edt1: TEdit;
    edt2: TEdit;
    edt3: TEdit;
    edt4: TEdit;
    strngfldds1DEBE1: TStringField;
    strngfldds1HABER1: TStringField;
    edt5: TEdit;
    procedure SALIRClick(Sender: TObject);
    procedure FormShow(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  frmModelo1: TfrmModelo1;
  Tab: string;
  d1: string;
  d2: Currency;
  d3: string;
  d4: Integer;
  x: Integer;
implementation

uses frmPrincipal;

{$R *.dfm}

procedure TfrmModelo1.SALIRClick(Sender: TObject);
begin
CLOSE;
frmPrincipal1.BringToFront;
frmPrincipal1.Enabled:=True;
frmPrincipal1.DBGrid1.Enabled:=True;
end;

procedure TfrmModelo1.FormShow(Sender: TObject);
begin
Tab:= 'MO' + FormatDateTime('mmyy', Now) + '01';
Query2.Active:=False;
//query2.sql.text:='SELECT NUM_REG,TIPO_POLI,FECHA_POL,NUM_CTA,NUMDEPTO,CONCEP_PO,TIPCAMBIO,DEBE_HABER,NUM_POLIZ,MONTOMOV FROM MO021201';
Query2.Active:=True;
Query2.Last;
d4:=TStringGrid(DBGrid1).Row;
Query2.First;
ds1.Active:=True;
  While Not ds1.Eof do
  begin
    edt1.Text:=Query2.FieldValues['NUM_POLIZ'];
    //if frmPrincipal1.dbedt1.Text=edt1.Text then
    //begin
      d1:=query2.FieldValues['DEBE_HABER'];
      edt2.Text:=d1;
      d3:=query2.FieldValues['MONTOMOV'];
      edt3.Text:=d3;
      if edt2.Text='D' then
      begin
      ds1.Edit;
      ds1.FieldByName('DEBE1').AsString:=edt3.Text;
      ds1.FieldByName('HABER1').AsString:='0';
      ds1.Post;
      edt4.Text:=d3;
      edt5.Text:=d1;
      ds1.Next;
      end
      else if edt2.Text='H' then
      begin
      ds1.Edit;
      ds1.FieldByName('DEBE1').AsString:='0';
      ds1.FieldByName('HABER1').AsString:=d3;
      ds1.Post;
      edt5.Text:=d1;
      ds1.Next;
      end;

      Query2.Next;
    //end;

  end;
  ds1.Active:=False;
  ds1.Active:=True;
end;
end.

el problema es que al mostrar el dbgrid no muestra nada en los campos pero no me da errorquisiera que me brindaran un poco de ayuda

gracias por la ayuda por anticipado


La franja horaria es GMT +2. Ahora son las 02:37:46.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi