2007-10-26 18:19:55 +00:00
unit uDetallesPresupuestoClienteController;
interface
uses
uDADataTable, uControllerDetallesArticulos, uBizDetallesPresupuestoCliente, uIDataModulePresupuestosCliente,
uBizArticulos, uBizContactos;
type
IDetallesPresupuestoClienteController = interface( IControllerDetallesArticulos)
[ '{8D1D3559-E695-4962-9999-404B26B50D6C}' ]
procedure AnadirArticulos( ADetalles: IDAStronglyTypedDataTable; ACliente: IBizCliente) ; overload ;
procedure ActualizarDetalles( ADetalles: IDAStronglyTypedDataTable; ACliente: IBizCliente) ; overload ;
procedure DesglosarPorteDetalles( ImportePorte: Currency ; ADetalles: IDAStronglyTypedDataTable) ;
function DarTotalPorteTotal( ADetalles: IDAStronglyTypedDataTable) : Double ;
end ;
TDetallesPresupuestoClienteController = class( TControllerDetallesArticulos, IDetallesPresupuestoClienteController)
private
FDataModule : IDataModulePresupuestosCliente;
protected
2007-11-05 17:49:11 +00:00
// procedure AsignarDatos(ADetalles: IDAStronglyTypedDataTable; IDCabecera: Integer); override;
2007-10-26 18:19:55 +00:00
procedure RellenarOtros( ADetalles: IDAStronglyTypedDataTable; AArticulos: IBizArticulo) ; overload ; override ;
procedure RellenarImportes( ADetalles: IDAStronglyTypedDataTable; AArticulos: IBizArticulo) ; override ;
procedure AsignarController; override ;
//Si sobreescribimos este m<> todo podremos tener en cuenta otras columnas para el calculo del importe total de un concepto
function CalcularImporteTotalConcepto( DataTable: TDADataTable) : Double ; override ;
procedure ValidarCampos( DataTable: TDADataTable) ; override ;
procedure DesglosarPorteDetalles( ImportePorte: Currency ; ADetalles: IDAStronglyTypedDataTable) ;
function DarTotalPorteTotal( ADetalles: IDAStronglyTypedDataTable) : Double ;
public
procedure AnadirArticulos( ADetalles: IDAStronglyTypedDataTable; ACliente: IBizCliente) ; reintroduce ; overload ;
procedure ActualizarDetalles( ADetalles: IDAStronglyTypedDataTable; ACliente: IBizCliente) ; overload ;
constructor Create; override ;
destructor Destroy; override ;
end ;
implementation
uses Dialogs, uDialogUtils, Variants, uControllerDetallesBase, uDataModulePresupuestosCliente, uArticulosPresupuestoClienteController,
uDataTableUtils, uCalculosUtils;
{ TDetallesPresupuestoClienteController }
procedure TDetallesPresupuestoClienteController. ActualizarDetalles( ADetalles: IDAStronglyTypedDataTable; ACliente: IBizCliente) ;
var
AArticulos : IBizArticulo;
begin
if Assigned( ADetalles) then
begin
try
AArticulos : = ( FArticulosController. BuscarTodos( ACliente) as IBizArticulo) ;
ActualizarDetalles( ADetalles, AArticulos) ;
ShowInfoMessage( 'Se han actualizado los descuentos para el cliente seleccionado' ) ;
finally
AArticulos : = Nil ;
end ;
end ;
end ;
procedure TDetallesPresupuestoClienteController. AnadirArticulos( ADetalles: IDAStronglyTypedDataTable; ACliente: IBizCliente) ;
var
AArticulos: IBizArticulo;
begin
if Assigned( ADetalles) then
begin
try
AArticulos : = ( FArticulosController. BuscarTodos( ACliente) as IBizArticulo) ;
AArticulos : = ( FArticulosController as IArticulosPresupuestoClienteController) . ElegirArticulos( AArticulos, 'Elija los art<72> culos que desea a<> adir a este pedido de cliente' , True ) ;
Add( ADetalles, AArticulos) ;
finally
AArticulos : = Nil ;
end ;
end ;
end ;
procedure TDetallesPresupuestoClienteController. AsignarController;
begin
FArticulosController : = TArticulosPresupuestoClienteController. Create;
end ;
2007-11-05 17:49:11 +00:00
{
2007-10-26 18:19:55 +00:00
procedure TDetallesPresupuestoClienteController. AsignarDatos( ADetalles: IDAStronglyTypedDataTable; IDCabecera: Integer ) ;
begin
inherited ;
with ( ADetalles as IBizDetallesPresupuestoCliente) do
begin
Edit;
ID : = FDataModule. GetNextID( DataTable. LogicalName) ;
ID_PEDIDO : = IDCabecera;
Post
end ;
end ;
2007-11-05 17:49:11 +00:00
}
2007-10-26 18:19:55 +00:00
function TDetallesPresupuestoClienteController. CalcularImporteTotalConcepto( DataTable: TDADataTable) : Double ;
begin
Result : = CalcularLineaConcepto( DataTable) ;
end ;
constructor TDetallesPresupuestoClienteController. Create;
begin
inherited ;
FDataModule : = TDataModulePresupuestosCliente. Create( Nil ) ;
end ;
function TDetallesPresupuestoClienteController. DarTotalPorteTotal( ADetalles: IDAStronglyTypedDataTable) : Double ;
begin
Result : = DarTotalPorte( ADetalles) ;
end ;
procedure TDetallesPresupuestoClienteController. DesglosarPorteDetalles( ImportePorte: Currency ; ADetalles: IDAStronglyTypedDataTable) ;
begin
DesglosarPorte( ImportePorte, ADetalles) ;
ActualizarTotales( ADetalles) ;
end ;
destructor TDetallesPresupuestoClienteController. Destroy;
begin
FDataModule : = Nil ;
inherited ;
end ;
procedure TDetallesPresupuestoClienteController. RellenarOtros( ADetalles: IDAStronglyTypedDataTable; AArticulos: IBizArticulo) ;
begin
if Assigned( AArticulos) then
ADetalles. DataTable. FieldByName( CAMPO_DESCUENTO) . AsFloat : = AArticulos. DESCUENTO
else
ADetalles. DataTable. FieldByName( CAMPO_DESCUENTO) . AsFloat : = 0 ;
end ;
procedure TDetallesPresupuestoClienteController. ValidarCampos( DataTable: TDADataTable) ;
begin
inherited ;
ValidarCamposLineaConcepto( DataTable) ;
end ;
procedure TDetallesPresupuestoClienteController. RellenarImportes( ADetalles: IDAStronglyTypedDataTable; AArticulos: IBizArticulo) ;
begin
if Assigned( AArticulos) then
ADetalles. DataTable. FieldByName( CAMPO_IMPORTE_UNIDAD) . AsVariant : = AArticulos. PRECIO_COSTE
else
ADetalles. DataTable. FieldByName( CAMPO_IMPORTE_UNIDAD) . AsVariant : = Null;
end ;
end .