unit Uvvod;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Grids, DBGrids, RXDBCtrl, StdCtrls, DBCtrls, Mask, ExtCtrls, DB,
  IBCustomDataSet, IBTable;

type
  TFvvod = class(TForm)
    Button1: TButton;
    Dtext: TDBMemo;
    Dvvod: TRxDBGrid;
    Button2: TButton;
    StaticText2: TStaticText;
    Dupr: TDBNavigator;
    Button3: TButton;
    Rloch: TRadioButton;
    Rprav: TRadioButton;
    Timer1: TTimer;
    Button4: TButton;
    Button5: TButton;
    StaticText3: TStaticText;
    Dotv: TRxDBGrid;
    StaticText4: TStaticText;
    Durov: TDBEdit;
    procedure Button2Click(Sender: TObject);
    procedure Button4Click(Sender: TObject);
    procedure Button5Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure RlochClick(Sender: TObject);
    procedure RpravClick(Sender: TObject);
    procedure DvvodCellClick(Column: TColumn);
    procedure DotvCellClick(Column: TColumn);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Fvvod: TFvvod;

implementation

uses Udatav;

{$R *.dfm}

procedure TFvvod.Button2Click(Sender: TObject);
var i:integer;
begin
with datav do begin
if not datav.Trbase.Active then  datav.Trbase.Active:=true;
dupr.DataSource:=datav.Dssosnv;
dtext.DataField:='';
dtext.DataSource:=datav.Dssosnv;
dtext.DataField:='VOPROS';
sosnv.Append;
end;
end;

procedure TFvvod.Button4Click(Sender: TObject);
begin
if (datav.Sosnv.State=dsedit) or (datav.Sosnv.State=dsinsert) then datav.Sosnv.Post;
if (datav.Sotv.State=dsedit) or (datav.Sotv.State=dsinsert) then datav.Sotv.Post;
datav.Trbase.CommitRetaining;
end;

procedure TFvvod.Button5Click(Sender: TObject);
begin
datav.Trbase.RollbackRetaining;
end;

procedure TFvvod.Button3Click(Sender: TObject);
begin

with datav do begin
if not datav.Trbase.Active then  datav.Trbase.Active:=true;
if (sosnv.State=dsedit) or (sosnv.State=dsinsert) then sosnv.Post;
dtext.DataField:='';
dupr.DataSource:=datav.Dssotv;
dtext.DataSource:=datav.Dssotv;
dtext.DataField:='OTVET';
sotv.Append;
datav.SotvNIDVOP.Value:=datav.SosnvNIDOSNV.Value;
datav.SotvPRAVDA.Value:=0;
rloch.Checked:=true;
end;
end;

procedure TFvvod.FormShow(Sender: TObject);
begin
datav.Sotv.Open;
datav.Sosnv.Open;

end;

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

procedure TFvvod.RlochClick(Sender: TObject);
begin
if (datav.Sotv.State<>dsedit) or (datav.Sotv.State<>dsinsert) then datav.Sotv.Edit;
datav.SotvPRAVDA.Value:=0;
end;

procedure TFvvod.RpravClick(Sender: TObject);
begin
if (datav.Sotv.State<>dsedit) or (datav.Sotv.State<>dsinsert) then datav.Sotv.Edit;
datav.SotvPRAVDA.Value:=1;
end;

procedure TFvvod.DvvodCellClick(Column: TColumn);
begin
dtext.DataField:='';
dtext.DataSource:=datav.Dssosnv;
dtext.DataField:='VOPROS';
end;

procedure TFvvod.DotvCellClick(Column: TColumn);
begin
dtext.DataField:='';
dtext.DataSource:=datav.Dssotv;
dtext.DataField:='OTVET';
end;

end.
