unit UResumoCaixa;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Buttons, ComCtrls, StdCtrls, DB, Grids, DBGrids, ExtCtrls;

type
  TFResumo = class(TForm)
    Panel1: TPanel;
    DBGrid1: TDBGrid;
    DSCaixa: TDataSource;
    Panel2: TPanel;
    Label1: TLabel;
    LbTotal: TLabel;
    Data1: TDateTimePicker;
    Data2: TDateTimePicker;
    SpeedButton1: TSpeedButton;
    SpeedButton2: TSpeedButton;
    Label2: TLabel;
    Label3: TLabel;
    procedure SpeedButton1Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure SpeedButton2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  FResumo: TFResumo;

implementation
uses
  UDataModulo;

{$R *.dfm}

procedure TFResumo.SpeedButton1Click(Sender: TObject);
var
Total:Currency;
BookMark:TBookmarkStr;
begin
  BookMark:=Modulo.Tbcaixa.Bookmark;
  Modulo.Tbcaixa.Filtered:=False;
  Modulo.Tbcaixa.Filter:='Data>='''+DateToStr(Data1.Date)+
                         '''and Data<='''+DateToStr(Data2.Date)+'''';
  Modulo.Tbcaixa.filtered:=True;
  Total:=0;
  Modulo.Tbcaixa.DisableControls;
  Modulo.Tbcaixa.First;
  while not Modulo.Tbcaixa.eof do
  begin
    Total:=Total+Modulo.Tbcaixa['Total'];
    Modulo.Tbcaixa.Next;
  end;

  LbTotal.Caption:=Format('%8f',[Total]);
  Modulo.Tbcaixa.BookMark:=BookMark;
  Modulo.Tbcaixa.EnableControls;
end;

procedure TFResumo.FormCreate(Sender: TObject);
begin
  Modulo.TbCaixa.Open;
  Data1.Date:=Date;
  Data2.Date:=Date;
end;

procedure TFResumo.SpeedButton2Click(Sender: TObject);
begin
  Modulo.TbCaixa.Filtered:=False;
end;

end.
