unit CadStatusCliente;

interface

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

type
  TfrmCadStatusCliente = class(TFrModeloCadastro)
    edtDescricao: TIB_Edit;
    GroupBox2: TGroupBox;
    dbCodigo: TIB_Text;
    edtCor: TColorBox;
    Label3: TLabel;
    IB_RadioGroup1: TIB_RadioGroup;
    IB_RadioGroup2: TIB_RadioGroup;
    procedure FormCreate(Sender: TObject);
    procedure BtInserirClick(Sender: TObject);
    procedure BtGravarClick(Sender: TObject);
    procedure BtAnteriorClick(Sender: TObject);
    procedure BtProximoClick(Sender: TObject);
    procedure BtCancelarClick(Sender: TObject);
    procedure BtEditarClick(Sender: TObject);
  private
    { Private declarations }
    procedure AtualizaTela;
  public
    { Public declarations }
  end;

var
  frmCadStatusCliente: TfrmCadStatusCliente;

implementation

uses DataModulo;

{$R *.dfm}

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

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

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

   TbPrincipal.FieldByName('COR').Value  := ColorToString(edtCor.Selected);
   inherited;
end;

procedure TfrmCadStatusCliente.BtAnteriorClick(Sender: TObject);
begin
  inherited;
AtualizaTela
end;

procedure TfrmCadStatusCliente.AtualizaTela;
begin
   if tbPrincipal.FieldByName('COR').AsString <> '' then
      edtCor.Selected:=StringToColor(tbPrincipal.FieldByName('COR').AsString);
end;

procedure TfrmCadStatusCliente.BtProximoClick(Sender: TObject);
begin
  inherited;
AtualizaTela
end;

procedure TfrmCadStatusCliente.BtCancelarClick(Sender: TObject);
begin
  inherited;
AtualizaTela
end;

procedure TfrmCadStatusCliente.BtEditarClick(Sender: TObject);
begin
  inherited;
  AtualizaTela;
end;

end.
