unit Vraag1_UXXXX;

  {Sleutel jou eksmamennommer hier in}

interface

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

type
  TfrmVraagEen = class(TForm)
    Panel1: TPanel;
    Panel2: TPanel;
    btnA: TButton;
    btnB: TButton;
    btnC: TButton;
    btnD: TButton;
    btnE: TButton;
    btnF: TButton;
    btnG: TButton;
    bmbClose: TBitBtn;
    qryQEen: TADOQuery;
    dsrEen: TDataSource;
    grdEen: TDBGrid;

    procedure btnAClick(Sender: TObject);
    procedure btnBClick(Sender: TObject);
    procedure btnCClick(Sender: TObject);
    procedure btnDClick(Sender: TObject);
    procedure btnEClick(Sender: TObject);
    procedure btnFClick(Sender: TObject);
    procedure btnGClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  frmVraagEen: TfrmVraagEen;

implementation

{$R *.dfm}


procedure TfrmVraagEen.btnAClick(Sender: TObject);
begin
  qryQEen.Active := False;
  qryQEen.SQL.Text :=  'SELECT StalletjieNaam, Klas, GetalGaste '  +
                       'FROM tblStalletjies '+
                       'ORDER BY GetalGaste DESC';
  qryQEen.Active := True;
end;

procedure TfrmVraagEen.btnBClick(Sender: TObject);
begin
  qryQEen.Active := False;
  qryQEen.SQL.Text :=  'SELECT Onderwyser  '+
                       'FROM tblStalletjies ' +
                       'WHERE (GetalGaste>= 100) AND (StalletjieId like "RC%")';
  qryQEen.Active := True;
end;

procedure TfrmVraagEen.btnCClick(Sender: TObject);
begin
  qryQEen.Active := False;
  qryQEen.SQL.Text :=  'SELECT StalletjieNaam, GetalGaste, ' +
                       'Round(GetalGaste * 1.25,0) AS PorsiesOmVoorteberei ' +
                       'FROM tblStalletjies';
  qryQEen.Active := True;
end;

procedure TfrmVraagEen.btnDClick(Sender: TObject);
var
   sX : String;
begin
  sX := INPUTBOX('Vraag', 'Item ? ', 'Rys');
  qryQEen.Active := False;
  qryQEen.SQL.Text :=  'SELECT format(Sum(Bedrag),"Currency") AS Totaal ' +
                       'FROM tblDonasies ' +
                       'WHERE (Item Like "%' + sX + '%") AND NOT Ontvang ';
  qryQEen.Active := True;
end;

procedure TfrmVraagEen.btnEClick(Sender: TObject);
begin
  qryQEen.Active := False;
  qryQEen.SQL.Text :=  'SELECT Item, Format(sum(Bedrag), "Currency") AS BedragOntvang ' +
                       'From tblStalletjies, tblDonasies ' +
                       'WHERE (tblStalletjies.StalletjieID = tblDonasies.StalletjieID) AND ' +
                       ' Ontvang AND (Klas = "12B")' +
                       'GROUP BY Item';
  qryQEen.Active := True;
end;

procedure TfrmVraagEen.btnFClick(Sender: TObject);
var
  iX : integer;
begin
  qryQEen.Active := False;
  qryQEen.SQL.Text :=  'UPDATE tblStalletjies ' +
                       'SET GetalGaste = GetalGaste + (0.05*GetalGaste) ' +
                       'WHERE (Klas like "%A")';
  iX := qryQEen.ExecSQL;
  MessageDlg('Rekords Suksesvol Verwerk',mtInformation,[mbok],0);
end;

procedure TfrmVraagEen.btnGClick(Sender: TObject);
var
  iX : integer;
begin
  qryQEen.Active := False;
  qryQEen.SQL.Text :=  'INSERT INTO tblDonasies ' +
                       '(StalletjieID, Item, Bedrag, Ontvang) ' +
                       'VALUES ("HC77","Ander uitgawes",200,TRUE)';
  iX := qryQEen.ExecSQL;
  MessageDlg('Rekords Suksesvol Verwerk',mtInformation,[mbok],0);
end;



end.
