unit DialogOsoba;

interface

uses
  Windows, Messages, Classes, SysUtils, Graphics, Controls, StdCtrls, Forms,
  Dialogs, DBCtrls, DB, Mask, ExtCtrls, Buttons,
  DataModule;

type
  TDlgOsoba = class(TForm)
    ScrollBox: TScrollBox;
    Label2: TLabel;
    EditNAZWISKO: TDBEdit;
    Label3: TLabel;
    EditIMIE: TDBEdit;
    Label4: TLabel;
    EditDATAUR: TDBEdit;
    Label5: TLabel;
    EditMCOWOSC: TDBEdit;
    Label6: TLabel;
    EditULICAINR: TDBEdit;
    Label7: TLabel;
    EditKODP: TDBEdit;
    Label8: TLabel;
    EditMIASTO: TDBEdit;
    Label9: TLabel;
    EditPESEL: TDBEdit;
    Panel2: TPanel;
    Label1: TLabel;
    EditIDOSOBY: TDBEdit;
    BitBtnOK: TBitBtn;
    BitBtnAnuluj: TBitBtn;
    procedure BitBtnOKClick(Sender: TObject);
    procedure BitBtnAnulujClick(Sender: TObject);
    procedure EditNAZWISKOExit(Sender: TObject);
    procedure EditIMIEExit(Sender: TObject);
    procedure EditDATAURExit(Sender: TObject);
  private
    { private declarations }
  public
    { public declarations }
  end;

var
  DlgOsoba: TDlgOsoba;

implementation
{$R *.DFM}
{------------------------------------------------------------------------------}
procedure TDlgOsoba.BitBtnOKClick(Sender: TObject);
var
   sa_puste : Boolean;
   
begin
   sa_puste := False;

   if(DM.TableOsobyNAZWISKO.IsNull) or (DM.TableOsobyNAZWISKO.Value  = '') then begin
      sa_puste := True;
      EditNAZWISKO.Color := clYellow;
   end
   else begin
      EditNAZWISKO.Color := clWindow;
   end;

   if(DM.TableOsobyIMIE.IsNull) or (DM.TableOsobyIMIE.Value = '') then begin
      sa_puste := True;
      EditIMIE.Color := clYellow;
   end
   else begin
      EditIMIE.Color := clWindow;
   end;

   if(DM.TableOsobyDATAUR.IsNull) then begin
      sa_puste := True;
      EditDATAUR.Color := clYellow;
   end
   else begin
      EditDATAUR.Color := clWindow;
   end;
   
   if Sa_puste then begin
      Modalresult := mrNone;
   end
   else begin
      DM.TableOsoby.Edit();
      DM.TableOsoby.Post();
   end;
end;

procedure TDlgOsoba.BitBtnAnulujClick(Sender: TObject);
begin
   DM.TableOsoby.Cancel();
end;

procedure TDlgOsoba.EditNAZWISKOExit(Sender: TObject);
begin
   if (DM.TableOsobyNAZWISKO.IsNull) or (DM.TableOsobyNAZWISKO.Value  = '') then begin
      EditNAZWISKO.Color := clYellow;
   end
   else begin
      EditNAZWISKO.Color := clWindow;
   end;
end;

procedure TDlgOsoba.EditIMIEExit(Sender: TObject);
begin
   if(DM.TableOsobyIMIE.IsNull) or (DM.TableOsobyIMIE.Value = '') then begin
      EditIMIE.Color := clYellow;
   end
   else begin
      EditIMIE.Color := clWindow;
   end;
end;

procedure TDlgOsoba.EditDATAURExit(Sender: TObject);
begin
   if(DM.TableOsobyDATAUR.IsNull) then begin
      EditDATAUR.Color := clYellow;
   end
   else begin
      EditDATAUR.Color := clWindow;
   end;
end;

end.
