2014-06-27 15:30:39 +02:00
|
|
|
unit BusinessObjects;
|
|
|
|
|
|
|
|
interface
|
|
|
|
|
|
|
|
uses
|
2017-04-24 00:19:53 +02:00
|
|
|
MVCFramework.Serializer.Commons;
|
2014-06-27 15:30:39 +02:00
|
|
|
|
|
|
|
type
|
|
|
|
TBaseBO = class
|
|
|
|
private
|
|
|
|
FID: Integer;
|
|
|
|
procedure SetID(const Value: Integer);
|
|
|
|
public
|
|
|
|
procedure CheckInsert; virtual;
|
|
|
|
procedure CheckUpdate; virtual;
|
|
|
|
procedure CheckDelete; virtual;
|
|
|
|
property ID: Integer read FID write SetID;
|
|
|
|
end;
|
|
|
|
|
2017-04-24 00:19:53 +02:00
|
|
|
[MVCNameCase(ncLowerCase)]
|
2014-06-27 15:30:39 +02:00
|
|
|
TArticle = class(TBaseBO)
|
|
|
|
private
|
|
|
|
FPrice: Currency;
|
|
|
|
FCode: string;
|
|
|
|
FDescription: string;
|
|
|
|
procedure SetCode(const Value: string);
|
|
|
|
procedure SetDescription(const Value: string);
|
|
|
|
procedure SetPrice(const Value: Currency);
|
|
|
|
public
|
2014-06-30 12:32:43 +02:00
|
|
|
procedure CheckInsert; override;
|
|
|
|
procedure CheckUpdate; override;
|
2014-06-27 15:30:39 +02:00
|
|
|
procedure CheckDelete; override;
|
2017-04-24 00:19:53 +02:00
|
|
|
[MVCColumn('CODICE')]
|
2014-06-27 15:30:39 +02:00
|
|
|
property Code: string read FCode write SetCode;
|
2017-04-24 00:19:53 +02:00
|
|
|
[MVCColumn('DESCRIZIONE')]
|
2014-06-27 15:30:39 +02:00
|
|
|
property Description: string read FDescription write SetDescription;
|
2017-04-24 00:19:53 +02:00
|
|
|
[MVCColumn('PREZZO')]
|
2014-06-27 15:30:39 +02:00
|
|
|
property Price: Currency read FPrice write SetPrice;
|
|
|
|
end;
|
|
|
|
|
|
|
|
implementation
|
|
|
|
|
|
|
|
uses
|
|
|
|
System.SysUtils;
|
|
|
|
|
|
|
|
{ TBaseBO }
|
|
|
|
|
|
|
|
procedure TBaseBO.CheckDelete;
|
|
|
|
begin
|
|
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TBaseBO.CheckInsert;
|
|
|
|
begin
|
|
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TBaseBO.CheckUpdate;
|
|
|
|
begin
|
|
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TBaseBO.SetID(const Value: Integer);
|
|
|
|
begin
|
|
|
|
FID := Value;
|
|
|
|
end;
|
|
|
|
|
|
|
|
{ TArticolo }
|
|
|
|
|
|
|
|
procedure TArticle.CheckDelete;
|
|
|
|
begin
|
|
|
|
inherited;
|
2017-02-04 23:43:06 +01:00
|
|
|
// if Price > 0 then
|
|
|
|
// raise Exception.Create('Cannot delete an article with a price greater than 0 (yes, it is a silly check)');
|
2014-06-27 15:30:39 +02:00
|
|
|
end;
|
|
|
|
|
2014-06-30 12:32:43 +02:00
|
|
|
procedure TArticle.CheckInsert;
|
|
|
|
begin
|
|
|
|
inherited;
|
|
|
|
if length(Code) < 3 then
|
|
|
|
raise Exception.Create('Article code cannot be less than 3 chars');
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TArticle.CheckUpdate;
|
|
|
|
begin
|
|
|
|
inherited;
|
|
|
|
if length(Code) < 3 then
|
|
|
|
raise Exception.Create('Article code cannot be less than 3 chars');
|
|
|
|
end;
|
|
|
|
|
2014-06-27 15:30:39 +02:00
|
|
|
procedure TArticle.SetCode(const Value: string);
|
|
|
|
begin
|
|
|
|
FCode := Value;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TArticle.SetDescription(const Value: string);
|
|
|
|
begin
|
|
|
|
FDescription := Value;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TArticle.SetPrice(const Value: Currency);
|
|
|
|
begin
|
|
|
|
FPrice := Value;
|
|
|
|
end;
|
|
|
|
|
|
|
|
end.
|