unit Unit4;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  Grids, DBGrids, StdCtrls, ExtCtrls, Buttons, Db, DBTables, DBCtrls,
  DBCGrids, Menus, Mask;

type
  Tteste = class(TForm)
    Panel1: TPanel;
    Panel2: TPanel;
    Label1: TLabel;
    DBGrid1: TDBGrid;
    Panel3: TPanel;
    Panel4: TPanel;
    Panel5: TPanel;
    Panel6: TPanel;
    DBGrid2: TDBGrid;
    SpeedButton1: TSpeedButton;
    SpeedButton2: TSpeedButton;
    SpeedButton3: TSpeedButton;
    SpeedButton4: TSpeedButton;
    SpeedButton5: TSpeedButton;
    SpeedButton6: TSpeedButton;
    Panel7: TPanel;
    Panel8: TPanel;
    Panel9: TPanel;
    DBCtrlGrid1: TDBCtrlGrid;
    DBMemo1: TDBMemo;
    DBGrid4: TDBGrid;
    Panel10: TPanel;
    Panel11: TPanel;
    SpeedButton7: TSpeedButton;
    SpeedButton9: TSpeedButton;
    Panel12: TPanel;
    SpeedButton8: TSpeedButton;
    SpeedButton10: TSpeedButton;
    SpeedButton11: TSpeedButton;
    PopupMenu1: TPopupMenu;
    Corect1: TMenuItem;
    Incorect1: TMenuItem;
    DBEdit1: TDBEdit;
    DBEdit2: TDBEdit;
    DBEdit3: TDBEdit;
    DBEdit4: TDBEdit;
    DBEdit5: TDBEdit;
    DBEdit6: TDBEdit;
    DBEdit7: TDBEdit;
    DBEdit8: TDBEdit;
    DBEdit9: TDBEdit;
    DBEdit10: TDBEdit;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    Label6: TLabel;
    Label7: TLabel;
    Label8: TLabel;
    Label9: TLabel;
    Label10: TLabel;
    Label11: TLabel;
    Label12: TLabel;
    Label13: TLabel;
    DBMemo2: TDBMemo;
    SpeedButton12: TSpeedButton;
    Panel13: TPanel;
    SpeedButton13: TSpeedButton;
    SpeedButton14: TSpeedButton;
    procedure SpeedButton1Click(Sender: TObject);
    procedure SpeedButton2Click(Sender: TObject);
    procedure SpeedButton3Click(Sender: TObject);
    procedure SpeedButton6Click(Sender: TObject);
    procedure DBGrid1ColEnter(Sender: TObject);
    procedure DBGrid1KeyUp(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure SpeedButton9Click(Sender: TObject);
    procedure SpeedButton7Click(Sender: TObject);
    procedure FormResize(Sender: TObject);
    procedure SpeedButton5Click(Sender: TObject);
    procedure SpeedButton4Click(Sender: TObject);
    procedure SpeedButton8Click(Sender: TObject);
    procedure SpeedButton10Click(Sender: TObject);
    procedure SpeedButton11Click(Sender: TObject);
    procedure DBGrid4DrawColumnCell(Sender: TObject; const Rect: TRect;
      DataCol: Integer; Column: TColumn; State: TGridDrawState);
    procedure Corect1Click(Sender: TObject);
    procedure Incorect1Click(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure SpeedButton14Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  teste: Tteste;

implementation

uses Unit3;

{$R *.DFM}

procedure Tteste.SpeedButton1Click(Sender: TObject);
var s:string;
begin
if InputQuery('Initiere disciplina.', 'Introduceti denumirea disciplinei:', s) then
 if s<>'' then
  begin
   dm.lectii.Append;
   dm.lectii['lectie']:=s;
   dm.lectii.Post;
  end;

end;

procedure Tteste.SpeedButton2Click(Sender: TObject);
begin
dbgrid1.Options:=[dgEditing,dgTitles,dgIndicator,dgColumnResize,dgColLines,dgRowLines,dgTabs,dgConfirmDelete,dgCancelOnExit];
dm.lectii.Edit;
end;

procedure Tteste.SpeedButton3Click(Sender: TObject);
begin
if (dm.lectii.State=dsEdit)or(dm.lectii.State=dsInsert) then dm.lectii.Post;
dbgrid1.Options:=[dgTitles,dgIndicator,dgColumnResize,dgColLines,dgRowLines,dgTabs,dgRowSelect,dgConfirmDelete,dgCancelOnExit];
end;

procedure Tteste.SpeedButton6Click(Sender: TObject);
var s:string;
begin
if InputQuery('Initiere test.', 'Introduceti denumirea testului:', s) then
 if s<>'' then
  begin
   dm.teste.Append;
   dm.teste['den_test']:=s;
   dm.teste['cod_lect']:=dm.lectii['cod'];
   dm.teste.Post;
  end;
end;

procedure Tteste.DBGrid1ColEnter(Sender: TObject);
begin
dm.teste.Filtered:=false;
dm.teste.Filter:='cod_lect='+inttostr(dm.lectii['cod']);
dm.teste.Filtered:=true;
end;

procedure Tteste.DBGrid1KeyUp(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
dm.teste.Filtered:=false;
dm.teste.Filter:='cod_lect='+inttostr(dm.lectii['cod']);
dm.teste.Filtered:=true;
end;

procedure Tteste.SpeedButton9Click(Sender: TObject);
begin
dm.itemi.Append;
dm.itemi['cod_test']:=dm.teste['cod'];
end;

procedure Tteste.SpeedButton7Click(Sender: TObject);
begin
if (dm.itemi.State=dsEdit)or(dm.itemi.State=dsInsert) then dm.itemi.Post;
end;

procedure Tteste.FormResize(Sender: TObject);
begin
dbctrlgrid1.RowCount:=trunc(dbctrlgrid1.height/50);
end;

procedure Tteste.SpeedButton5Click(Sender: TObject);
begin
dbgrid2.Options:=[dgEditing,dgTitles,dgIndicator,dgColumnResize,dgColLines,dgRowLines,dgTabs,dgConfirmDelete,dgCancelOnExit];
dm.teste.Edit;
end;

procedure Tteste.SpeedButton4Click(Sender: TObject);
begin
if (dm.teste.State=dsEdit)or(dm.teste.State=dsInsert) then dm.teste.Post;
dbgrid2.Options:=[dgTitles,dgIndicator,dgColumnResize,dgColLines,dgRowLines,dgTabs,dgRowSelect,dgConfirmDelete,dgCancelOnExit];

end;

procedure Tteste.SpeedButton8Click(Sender: TObject);
var s:string;
begin
if InputQuery('Initiere raspuns.', 'Introduceti raspunsul:', s) then
 if s<>'' then
  begin
   dm.rasp.Append;
   dm.rasp['raspuns']:=s;
   dm.rasp['cod_itemi']:=dm.itemi['cod'];
   dm.rasp.Post;
  end;

end;

procedure Tteste.SpeedButton10Click(Sender: TObject);
begin
dbgrid4.Options:=[dgEditing,dgTitles,dgIndicator,dgColumnResize,dgColLines,dgRowLines,dgTabs,dgConfirmDelete,dgCancelOnExit];
dm.rasp.Edit;
end;

procedure Tteste.SpeedButton11Click(Sender: TObject);
begin
if (dm.rasp.State=dsEdit)or(dm.rasp.State=dsInsert) then dm.rasp.Post;
dbgrid4.Options:=[dgTitles,dgIndicator,dgColumnResize,dgColLines,dgRowLines,dgTabs,dgRowSelect,dgConfirmDelete,dgCancelOnExit];

end;

procedure Tteste.DBGrid4DrawColumnCell(Sender: TObject; const Rect: TRect;
  DataCol: Integer; Column: TColumn; State: TGridDrawState);
begin
with dbgrid4.Canvas do begin
 if not(gdfocused in State) then
 begin
 if dm.rasp['adevarat']=true then brush.Color:=clAqua;
 font.Color:=clBlack;
 fillrect(rect);
 textout(rect.left,rect.top,column.field.text);
 end
 else
 dbgrid1.defaultdrawcolumncell(rect,datacol,column,state);
end;
end;

procedure Tteste.Corect1Click(Sender: TObject);
begin
dm.rasp.edit;
dm.rasp['adevarat']:=true;
dm.rasp.post;
end;

procedure Tteste.Incorect1Click(Sender: TObject);
begin
dm.rasp.edit;
dm.rasp['adevarat']:=false;
dm.rasp.post;
end;

procedure Tteste.FormShow(Sender: TObject);
begin
dbctrlgrid1.RowCount:=trunc(dbctrlgrid1.height/50);
end;

procedure Tteste.SpeedButton14Click(Sender: TObject);
var i:integer;
begin
dm.rasp.first;
while not dm.rasp.Eof do dm.rasp.Delete;

end;

end.
