unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls, DBCtrls, Grids, DBGrids, TeeProcs, TeEngine,
  Chart, DBChart, TeeDBEdit, TeeDBCrossTab, DB, DBTables, Series;

type
  TForm1 = class(TForm)
    Panel1: TPanel;
    DBChart1: TDBChart;
    Panel2: TPanel;
    DBGrid1: TDBGrid;
    Panel3: TPanel;
    DBNavigator1: TDBNavigator;
    Panel4: TPanel;
    Button1: TButton;
    RadioGroup1: TRadioGroup;
    CheckBox1: TCheckBox;
    Button2: TButton;
    Table1: TTable;
    DBCrossTabSource1: TDBCrossTabSource;
    Series1: TBarSeries;
    DataSource1: TDataSource;
    procedure CheckBox1Click(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure RadioGroup1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  bswap:boolean=false;
implementation

{$R *.dfm}

procedure TForm1.CheckBox1Click(Sender: TObject);
begin
//Table1.Active := CheckBox1.Checked;
DBCrossTabSource1.Active := CheckBox1.Checked;
RadioGroup1.Enabled := CheckBox1.Checked;
Button2.Enabled     := CheckBox1.Checked;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
Close;
end;

procedure TForm1.RadioGroup1Click(Sender: TObject);
begin
case RadioGroup1.ItemIndex of
0: DBCrossTabSource1.Formula := gfCount;
1: DBCrossTabSource1.Formula := gfSum;
end;
DBCrossTabSource1.ValueField := 'AmountPaid';
DBCrossTabSource1.Active := TRUE;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
if not bswap then
  begin
    DBCrossTabSource1.GroupField := 'Terms';
    DBCrossTabSource1.LabelField := 'ShipVIA';
    bswap := not bswap;
  end
  else
    begin
      DBCrossTabSource1.GroupField := 'ShipVIA';
      DBCrossTabSource1.LabelField := 'Terms';
      bswap := not bswap;
    end;
DBCrossTabSource1.ValueField := 'AmountPaid';
DBCrossTabSource1.Active := TRUE;
end;

end.
