git-svn-id: https://192.168.0.254/svn/Proyectos.Tecsitel_FactuGES2/trunk@447 0c75b7a4-871f-7646-8a2f-f78d34cc349f
151 lines
3.8 KiB
ObjectPascal
151 lines
3.8 KiB
ObjectPascal
unit uBizArticulos;
|
||
|
||
interface
|
||
|
||
uses
|
||
uDAInterfaces, uDADataTable, schArticulosClient_Intf, uDBSelectionListUtils;
|
||
|
||
const
|
||
BIZ_CLIENT_ARTICULO = 'Client.Articulo';
|
||
CTE_PARAM_TIEMPO = 0.5;
|
||
|
||
type
|
||
IBizArticulo = interface(IArticulos)
|
||
['{06AB61B1-C225-4791-9F5E-00A60DBA7FFD}']
|
||
function EsNuevo : Boolean;
|
||
function HayImagen: Boolean;
|
||
procedure SalvarImagen(const AFileName: String);
|
||
procedure CargarImagen(const AFileName: String);
|
||
procedure QuitarImagen;
|
||
end;
|
||
|
||
TBizArticulo = class(TArticulosDataTableRules, IBizArticulo, ISeleccionable)
|
||
protected
|
||
FSeleccionableInterface : ISeleccionable;
|
||
procedure OnNewRecord(Sender: TDADataTable); override;
|
||
procedure PARAMETROSPRECIOOnChange(Sender: TDACustomField);
|
||
|
||
public
|
||
procedure IniciarValoresArticuloNuevo; virtual;
|
||
function HayImagen: Boolean;
|
||
procedure SalvarImagen(const AFileName: String);
|
||
procedure CargarImagen(const AFileName: String);
|
||
procedure QuitarImagen;
|
||
function EsNuevo : Boolean;
|
||
constructor Create(aDataTable: TDADataTable); override;
|
||
destructor Destroy; override;
|
||
property SeleccionableInterface : ISeleccionable read FSeleccionableInterface
|
||
write FSeleccionableInterface implements ISeleccionable;
|
||
end;
|
||
|
||
implementation
|
||
|
||
uses
|
||
uFactuGES_App, uDataTableUtils, SysUtils, uROClasses, Classes;
|
||
|
||
{ TBizArticulo }
|
||
|
||
procedure TBizArticulo.CargarImagen(const AFileName: String);
|
||
begin
|
||
{ inherited;
|
||
DataTable.Edit;
|
||
DataTable.FieldByName(fld_ArticulosIMAGEN).LoadFromFile(AFileName);
|
||
DataTable.Post;}
|
||
end;
|
||
|
||
constructor TBizArticulo.Create(aDataTable: TDADataTable);
|
||
begin
|
||
inherited;
|
||
|
||
with aDataTable do
|
||
begin
|
||
FieldByName(fld_ArticulosTIEMPO).OnChange := PARAMETROSPRECIOOnChange;
|
||
FieldByName(fld_ArticulosPARAM_TIEMPO).OnChange := PARAMETROSPRECIOOnChange;
|
||
FieldByName(fld_ArticulosPRECIO_NETO).OnChange := PARAMETROSPRECIOOnChange;
|
||
FieldByName(fld_ArticulosPRECIO_PORTE).OnChange := PARAMETROSPRECIOOnChange;
|
||
end;
|
||
|
||
FSeleccionableInterface := TSeleccionable.Create(aDataTable);
|
||
end;
|
||
|
||
destructor TBizArticulo.Destroy;
|
||
begin
|
||
FSeleccionableInterface := NIL;
|
||
inherited;
|
||
end;
|
||
|
||
function TBizArticulo.EsNuevo: Boolean;
|
||
begin
|
||
Result := (ID < 0);
|
||
end;
|
||
|
||
function TBizArticulo.HayImagen: Boolean;
|
||
{var
|
||
AStream : TMemoryStream;
|
||
AROStream : IROStream;}
|
||
begin
|
||
{ AStream := TMemoryStream.Create;
|
||
AROStream := TROStream.Create(AStream, False);
|
||
try
|
||
DataTable.FieldByName(fld_ArticulosIMAGEN).SaveToStream(AROStream);
|
||
Result := (AROStream.Size > 0);
|
||
finally
|
||
AROStream := NIL;
|
||
FreeAndNIL(AStream);
|
||
end;}
|
||
end;
|
||
|
||
procedure TBizArticulo.IniciarValoresArticuloNuevo;
|
||
begin
|
||
ID_EMPRESA := AppFactuGES.EmpresaActiva.ID;
|
||
PRECIO_PORTE := 0;
|
||
PRECIO_COSTE := 0;
|
||
DESCUENTO := 0;
|
||
PRECIO_NETO := 0;
|
||
COMISIONABLE := 1;
|
||
ELIMINADO := 0;
|
||
USUARIO := AppFactuGES.UsuarioActivo.UserName;
|
||
end;
|
||
|
||
procedure TBizArticulo.OnNewRecord(Sender: TDADataTable);
|
||
begin
|
||
inherited;
|
||
// ID := GetRecNo; // -1, -2, -3...
|
||
INVENTARIABLE := 1;
|
||
PARAM_TIEMPO := CTE_PARAM_TIEMPO;
|
||
IniciarValoresArticuloNuevo;
|
||
end;
|
||
|
||
procedure TBizArticulo.PARAMETROSPRECIOOnChange(Sender: TDACustomField);
|
||
begin
|
||
if not Self.DataTable.Editing then
|
||
Edit;
|
||
|
||
if (TIEMPO = 0) or (PARAM_TIEMPO = 0) then
|
||
MANO_OBRA := 0
|
||
else
|
||
MANO_OBRA := TIEMPO * PARAM_TIEMPO;
|
||
|
||
PRECIO_PVP := PRECIO_NETO + PRECIO_PORTE + MANO_OBRA;
|
||
end;
|
||
|
||
procedure TBizArticulo.QuitarImagen;
|
||
begin
|
||
{ DataTable.Edit;
|
||
DataTable.Fields[idx_ArticulosIMAGEN].Clear;
|
||
DataTable.Post;}
|
||
end;
|
||
|
||
procedure TBizArticulo.SalvarImagen(const AFileName: String);
|
||
begin
|
||
// DataTable.FieldByName(fld_ArticulosIMAGEN).SaveToFile(AFileName);
|
||
end;
|
||
|
||
initialization
|
||
RegisterDataTableRules(BIZ_CLIENT_ARTICULO, TBizArticulo);
|
||
|
||
finalization
|
||
|
||
end.
|
||
|
||
|