A Unit com a Interface IValidator
Código:
interface
uses
SysUtils, Windows, Messages, Classes, Graphics, Controls, Forms, Dialogs,
clsDocumento, IPluginUnit;
type
TOnErrorValidate = procedure (FieldName: String) of object;
TNotifyValidate = procedure (Documento: TDocumentoNovo) of object;
IValidator = interface(IPlugin)
['{A9688CA1-4117-42D7-A790-60B950B2D264}']
function GetOnAfterValidate: TNotifyValidate;
function GetOnBeforeValidate: TNotifyValidate;
function GetOnErrorValidate: TOnErrorValidate;
procedure SetOnBeforeValidate(const Value: TNotifyValidate);
procedure SetOnAfterValidate(const Value: TNotifyValidate);
procedure SetOnErrorValidate(const Value: TOnErrorValidate);
procedure Validate(Documento: TDocumentoNovo);{overload;
procedure Validate(Documento: IDocument);overload;//Criado por Paulo }
property OnAfterValidate: TNotifyValidate read GetOnAfterValidate write
SetOnBeforeValidate;
property OnBeforeValidate: TNotifyValidate read GetOnBeforeValidate write
SetOnBeforeValidate;
property OnErrorValidate: TOnErrorValidate read GetOnErrorValidate write
SetOnErrorValidate;
end;
IteratorValidator = interface
['{33D0C0ED-91A4-468E-AF5B-A7E5B5C5DAC7}']
procedure First();
procedure Next();
function IsDone(): Boolean;
function CurrentItem: IValidator;
end;
IListValidator = interface
['{8F2F5645-3BC1-427D-89AC-A39C370AD957}']
function CreateIterator(): IteratorValidator;
procedure Add(Validator: IValidator);
procedure Delete(Index: Integer);
function Item(Index: integer): IValidator;
function Count(): integer;
end;
implementation
end.
A Unit onde está a classe TDocumentoNovo
Código:
type
TDocumentoNovo = class(TClassBase, IDocument)
private
FCod_Caixa: Integer;
FCodDocumento: Integer;
FCod_Etiqueta: Integer;
FCod_Usuario: Integer;
FComplemento: String;
FDataFinal: TDate;
FDataInicial: TDate;
FData_Digitacao: TDate;
FDescricao: String;
FPrevisaoExpurgo: TDate;
FSequencialFinal: Integer;
FSequencialInicial: Integer;
FDestroyTipoDocumento: Boolean;
FTipoDocumento: TTipoDocumento;
FDestroyCaixa: Boolean;
FCaixa: TCaixa;
FCodTipoDocumento: Integer;
FHasAutoComplete: Boolean;
FAuditoria_Interna: String;
FAnomalias: TListBase;
FListValor: TListBase;
FStatus: String;
FCod_Status: Integer;
FCod_xSolicitante: Integer;
FCarga: TCarga;
//Preferimos usar o Cod_Auditoria ao inves da Classe FAuditoria por quetão de tempo devido a urgencia de entrega
// que se se faz presente nesta data
//FAuditoria:TAuditoria;
//FDestroyAuditoria: Boolean;
FCod_Auditoria : integer;
FHashRegistro: String;
function GetCliente(): TCliente;
function GetLocal(): TLocal;
function GetDepartamento(): TDepartamento;
function GetComplemento: String;
function GetDataFinal: TDate;
function GetDataInicial: TDate;
function GetDescricao: String;
function GetSequencialFinal: Integer;
function GetSequencialInicial: Integer;
function getQuantidadeDigitacao: Integer;
procedure SetCod_Caixa(Value: Integer);
procedure SetCod_Documento(Value: Integer);
procedure SetCod_Usuario(Value: Integer);
procedure SetComplemento(const Value: String);
procedure SetDataFinal(Value: TDate);
procedure SetDataInicial(Value: TDate);
procedure SetData_Digitacao(Value: TDate);
procedure SetDescricao(const Value: String);
procedure SetPrevisaoExpurgo(Value: TDate);
procedure SetSequencialFinal(Value: Integer);
procedure SetSequencialInicial(Value: Integer);
//procedure SetCodTipoDocumento(Value: Integer);
function GetCodTipoDocumento: Integer;
function GetCodDocumento: Integer;
procedure SetCodDocumento(Value: Integer);
function GetHasAutoComplete: Boolean;
procedure SetHasAutoComplete(Value: Boolean);
procedure SetCaixa(const Value: TCaixa);
function GetCaixa: TCaixa;
procedure SetAuditoria_Interna(const Value: String);
function GetAnomalias: TListBase;
procedure SetAnomalias(Value: TListBase);
function GetStatus: String;
procedure SetStatus(const Value: String);
function getValorIndices(): TListBase;
function getTipoDocumento: TTipoDocumento;
procedure setTipoDocumento(const value: TTipoDocumento);
procedure SetCod_Status(const Value: Integer);
function GetCod_Status: Integer;
function GetAuditoria_Interna: String;
function GetCod_Caixa: Integer;
function GetCod_Etiqueta: Integer;
function GetCod_Usuario: Integer;
function GetData_Digitacao: TDate;
procedure SetCod_Etiqueta(const Value: Integer);
function GetCod_xSolicitante: Integer;
procedure SetCod_xSolicitante(Value: Integer);
function GetPrevisaoExpurgo: TDate;
function GetCarga: TCarga;
//function GetAuditoria: TAuditoria;
//procedure SetAuditoria(const Value: TAuditoria);
function GetCod_Auditoria: integer;
procedure SetCod_Auditoria(const Value: integer);
function getHashRegistro: String;
procedure setHashRegistro(const Value: String);
function QuantidadeDigitacaoCustomizavel: Integer;
public
constructor Create; override;
destructor Destroy; override;
procedure PopularValorIndice();
//Colocados aqui para nao serem lidas em tempo de execucao usando o metodo AssignPropertys
//pois causa Access Violation.
property Carga: TCarga read GetCarga;
property Cliente: TCliente read GetCliente;
property Local: TLocal read GetLocal;
property Departamento: TDepartamento read GetDepartamento;
property QuantidadeDigitacao: Integer read GetQuantidadeDigitacao;
property CodTipoDocumento: Integer read GetCodTipoDocumento;
published
property TipoDocumento: TTipoDocumento read GetTipoDocumento write SetTipoDocumento;
property Caixa: TCaixa read GetCaixa write SetCaixa;
property Cod_Caixa: Integer read GetCod_Caixa write SetCod_Caixa;
property CodDocumento: Integer read GetCodDocumento write SetCod_Documento;
property Cod_Etiqueta: Integer read GetCod_Etiqueta write SetCod_Etiqueta;
property Cod_Usuario: Integer read GetCod_Usuario write SetCod_Usuario;
property Complemento: String read GetComplemento write SetComplemento;
property DataFinal: TDate read GetDataFinal write SetDataFinal;
property DataInicial: TDate read GetDataInicial write SetDataInicial;
property Data_Digitacao: TDate read GetData_Digitacao write SetData_Digitacao;
property Descricao: String read GetDescricao write SetDescricao;
property PrevisaoExpurgo: TDate read GetPrevisaoExpurgo write
SetPrevisaoExpurgo;
property SequencialFinal: Integer read GetSequencialFinal write
SetSequencialFinal;
property SequencialInicial: Integer read GetSequencialInicial write
SetSequencialInicial;
property HasAutoComplete: Boolean read GetHasAutoComplete write SetHasAutoComplete;
property Auditoria_Interna: String read GetAuditoria_Interna write SetAuditoria_Interna;
property Anomalias: TListBase read GetAnomalias write SetAnomalias;
property Status: String read GetStatus write SetStatus;
property ValorIndices: TListBase read GetValorIndices;
property Cod_Status: Integer read GetCod_Status write SetCod_Status;
property Cod_xSolicitante: Integer read GetCod_xSolicitante write SetCod_xSolicitante;
//Preferimos usar o Cod_Auditoria ao inves da Classe FAuditoria por quetão de tempo devido a urgencia de entrega
// que se se faz presente nesta data
property Cod_Auditoria : integer read GetCod_Auditoria write SetCod_Auditoria;
property HashRegistro: String read getHashRegistro write setHashRegistro;
end;