323 lines
11 KiB
ObjectPascal
323 lines
11 KiB
ObjectPascal
|
|
unit uViewAlbaranCliente;
|
|||
|
|
|
|||
|
|
interface
|
|||
|
|
|
|||
|
|
uses
|
|||
|
|
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
|||
|
|
Dialogs, uViewBase, uBizAlbaranesCliente, DB, uDADataTable, uCustomView,
|
|||
|
|
AppEvnts, StdCtrls, Mask, DBCtrls,
|
|||
|
|
|
|||
|
|
uViewObservaciones, uViewDatosYSeleccionCliente,
|
|||
|
|
cxGraphics, cxDropDownEdit, cxImageComboBox, cxDBEdit, cxContainer, cxEdit,
|
|||
|
|
cxTextEdit, cxMaskEdit, cxCalendar, dxLayoutControl, cxControls, cxMemo,
|
|||
|
|
uViewDireccionEntregaAlbaranCliente, Buttons, ActnList, uBizPedidosCliente,
|
|||
|
|
uPedidosClienteController, ExtCtrls, cxLookupEdit, cxDBLookupEdit,
|
|||
|
|
cxDBLookupComboBox, uFormasPagoController, uAlmacenesController;
|
|||
|
|
|
|||
|
|
type
|
|||
|
|
IViewAlbaranCliente = interface(IViewBase)
|
|||
|
|
['{F4946DFE-B64C-47C8-96D6-24549E6DAC11}']
|
|||
|
|
function GetAlbaran: IBizAlbaranCliente;
|
|||
|
|
procedure SetAlbaran(const Value: IBizAlbaranCliente);
|
|||
|
|
property Albaran: IBizAlbaranCliente read GetAlbaran write SetAlbaran;
|
|||
|
|
|
|||
|
|
function GetViewClienteAlbaran: TfrViewDatosYSeleccionCliente;
|
|||
|
|
procedure SetViewClienteAlbaran(const Value: TfrViewDatosYSeleccionCliente);
|
|||
|
|
property ViewClienteAlbaran: TfrViewDatosYSeleccionCliente read GetViewClienteAlbaran write SetViewClienteAlbaran;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
TfrViewAlbaranCliente = class(TfrViewBase, IViewAlbaranCliente)
|
|||
|
|
DADataSource: TDADataSource;
|
|||
|
|
dxLayoutControl1Group_Root: TdxLayoutGroup;
|
|||
|
|
dxLayoutControl1: TdxLayoutControl;
|
|||
|
|
dxLayoutControl1Item2: TdxLayoutItem;
|
|||
|
|
edtFechaAlbaran: TcxDBDateEdit;
|
|||
|
|
dxLayoutControl1Group1: TdxLayoutGroup;
|
|||
|
|
dxLayoutControl1Group2: TdxLayoutGroup;
|
|||
|
|
dxLayoutControl1Item6: TdxLayoutItem;
|
|||
|
|
memObservaciones: TcxDBMemo;
|
|||
|
|
dxLayoutControl1Item3: TdxLayoutItem;
|
|||
|
|
eReferencia: TcxDBTextEdit;
|
|||
|
|
dxLayoutControl1Group6: TdxLayoutGroup;
|
|||
|
|
dxLayoutControl1Group7: TdxLayoutGroup;
|
|||
|
|
dxLayoutControl1Group8: TdxLayoutGroup;
|
|||
|
|
dxLayoutControl1Group3: TdxLayoutGroup;
|
|||
|
|
dxLayoutControl1Item1: TdxLayoutItem;
|
|||
|
|
frViewClienteAlbaran: TfrViewDatosYSeleccionCliente;
|
|||
|
|
dxLayoutControl1Item8: TdxLayoutItem;
|
|||
|
|
eCalle: TcxDBTextEdit;
|
|||
|
|
dxLayoutControl1Item9: TdxLayoutItem;
|
|||
|
|
ePoblacion: TcxDBTextEdit;
|
|||
|
|
dxLayoutControl1Item10: TdxLayoutItem;
|
|||
|
|
eCodigoPostal: TcxDBTextEdit;
|
|||
|
|
dxLayoutControl1Item11: TdxLayoutItem;
|
|||
|
|
eProvincia: TcxDBTextEdit;
|
|||
|
|
dxLayoutControl1Item12: TdxLayoutItem;
|
|||
|
|
ePersonaContacto: TcxDBTextEdit;
|
|||
|
|
dxLayoutControl1Item13: TdxLayoutItem;
|
|||
|
|
eTlfTrabajo: TcxDBTextEdit;
|
|||
|
|
dxLayoutControl1Group4: TdxLayoutGroup;
|
|||
|
|
dxLayoutControl1Group9: TdxLayoutGroup;
|
|||
|
|
dxLayoutControl1Item14: TdxLayoutItem;
|
|||
|
|
bElegirDireccion: TBitBtn;
|
|||
|
|
ActionList1: TActionList;
|
|||
|
|
actElegirDireccion: TAction;
|
|||
|
|
Button1: TButton;
|
|||
|
|
dxLayoutControl1Item5: TdxLayoutItem;
|
|||
|
|
actVerPedidoCli: TAction;
|
|||
|
|
eReferenciaPedidoCli: TcxTextEdit;
|
|||
|
|
dxLayoutControl1Item7: TdxLayoutItem;
|
|||
|
|
dxLayoutControl1Group5: TdxLayoutGroup;
|
|||
|
|
dxLayoutControl1Item4: TdxLayoutItem;
|
|||
|
|
cbFormaPago: TcxDBLookupComboBox;
|
|||
|
|
dxLayoutControl1Item15: TdxLayoutItem;
|
|||
|
|
bFormasPago: TButton;
|
|||
|
|
dsFormaPago: TDADataSource;
|
|||
|
|
dxLayoutControl1Group13: TdxLayoutGroup;
|
|||
|
|
dxLayoutControl1Group14: TdxLayoutGroup;
|
|||
|
|
dxLayoutControl1Item16: TdxLayoutItem;
|
|||
|
|
eFechaRecepcion: TcxDBDateEdit;
|
|||
|
|
dxLayoutControl1Group11: TdxLayoutGroup;
|
|||
|
|
dxLayoutControl1Item17: TdxLayoutItem;
|
|||
|
|
eFechaEnvio: TcxDBTextEdit;
|
|||
|
|
dxLayoutControl1Item19: TdxLayoutItem;
|
|||
|
|
cbConAlmacen: TCheckBox;
|
|||
|
|
dxLayoutControl1Item20: TdxLayoutItem;
|
|||
|
|
cbAlmacen: TcxDBLookupComboBox;
|
|||
|
|
dsAlmacenes: TDADataSource;
|
|||
|
|
dxLayoutControl1Item18: TdxLayoutItem;
|
|||
|
|
Label1: TLabel;
|
|||
|
|
dxLayoutControl1Group12: TdxLayoutGroup;
|
|||
|
|
dxLayoutControl1Item21: TdxLayoutItem;
|
|||
|
|
cbFechaRecepcion: TCheckBox;
|
|||
|
|
dxLayoutControl1Group10: TdxLayoutGroup;
|
|||
|
|
dxLayoutControl1Item22: TdxLayoutItem;
|
|||
|
|
eRefFacturaCli: TcxDBTextEdit;
|
|||
|
|
dxLayoutControl1Group15: TdxLayoutGroup;
|
|||
|
|
dxLayoutControl1Item24: TdxLayoutItem;
|
|||
|
|
eFechaPrevista: TcxDBDateEdit;
|
|||
|
|
procedure CustomViewCreate(Sender: TObject);
|
|||
|
|
procedure CustomViewDestroy(Sender: TObject);
|
|||
|
|
procedure actElegirDireccionExecute(Sender: TObject);
|
|||
|
|
procedure actElegirDireccionUpdate(Sender: TObject);
|
|||
|
|
procedure actVerPedidoCliUpdate(Sender: TObject);
|
|||
|
|
procedure actVerPedidoCliExecute(Sender: TObject);
|
|||
|
|
procedure frViewClienteAlbaranactElegirContactoUpdate(Sender: TObject);
|
|||
|
|
procedure frViewClienteAlbaranactAnadirContactoUpdate(Sender: TObject);
|
|||
|
|
procedure bFormasPagoClick(Sender: TObject);
|
|||
|
|
procedure cbConAlmacenClick(Sender: TObject);
|
|||
|
|
procedure cbFechaRecepcionClick(Sender: TObject);
|
|||
|
|
protected
|
|||
|
|
FAlbaran : IBizAlbaranCliente;
|
|||
|
|
FAlmacenesController : IAlmacenesController;
|
|||
|
|
FPedidoAsociado : IBizPedidoCliente;
|
|||
|
|
FPedidoController : IPedidosClienteController;
|
|||
|
|
FViewClienteAlbaran : TfrViewDatosYSeleccionCliente;
|
|||
|
|
FFormasPagoController : IFormasPagoController;
|
|||
|
|
|
|||
|
|
function GetAlbaran: IBizAlbaranCliente;
|
|||
|
|
procedure SetAlbaran(const Value: IBizAlbaranCliente); virtual;
|
|||
|
|
function GetViewClienteAlbaran: TfrViewDatosYSeleccionCliente;
|
|||
|
|
procedure SetViewClienteAlbaran(const Value: TfrViewDatosYSeleccionCliente);
|
|||
|
|
public
|
|||
|
|
property Albaran: IBizAlbaranCliente read GetAlbaran write SetAlbaran;
|
|||
|
|
property ViewClienteAlbaran: TfrViewDatosYSeleccionCliente read GetViewClienteAlbaran;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
implementation
|
|||
|
|
|
|||
|
|
{$R *.dfm}
|
|||
|
|
|
|||
|
|
{ TfrViewAlbaranCliente }
|
|||
|
|
|
|||
|
|
uses
|
|||
|
|
uClientesController, uBizDireccionesContacto, uAlbaranesClienteController,
|
|||
|
|
schAlbaranesClienteClient_Intf, uBizFormasPago, uBizAlmacenes, uDateUtils;
|
|||
|
|
|
|||
|
|
|
|||
|
|
procedure TfrViewAlbaranCliente.actElegirDireccionExecute(Sender: TObject);
|
|||
|
|
var
|
|||
|
|
AClientesController : IClientesController;
|
|||
|
|
AAlbaranController : IAlbaranesClienteController;
|
|||
|
|
ADireccion : IBizDireccionesContacto;
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
AClientesController := TClientesController.Create;
|
|||
|
|
AAlbaranController := TAlbaranesClienteController.Create;
|
|||
|
|
try
|
|||
|
|
ADireccion := AClientesController.ElegirDireccionEntrega(FAlbaran.Cliente.Direcciones,
|
|||
|
|
'Seleccione la direcci<63>n del cliente que quiere utilizar como direcci<63>n de envio de este albaran.');
|
|||
|
|
if Assigned(ADireccion) then
|
|||
|
|
begin
|
|||
|
|
AAlbaranController.CopiarDireccionEnvio(ADireccion, FAlbaran);
|
|||
|
|
FAlbaran.Edit;
|
|||
|
|
FAlbaran.IMPORTE_PORTE := ADireccion.PORTE;
|
|||
|
|
end;
|
|||
|
|
finally
|
|||
|
|
AClientesController := NIL;
|
|||
|
|
AAlbaranController := NIL;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrViewAlbaranCliente.actElegirDireccionUpdate(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
(Sender as TAction).Enabled := Assigned(FAlbaran) and
|
|||
|
|
Assigned(FViewClienteAlbaran) and
|
|||
|
|
FAlbaran.DataTable.Active and
|
|||
|
|
Assigned(FAlbaran.Cliente) and
|
|||
|
|
Assigned(FAlbaran.Cliente) and
|
|||
|
|
Assigned(FAlbaran.Cliente.Direcciones) and
|
|||
|
|
FAlbaran.Cliente.Direcciones.DataTable.Active and
|
|||
|
|
(FAlbaran.Cliente.Direcciones.DataTable.RecordCount > 0);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrViewAlbaranCliente.actVerPedidoCliExecute(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
FPedidoController.Ver(FPedidoAsociado);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrViewAlbaranCliente.actVerPedidoCliUpdate(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
(Sender as TAction).Enabled := Assigned(FPedidoAsociado)
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrViewAlbaranCliente.bFormasPagoClick(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
FFormasPagoController.VerTodos((dsFormaPago.DataTable) as IBizFormaPago);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrViewAlbaranCliente.cbConAlmacenClick(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
if cbConAlmacen.Checked then
|
|||
|
|
begin
|
|||
|
|
cbAlmacen.Enabled := True;
|
|||
|
|
cbAlmacen.DroppedDown := True;
|
|||
|
|
end
|
|||
|
|
else begin
|
|||
|
|
cbAlmacen.Enabled := False;
|
|||
|
|
FAlbaran.Edit;
|
|||
|
|
FAlbaran.ID_ALMACEN := 0;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrViewAlbaranCliente.cbFechaRecepcionClick(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
if cbFechaRecepcion.Checked then
|
|||
|
|
begin
|
|||
|
|
eFechaRecepcion.Enabled := True;
|
|||
|
|
end
|
|||
|
|
else begin
|
|||
|
|
eFechaRecepcion.Enabled := False;
|
|||
|
|
FAlbaran.Edit;
|
|||
|
|
FAlbaran.FECHA_RECEPCION := 0;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrViewAlbaranCliente.CustomViewCreate(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
FFormasPagoController := TFormasPagoController.Create;
|
|||
|
|
FPedidoAsociado := NIL;
|
|||
|
|
FPedidoController := TPedidosClienteController.Create;
|
|||
|
|
FViewClienteAlbaran := frViewClienteAlbaran;
|
|||
|
|
FViewClienteAlbaran.MsgElegirCliente := 'Elija el cliente al que se le realizar<61> el Albaran.';
|
|||
|
|
FAlmacenesController := TAlmacenesController.Create;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrViewAlbaranCliente.CustomViewDestroy(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
FViewClienteAlbaran := Nil;
|
|||
|
|
FPedidoController := NIL;
|
|||
|
|
FFormasPagoController := NIL;
|
|||
|
|
FPedidoAsociado := NIL;
|
|||
|
|
FAlmacenesController := NIL;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrViewAlbaranCliente.frViewClienteAlbaranactAnadirContactoUpdate(
|
|||
|
|
Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
if Assigned(FPedidoAsociado) then
|
|||
|
|
(Sender as TAction).Enabled := False
|
|||
|
|
else
|
|||
|
|
inherited;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrViewAlbaranCliente.frViewClienteAlbaranactElegirContactoUpdate(
|
|||
|
|
Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
if Assigned(FPedidoAsociado) then
|
|||
|
|
(Sender as TAction).Enabled := False
|
|||
|
|
else
|
|||
|
|
inherited;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
function TfrViewAlbaranCliente.GetAlbaran: IBizAlbaranCliente;
|
|||
|
|
begin
|
|||
|
|
Result := FAlbaran;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
function TfrViewAlbaranCliente.GetViewClienteAlbaran: TfrViewDatosYSeleccionCliente;
|
|||
|
|
begin
|
|||
|
|
Result := FViewClienteAlbaran;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrViewAlbaranCliente.SetAlbaran(const Value: IBizAlbaranCliente);
|
|||
|
|
begin
|
|||
|
|
FAlbaran := Value;
|
|||
|
|
if Assigned(FAlbaran) then
|
|||
|
|
begin
|
|||
|
|
DADataSource.DataTable := FAlbaran.DataTable;
|
|||
|
|
frViewClienteAlbaran.Cliente := FAlbaran.Cliente;
|
|||
|
|
|
|||
|
|
dsFormaPago.DataTable := FFormasPagoController.BuscarTodos.DataTable;
|
|||
|
|
dsFormaPago.DataTable.Active := True;
|
|||
|
|
|
|||
|
|
dsAlmacenes.DataTable := (FAlmacenesController.BuscarTodos).DataTable;
|
|||
|
|
dsAlmacenes.DataTable.Active := True;
|
|||
|
|
|
|||
|
|
cbConAlmacen.Checked := (FAlbaran.ID_ALMACEN > 0);
|
|||
|
|
cbAlmacen.Enabled := cbConAlmacen.Checked;
|
|||
|
|
cbFechaRecepcion.Checked := not EsFechaVacia(FAlbaran.FECHA_RECEPCION);
|
|||
|
|
eFechaRecepcion.Enabled := cbFechaRecepcion.Checked;
|
|||
|
|
|
|||
|
|
eReferenciaPedidoCli.Enabled := False;
|
|||
|
|
eRefFacturaCli.Enabled := False;
|
|||
|
|
|
|||
|
|
FPedidoAsociado := NIL;
|
|||
|
|
if (FAlbaran.ID_PEDIDO > 0) then
|
|||
|
|
begin
|
|||
|
|
FPedidoAsociado := FPedidoController.Buscar(FAlbaran.ID_PEDIDO);
|
|||
|
|
if Assigned(FPedidoAsociado) then
|
|||
|
|
begin
|
|||
|
|
FPedidoAsociado.DataTable.Active := True;
|
|||
|
|
eReferenciaPedidoCli.Text := FPedidoAsociado.REFERENCIA
|
|||
|
|
end
|
|||
|
|
else
|
|||
|
|
eReferenciaPedidoCli.Text := '';
|
|||
|
|
end
|
|||
|
|
else
|
|||
|
|
eReferenciaPedidoCli.Text := 'No hay pedido asociado';
|
|||
|
|
end
|
|||
|
|
else begin
|
|||
|
|
DADataSource.DataTable := NIL;
|
|||
|
|
frViewClienteAlbaran.Cliente := nil;
|
|||
|
|
FPedidoAsociado := NIL;
|
|||
|
|
dsFormaPago.DataTable := NIL;
|
|||
|
|
dsAlmacenes.DataTable := NIL;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrViewAlbaranCliente.SetViewClienteAlbaran(const Value: TfrViewDatosYSeleccionCliente);
|
|||
|
|
begin
|
|||
|
|
FViewClienteAlbaran := Value;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
end.
|