Source

asprovider / Demo / TestMain.pas

Full commit
unit TestMain;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, DB, DBClient, StdCtrls, Provider, Grids, DBGrids, xmldom, Xmlxform,
  ExtCtrls, DBCtrls, ASProvider, Mask, ActnList;

type
  TMainForm = class(TForm)
    Button1: TButton;
    DBGrid1: TDBGrid;
    Button2: TButton;
    DBNavigator1: TDBNavigator;
    ASComponentProvider1: TASComponentProvider;
    ClientDataSet1: TClientDataSet;
    DataSource1: TDataSource;
    DBText1: TDBText;
    DBEdit1: TDBEdit;
    Button3: TButton;
    ActionList1: TActionList;
    Action1: TAction;
    Action2: TAction;
    Button4: TButton;
    Action3: TAction;
    Action4: TAction;
    ClientDataSet1Caption: TWideStringField;
    ClientDataSet1Enabled: TBooleanField;
    ClientDataSet1Visible: TBooleanField;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure DBEdit1Change(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure Action1Update(Sender: TObject);
    procedure Action1Execute(Sender: TObject);
    procedure Action2Update(Sender: TObject);
    procedure Action2Execute(Sender: TObject);
    procedure Action3Update(Sender: TObject);
    procedure Action3Execute(Sender: TObject);
    procedure Action4Update(Sender: TObject);
    procedure Action4Execute(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  MainForm: TMainForm;

implementation

{$R *.dfm}

procedure TMainForm.Action1Execute(Sender: TObject);
begin
  ClientDataSet1.Open;
end;

procedure TMainForm.Action1Update(Sender: TObject);
begin
  (Sender as TAction).Enabled := ClientDataSet1.Active = False;
end;

procedure TMainForm.Action2Execute(Sender: TObject);
begin
  ClientDataSet1.Close;
end;

procedure TMainForm.Action2Update(Sender: TObject);
begin
  (Sender as TAction).Enabled := ClientDataSet1.Active = True;
end;

procedure TMainForm.Action3Execute(Sender: TObject);
begin
  ClientDataSet1.ApplyUpdates(0);
end;

procedure TMainForm.Action3Update(Sender: TObject);
begin
  (Sender as TAction).Enabled := ClientDataSet1.ChangeCount > 0;
end;

procedure TMainForm.Action4Execute(Sender: TObject);
begin
  ClientDataSet1.CancelUpdates;
end;

procedure TMainForm.Action4Update(Sender: TObject);
begin
  (Sender as TAction).Enabled := ClientDataSet1.ChangeCount > 0;
end;

procedure TMainForm.Button1Click(Sender: TObject);
begin
  ClientDataSet1.Open;
end;

procedure TMainForm.Button2Click(Sender: TObject);
begin
  ClientDataSet1.ApplyUpdates(0);
end;

procedure TMainForm.Button3Click(Sender: TObject);
begin
  ClientDataSet1.CancelUpdates;
end;

procedure TMainForm.DBEdit1Change(Sender: TObject);
begin
  with (Sender as TDBEdit) do
    if Text = 'foo' then begin
      EditText := 'foo bar';
    end;
end;

end.