unit CadPraca;

interface

uses
  Windows, system.UItypes, IB_Access,  Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ModeloCadastro, UCBase, ImgList, AppEvnts, IB_Components,
  ExtCtrls, StdCtrls, jpeg, Grids, IB_Grid, Buttons, ComCtrls, Mask,
  IB_Controls, IB_EditButton, System.ImageList;

type
  TfrmCadPracas = class(TFrModeloCadastro)
    GroupBox2: TGroupBox;
    dbCodigo: TIB_Text;
    edtDescricao: TIB_Edit;
    procedure FormCreate(Sender: TObject);
    procedure BtGravarClick(Sender: TObject);
    procedure BtExcluirClick(Sender: TObject);
    procedure btnEditar2Click(Sender: TObject);
    procedure BtInserirClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  frmCadPracas: TfrmCadPracas;

implementation

{$R *.dfm}

procedure TfrmCadPracas.FormCreate(Sender: TObject);
begin
   Gera_Codigo      := True;
   Chave_Tabela     := 'CODIGO';
   Descricao_Unica  := True;
   Campo_Tabela     := 'DESCRICAO';
   inherited;
end;

procedure TfrmCadPracas.BtGravarClick(Sender: TObject);
begin
   if edtDescricao.Text = '' then
   begin
      MessageDlg('Informe a descrição', mtWarning, [mbOK], 0);
      edtDescricao.SetFocus;
      Exit;
   end;

  if TbPrincipal.State in [dssInsert] then
     descricao_auditoria := 'CADASTROU PRAÇA ' + TbPrincipal.FieldByName('CODIGO').AsString  + ' ' + TbPrincipal.FieldByName('DESCRICAO').AsString;

  if TbPrincipal.State in [dssEdit] then
     descricao_auditoria := 'ALTEROU PRAÇA ' + TbPrincipal.FieldByName('CODIGO').OldAsString  + ' ' + TbPrincipal.FieldByName('DESCRICAO').OldAsString;

  inherited;
end;

procedure TfrmCadPracas.BtExcluirClick(Sender: TObject);
begin
   descricao_auditoria := 'EXCLUIU A PRAÇA ' + TbPrincipal.FieldByName('CODIGO').AsString + ' ' + TbPrincipal.FieldByName('DESCRICAO').AsString;
   inherited;
end;

procedure TfrmCadPracas.btnEditar2Click(Sender: TObject);
begin
   edtDescricao.SetFocus;
   inherited;
end;

procedure TfrmCadPracas.BtInserirClick(Sender: TObject);
begin
  inherited;
  try
     edtDescricao.SetFocus;
     except
  end;
end;

end.
