unit AlteracaoStatusCliente;

interface

uses
  Windows, system.UItypes, IB_Access,  Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, TelaComum, StdCtrls, Buttons, ExtCtrls, IB_Components,
  IB_Controls, ImgList, jpeg,DataModulo, System.ImageList;

type
  TfrmAlteracaoStatusCliente = class(TfrmTelaComum)
    IB_DataSource1: TIB_DataSource;
    edtDescricao: TIB_Memo;
    Image1: TImage;
    qrAlteracaoStatus: TIB_Query;
    procedure BtGravarClick(Sender: TObject);
    procedure BtCancelarClick(Sender: TObject);
    procedure edtDescricaoKeyPress(Sender: TObject; var Key: Char);
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  frmAlteracaoStatusCliente: TfrmAlteracaoStatusCliente;

implementation

uses CadCliente, ModeloCadastro;

{$R *.dfm}

procedure TfrmAlteracaoStatusCliente.BtGravarClick(Sender: TObject);
begin
   if Trim(edtDescricao.Lines.Text) = '' then
   begin
      MessageDlg('É necessário informar uma justificativa', mtWarning, [mbOK], 0);
      edtDescricao.SetFocus;
      Exit;
   end;
   
   descricao_auditoria := 'JUSTIFICOU UMA ALTERAÇÃO NO CADASTRO DO CLIENTE ' + frmCadCliente.TbPrincipal.FieldByName('COD_CLIENTE').AsString + ' ' + frmCadCliente.TbPrincipal.FieldByName('RAZAOSOCIAL').AsString;
   qrAlteracaoStatus.FieldByName('COMENTARIO').Value := 'ALTERAÇÃO PARA O STATUS '+frmCadCliente.qrStatus.FieldByName('DESCRICAO').AsString + #13 + edtDescricao.Text; 
   GravaAuditoria(False,qrAlteracaoStatus);
   inherited;
   qrAlteracaoStatus.Post;
end;

procedure TfrmAlteracaoStatusCliente.BtCancelarClick(Sender: TObject);
begin
   inherited;
   qrAlteracaoStatus.Cancel;
   Close;
end;

procedure TfrmAlteracaoStatusCliente.edtDescricaoKeyPress(Sender: TObject;
  var Key: Char);
begin
  inherited;
   Key := UpCase(Key);
end;

procedure TfrmAlteracaoStatusCliente.FormCreate(Sender: TObject);
begin
   inherited;
   Chave_Tabela := 'COD_ALTERACAO_STATUS_CLIENTE';
end;

end.
