git-svn-id: https://192.168.0.254/svn/Proyectos.EstudioCarnicero_ProGestion/trunk@4 1b8572a8-2d6b-b84e-8c90-20ed86fa4eca
240 lines
6.2 KiB
ObjectPascal
240 lines
6.2 KiB
ObjectPascal
unit uBizObraFinal;
|
|
|
|
interface
|
|
|
|
uses Controls, uDADataTable, uBizObra, uBizFacturasCliente, uBizRecibosCliente;
|
|
|
|
const
|
|
BIZ_OBRAFINAL = 'IBizObraFinal';
|
|
BIZ_FACTURASOBRAS = 'IBizFacturasObras';
|
|
BIZ_RECIBOSOBRAS = 'IBizRecibosObras';
|
|
|
|
type
|
|
IBizObraFinal = Interface; //Se declara después
|
|
|
|
IBizFacturasObras = interface(IBizFacturasCliente)
|
|
['{A1260299-841D-4664-86C0-7FB18B0245D8}']
|
|
function GetObra: IBizObraFinal;
|
|
procedure SetObra(const Value: IBizObraFinal);
|
|
property Obra: IBizObraFinal read GetObra write SetObra;
|
|
end;
|
|
|
|
IBizRecibosObras = interface(IBizRecibosCliente)
|
|
['{C530C195-1578-4509-82C3-CBB0C75CA548}']
|
|
function GetObra: IBizObraFinal;
|
|
procedure SetObra(const Value: IBizObraFinal);
|
|
property Obra: IBizObraFinal read GetObra write SetObra;
|
|
end;
|
|
|
|
IBizObraFinal = interface(IBizObra)
|
|
['{CB53EF43-54AF-42D7-8D9E-663CE8FBE2C0}']
|
|
function GetFacturas: IBizFacturasObras;
|
|
procedure SetFacturas(const Value: IBizFacturasObras);
|
|
property Facturas: IBizFacturasObras read GetFacturas write SetFacturas;
|
|
|
|
function GetRecibos: IBizRecibosObras;
|
|
procedure SetRecibos(const Value: IBizRecibosObras);
|
|
property Recibos: IBizRecibosObras read GetRecibos write SetRecibos;
|
|
|
|
function ShowForSelect : TModalResult;
|
|
end;
|
|
|
|
|
|
TBizObraFinal = class(TBizObraDataTableRules, IBizObraFinal)
|
|
protected
|
|
FFacturas: IBizFacturasObras;
|
|
FRecibos: IBizRecibosObras;
|
|
FCodigoObraFacturas : Integer;
|
|
FCodigoObraRecibos : Integer;
|
|
function GetFacturas: IBizFacturasObras;
|
|
procedure SetFacturas(const Value: IBizFacturasObras);
|
|
function GetRecibos: IBizRecibosObras;
|
|
procedure SetRecibos(const Value: IBizRecibosObras);
|
|
public
|
|
property Facturas: IBizFacturasObras read GetFacturas write SetFacturas;
|
|
property Recibos: IBizRecibosObras read GetRecibos write SetRecibos;
|
|
function ShowForSelect : TModalResult;
|
|
constructor Create(aDataTable: TDADataTable); override;
|
|
end;
|
|
|
|
TBizFacturasObras = class(TBizFacturasCliente, IBizFacturasObras)
|
|
private
|
|
FObra: IBizObraFinal;
|
|
protected
|
|
function GetObra: IBizObraFinal;
|
|
procedure SetObra(const Value: IBizObraFinal);
|
|
procedure OnNewRecord(Sender: TDADataTable); override;
|
|
public
|
|
property Obra: IBizObraFinal read GetObra write SetObra;
|
|
procedure Show; override;
|
|
end;
|
|
|
|
TBizRecibosObras = class(TBizRecibosCliente, IBizRecibosObras)
|
|
private
|
|
FObra: IBizObraFinal;
|
|
protected
|
|
function GetObra: IBizObraFinal;
|
|
procedure SetObra(const Value: IBizObraFinal);
|
|
procedure OnNewRecord(Sender: TDADataTable); override;
|
|
public
|
|
property Obra: IBizObraFinal read GetObra write SetObra;
|
|
procedure Show; override;
|
|
end;
|
|
|
|
implementation
|
|
|
|
uses
|
|
DB, Variants, uEditorUtils, schFacturasClienteClient_Intf, uDataModuleObrasFinal;
|
|
|
|
|
|
{ TBizFacturasObras }
|
|
function TBizFacturasObras.GetObra: IBizObraFinal;
|
|
begin
|
|
if not Assigned(FObra) then
|
|
FObra := dmObrasFinal.GetObraItem(CODIGOOBRA)
|
|
else
|
|
if (CODIGOOBRA <> FObra.Codigo) and
|
|
not (FObra.DataTable.State in dsEditModes) then
|
|
FObra := dmObrasFinal.GetObraItem(CODIGOOBRA);
|
|
|
|
if not FObra.DataTable.Active then
|
|
FObra.DataTable.Active := True;
|
|
|
|
Result := FObra;
|
|
end;
|
|
|
|
procedure TBizFacturasObras.OnNewRecord(Sender: TDADataTable);
|
|
begin
|
|
inherited;
|
|
CLASEFACTURA := CTE_NORMAL;
|
|
PAGADA := SITUACION_PENDIENTE;
|
|
setReferencia(CTE_NORMAL);
|
|
end;
|
|
|
|
procedure TBizFacturasObras.SetObra(const Value: IBizObraFinal);
|
|
var
|
|
bEnEdicion : Boolean;
|
|
begin
|
|
bEnEdicion := (DataTable.State in dsEditModes);
|
|
if not bEnEdicion then
|
|
Edit;
|
|
FObra := Value;
|
|
if Assigned(FObra) then
|
|
begin
|
|
CODIGOOBRA := FObra.CODIGO;
|
|
Cliente := FObra.Cliente;
|
|
Post;
|
|
|
|
if bEnEdicion then
|
|
Edit;
|
|
end
|
|
end;
|
|
|
|
procedure TBizFacturasObras.Show;
|
|
begin
|
|
//inherited;
|
|
ShowEditor(IBizFacturasObras, Self, etItem);
|
|
end;
|
|
|
|
{ TBizObraFinal }
|
|
|
|
constructor TBizObraFinal.Create(aDataTable: TDADataTable);
|
|
begin
|
|
inherited;
|
|
FCodigoObraFacturas := -1;
|
|
FCodigoObraRecibos := -1;
|
|
end;
|
|
|
|
function TBizObraFinal.GetFacturas: IBizFacturasObras;
|
|
begin
|
|
if (not Assigned(FFacturas)) or (CODIGO <> FCodigoObraFacturas) then
|
|
begin
|
|
FCodigoObraFacturas := CODIGO;
|
|
FFacturas := dmObrasFinal.GetFacturasItems(FCodigoObraFacturas)
|
|
end;
|
|
Result := FFacturas;
|
|
end;
|
|
|
|
function TBizObraFinal.GetRecibos: IBizRecibosObras;
|
|
begin
|
|
if (not Assigned(FRecibos)) or (CODIGO <> FCodigoObraRecibos) then
|
|
begin
|
|
FCodigoObraRecibos := CODIGO;
|
|
FRecibos := dmObrasFinal.GetRecibosItems(FCodigoObraRecibos)
|
|
end;
|
|
Result := FRecibos;
|
|
end;
|
|
|
|
procedure TBizObraFinal.SetFacturas(const Value: IBizFacturasObras);
|
|
begin
|
|
FFacturas := Value;
|
|
end;
|
|
|
|
procedure TBizObraFinal.SetRecibos(const Value: IBizRecibosObras);
|
|
begin
|
|
FRecibos := Value;
|
|
end;
|
|
|
|
function TBizObraFinal.ShowForSelect: TModalResult;
|
|
begin
|
|
Result := ShowEditor(IBizObraFinal, Self, etSelectItem);
|
|
end;
|
|
|
|
{ TBizRecibosObras }
|
|
|
|
function TBizRecibosObras.GetObra: IBizObraFinal;
|
|
begin
|
|
if not Assigned(FObra) then
|
|
FObra := dmObrasFinal.GetObraItem(CODIGOOBRA)
|
|
else
|
|
if (CODIGOOBRA <> FObra.Codigo) and
|
|
not (FObra.DataTable.State in dsEditModes) then
|
|
FObra := dmObrasFinal.GetObraItem(CODIGOOBRA);
|
|
|
|
if not FObra.DataTable.Active then
|
|
FObra.DataTable.Active := True;
|
|
|
|
Result := FObra;
|
|
end;
|
|
|
|
procedure TBizRecibosObras.OnNewRecord(Sender: TDADataTable);
|
|
begin
|
|
inherited;
|
|
//
|
|
end;
|
|
|
|
procedure TBizRecibosObras.SetObra(const Value: IBizObraFinal);
|
|
var
|
|
bEnEdicion : Boolean;
|
|
begin
|
|
bEnEdicion := (DataTable.State in dsEditModes);
|
|
if not bEnEdicion then
|
|
Edit;
|
|
FObra := Value;
|
|
if Assigned(FObra) then
|
|
begin
|
|
CODIGOOBRA := FObra.CODIGO;
|
|
Cliente := FObra.Cliente;
|
|
Post;
|
|
|
|
if bEnEdicion then
|
|
Edit;
|
|
end
|
|
end;
|
|
|
|
procedure TBizRecibosObras.Show;
|
|
begin
|
|
//inherited;
|
|
ShowEditor(IBizRecibosObras, Self, etItem);
|
|
end;
|
|
|
|
initialization
|
|
RegisterDataTableRules(BIZ_OBRAFINAL, TBizObraFinal);
|
|
RegisterDataTableRules(BIZ_FACTURASOBRAS, TBizFacturasObras);
|
|
RegisterDataTableRules(BIZ_RECIBOSOBRAS, TBizRecibosObras);
|
|
|
|
finalization
|
|
|
|
end.
|
|
|