386 lines
13 KiB
ObjectPascal
386 lines
13 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, uViewDatosYSeleccionClienteAlbaran,
|
|||
|
|
cxGraphics, cxDropDownEdit, cxImageComboBox, cxDBEdit, cxContainer, cxEdit,
|
|||
|
|
cxTextEdit, cxMaskEdit, cxCalendar, dxLayoutControl, cxControls, cxMemo,
|
|||
|
|
uViewDireccionEntregaAlbaranCliente, Buttons, ActnList,
|
|||
|
|
|
|||
|
|
// uBizPedidosCliente, uPedidosClienteController,
|
|||
|
|
|
|||
|
|
ExtCtrls, cxLookupEdit, cxDBLookupEdit, uBizFormasPago,
|
|||
|
|
cxDBLookupComboBox, uFormasPagoController, uAlmacenesController, uDAInterfaces,
|
|||
|
|
uViewTienda, uAlbaranesClienteController, uViewDatosYSeleccionCliente;
|
|||
|
|
|
|||
|
|
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: IViewDatosYSeleccionClienteAlbaran;
|
|||
|
|
property ViewClienteAlbaran: IViewDatosYSeleccionClienteAlbaran read GetViewClienteAlbaran;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
TfrViewAlbaranCliente = class(TfrViewBase, IViewAlbaranCliente)
|
|||
|
|
DADataSource: TDADataSource;
|
|||
|
|
dxLayoutControl1Group_Root: TdxLayoutGroup;
|
|||
|
|
dxLayoutControl1: TdxLayoutControl;
|
|||
|
|
dxLayoutControl1Item2: TdxLayoutItem;
|
|||
|
|
edtFechaAlbaran: TcxDBDateEdit;
|
|||
|
|
dxLayoutControl1Group1: TdxLayoutGroup;
|
|||
|
|
dxLayoutControl1Group2: TdxLayoutGroup;
|
|||
|
|
dxLayoutControl1Item3: TdxLayoutItem;
|
|||
|
|
eReferencia: TcxDBTextEdit;
|
|||
|
|
dxLayoutControl1Group6: TdxLayoutGroup;
|
|||
|
|
dxLayoutControl1Group7: TdxLayoutGroup;
|
|||
|
|
dxLayoutControl1Group8: TdxLayoutGroup;
|
|||
|
|
dxLayoutControl1Group3: TdxLayoutGroup;
|
|||
|
|
dxLayoutControl1Item1: TdxLayoutItem;
|
|||
|
|
frViewClienteAlbaran: TfrViewDatosYSeleccionClienteAlbaran;
|
|||
|
|
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;
|
|||
|
|
dxLayoutControl1Item19: TdxLayoutItem;
|
|||
|
|
cbConAlmacen: TCheckBox;
|
|||
|
|
dxLayoutControl1Item20: TdxLayoutItem;
|
|||
|
|
cbAlmacen: TcxDBLookupComboBox;
|
|||
|
|
dsAlmacenes: TDADataSource;
|
|||
|
|
dxLayoutControl1Item18: TdxLayoutItem;
|
|||
|
|
Label1: TLabel;
|
|||
|
|
dxLayoutControl1Group12: TdxLayoutGroup;
|
|||
|
|
dxLayoutControl1Group10: TdxLayoutGroup;
|
|||
|
|
dxLayoutControl1Item22: TdxLayoutItem;
|
|||
|
|
eRefFacturaCli: TcxDBTextEdit;
|
|||
|
|
dxLayoutControl1Group15: TdxLayoutGroup;
|
|||
|
|
dxLayoutControl1Item24: TdxLayoutItem;
|
|||
|
|
eFechaPrevista: TcxDBDateEdit;
|
|||
|
|
dxLayoutControl1Item23: TdxLayoutItem;
|
|||
|
|
eRefCliente: TcxDBTextEdit;
|
|||
|
|
dxLayoutControl1Item21: TdxLayoutItem;
|
|||
|
|
eFechaEnvio: TcxDBDateEdit;
|
|||
|
|
dxLayoutControl1Group17: TdxLayoutGroup;
|
|||
|
|
frViewTienda1: TfrViewTienda;
|
|||
|
|
dxLayoutControl1Item17: TdxLayoutItem;
|
|||
|
|
frViewObservaciones1: TfrViewObservaciones;
|
|||
|
|
dxLayoutControl1Item6: TdxLayoutItem;
|
|||
|
|
procedure CustomViewCreate(Sender: TObject);
|
|||
|
|
procedure CustomViewDestroy(Sender: TObject);
|
|||
|
|
procedure actVerPedidoCliExecute(Sender: TObject);
|
|||
|
|
|
|||
|
|
procedure bFormasPagoClick(Sender: TObject);
|
|||
|
|
procedure cbConAlmacenClick(Sender: TObject);
|
|||
|
|
procedure eFechaPrevistaPropertiesValidate(Sender: TObject;
|
|||
|
|
var DisplayValue: Variant; var ErrorText: TCaption; var Error: Boolean);
|
|||
|
|
procedure eFechaEnvioPropertiesValidate(Sender: TObject;
|
|||
|
|
var DisplayValue: Variant; var ErrorText: TCaption; var Error: Boolean);
|
|||
|
|
procedure eFechaRecepcionPropertiesValidate(Sender: TObject;
|
|||
|
|
var DisplayValue: Variant; var ErrorText: TCaption; var Error: Boolean);
|
|||
|
|
procedure frViewClienteAlbaranactElegirContactoUpdate(Sender: TObject);
|
|||
|
|
procedure actVerPedidoCliUpdate(Sender: TObject);
|
|||
|
|
procedure frViewClienteAlbaranButton1Click(Sender: TObject);
|
|||
|
|
procedure frViewClienteAlbaranButton2Click(Sender: TObject);
|
|||
|
|
procedure frViewClienteAlbaranactAnadirContactoUpdate(Sender: TObject);
|
|||
|
|
|
|||
|
|
protected
|
|||
|
|
FAlbaran : IBizAlbaranCliente;
|
|||
|
|
FController : IAlbaranesClienteController;
|
|||
|
|
FAlmacenesController : IAlmacenesController;
|
|||
|
|
// FPedidoAsociado : IBizPedidoCliente;
|
|||
|
|
// FPedidoController : IPedidosClienteController;
|
|||
|
|
FViewClienteAlbaran : IViewDatosYSeleccionClienteAlbaran;
|
|||
|
|
FFormasPago : IBizFormaPago;
|
|||
|
|
FFormasPagoController : IFormasPagoController;
|
|||
|
|
|
|||
|
|
function GetAlbaran: IBizAlbaranCliente;
|
|||
|
|
procedure SetAlbaran(const Value: IBizAlbaranCliente); virtual;
|
|||
|
|
function GetViewClienteAlbaran: IViewDatosYSeleccionClienteAlbaran;
|
|||
|
|
|
|||
|
|
public
|
|||
|
|
property Albaran: IBizAlbaranCliente read GetAlbaran write SetAlbaran;
|
|||
|
|
property ViewClienteAlbaran: IViewDatosYSeleccionClienteAlbaran read GetViewClienteAlbaran;
|
|||
|
|
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
implementation
|
|||
|
|
|
|||
|
|
{$R *.dfm}
|
|||
|
|
|
|||
|
|
{ TfrViewAlbaranCliente }
|
|||
|
|
|
|||
|
|
uses
|
|||
|
|
uClientesController, uBizDireccionesContacto,
|
|||
|
|
schAlbaranesClienteClient_Intf, uBizAlmacenes, uDateUtils,
|
|||
|
|
uDialogUtils, uFactuGES_App;
|
|||
|
|
|
|||
|
|
|
|||
|
|
procedure TfrViewAlbaranCliente.actVerPedidoCliExecute(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
// FPedidoController.Ver(FPedidoAsociado);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrViewAlbaranCliente.actVerPedidoCliUpdate(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
if (Sender as TAction).Enabled then
|
|||
|
|
(Sender as TAction).Enabled := (Albaran.REF_PEDIDO <> '')
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrViewAlbaranCliente.bFormasPagoClick(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
if Assigned(FFormasPago) then
|
|||
|
|
FFormasPagoController.VerTodos(FFormasPago);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrViewAlbaranCliente.cbConAlmacenClick(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
|
|||
|
|
//Para que no me cambie el estilo del campo
|
|||
|
|
if ReadOnly then Exit;
|
|||
|
|
|
|||
|
|
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.CustomViewCreate(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
FFormasPago := Nil;
|
|||
|
|
FFormasPagoController := TFormasPagoController.Create;
|
|||
|
|
// FPedidoAsociado := NIL;
|
|||
|
|
// FPedidoController := TPedidosClienteController.Create;
|
|||
|
|
FViewClienteAlbaran := frViewClienteAlbaran;
|
|||
|
|
FAlmacenesController := TAlmacenesController.Create;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrViewAlbaranCliente.CustomViewDestroy(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
FFormasPago := Nil;
|
|||
|
|
FFormasPagoController := NIL;
|
|||
|
|
FViewClienteAlbaran := Nil;
|
|||
|
|
// FPedidoController := NIL;
|
|||
|
|
// FPedidoAsociado := NIL;
|
|||
|
|
FAlmacenesController := NIL;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrViewAlbaranCliente.eFechaEnvioPropertiesValidate(Sender: TObject;
|
|||
|
|
var DisplayValue: Variant; var ErrorText: TCaption; var Error: Boolean);
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
|
|||
|
|
if VarIsNull(DisplayValue) or (DisplayValue = '') then
|
|||
|
|
begin
|
|||
|
|
if (ShowConfirmMessage('Si elimina la fecha prevista de envio, se eliminar<61>n tambien las fechas de envio y recepci<63>n en caso de tenerlas. <20>Desea continuar?', '') = IDYES) then
|
|||
|
|
begin
|
|||
|
|
eFechaRecepcion.Clear;
|
|||
|
|
eFechaRecepcion.Enabled := false;
|
|||
|
|
end
|
|||
|
|
else
|
|||
|
|
DisplayValue := DateToStr(eFechaEnvio.Date);
|
|||
|
|
end
|
|||
|
|
else
|
|||
|
|
eFechaRecepcion.Enabled := true;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrViewAlbaranCliente.eFechaPrevistaPropertiesValidate(Sender: TObject; var DisplayValue: Variant; var ErrorText: TCaption;
|
|||
|
|
var Error: Boolean);
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
if VarIsNull(DisplayValue) or (DisplayValue = '') then
|
|||
|
|
begin
|
|||
|
|
if (ShowConfirmMessage('Si elimina la fecha prevista de envio, se eliminar<61>n tambien las fechas de envio y recepci<63>n en caso de tenerlas. <20>Desea continuar?', '') = IDYES) then
|
|||
|
|
begin
|
|||
|
|
eFechaEnvio.Clear;
|
|||
|
|
eFechaEnvio.Enabled := false;
|
|||
|
|
eFechaRecepcion.Clear;
|
|||
|
|
eFechaRecepcion.Enabled := false;
|
|||
|
|
end
|
|||
|
|
else
|
|||
|
|
DisplayValue := DateToStr(eFechaPrevista.Date);
|
|||
|
|
end
|
|||
|
|
else
|
|||
|
|
eFechaEnvio.Enabled := true;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrViewAlbaranCliente.eFechaRecepcionPropertiesValidate(
|
|||
|
|
Sender: TObject; var DisplayValue: Variant; var ErrorText: TCaption;
|
|||
|
|
var Error: Boolean);
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
if not (VarIsNull(DisplayValue) or (DisplayValue = '')) then
|
|||
|
|
begin
|
|||
|
|
if (eFechaRecepcion.Date < eFechaEnvio.Date) then
|
|||
|
|
begin
|
|||
|
|
ShowWarningMessage('La fecha de recepci<63>n debe ser posterior a la fecha de envio');
|
|||
|
|
eFechaRecepcion.SetFocus;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrViewAlbaranCliente.frViewClienteAlbaranactAnadirContactoUpdate(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
{
|
|||
|
|
if (Sender as TAction).Enabled then
|
|||
|
|
(Sender as TAction).Enabled := not Assigned(FPedidoAsociado);
|
|||
|
|
}
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrViewAlbaranCliente.frViewClienteAlbaranactElegirContactoUpdate(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
{
|
|||
|
|
if (Sender as TAction).Enabled then
|
|||
|
|
(Sender as TAction).Enabled := not Assigned(FPedidoAsociado);
|
|||
|
|
}
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrViewAlbaranCliente.frViewClienteAlbaranButton1Click(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
{if Assigned(Albaran) and Assigned(Albaran.Cliente) and
|
|||
|
|
Assigned (Albaran.Detalles) and (Albaran.Detalles.RecordCount > 0) then
|
|||
|
|
begin
|
|||
|
|
if (Application.MessageBox('Los descuentos de los art<72>culos del albar<61>n ser<65>n actualizados con los del nuevo cliente seleccionado, <20>Desea continuar?', 'Atenci<63>n', MB_YESNO) = IDNO) then
|
|||
|
|
Exit;
|
|||
|
|
end;}
|
|||
|
|
frViewClienteAlbaran.actElegirContacto.Execute;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrViewAlbaranCliente.frViewClienteAlbaranButton2Click(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
if Assigned(Albaran) and Assigned(Albaran.Cliente) and
|
|||
|
|
Assigned (Albaran.Detalles) and (Albaran.Detalles.RecordCount > 0) then
|
|||
|
|
begin
|
|||
|
|
if (Application.MessageBox('Los descuentos de los art<72>culos del albar<61>n ser<65>n actualizados con los del nuevo cliente seleccionado, <20>Desea continuar?', 'Atenci<63>n', MB_YESNO) = IDNO) then
|
|||
|
|
Exit;
|
|||
|
|
end;
|
|||
|
|
frViewClienteAlbaran.actAnadirContacto.Execute;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
function TfrViewAlbaranCliente.GetAlbaran: IBizAlbaranCliente;
|
|||
|
|
begin
|
|||
|
|
Result := FAlbaran;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
function TfrViewAlbaranCliente.GetViewClienteAlbaran: IViewDatosYSeleccionClienteAlbaran;
|
|||
|
|
begin
|
|||
|
|
Result := FViewClienteAlbaran;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrViewAlbaranCliente.SetAlbaran(const Value: IBizAlbaranCliente);
|
|||
|
|
begin
|
|||
|
|
FAlbaran := Value;
|
|||
|
|
if Assigned(FAlbaran) then
|
|||
|
|
begin
|
|||
|
|
DADataSource.DataTable := FAlbaran.DataTable;
|
|||
|
|
frViewTienda1.DataItem := FAlbaran.DataTable;
|
|||
|
|
FViewClienteAlbaran.Albaran := FAlbaran;
|
|||
|
|
|
|||
|
|
FFormasPago := FFormasPagoController.BuscarTodos;
|
|||
|
|
dsFormaPago.DataTable := FFormasPago.DataTable;
|
|||
|
|
dsFormaPago.DataTable.Active := True;
|
|||
|
|
|
|||
|
|
dsAlmacenes.DataTable := (FAlmacenesController.BuscarTodos).DataTable;
|
|||
|
|
dsAlmacenes.DataTable.Active := True;
|
|||
|
|
|
|||
|
|
//Para que no me cambie el estilo del campo
|
|||
|
|
if not ReadOnly then
|
|||
|
|
begin
|
|||
|
|
cbConAlmacen.Checked := (FAlbaran.ID_ALMACEN > 0);
|
|||
|
|
cbAlmacen.Enabled := cbConAlmacen.Checked;
|
|||
|
|
|
|||
|
|
eReferenciaPedidoCli.Enabled := False;
|
|||
|
|
eRefFacturaCli.Enabled := False;
|
|||
|
|
|
|||
|
|
if EsFechaVacia(FAlbaran.FECHA_PREVISTA_ENVIO) then
|
|||
|
|
begin
|
|||
|
|
eFechaEnvio.Enabled := false;
|
|||
|
|
eFechaRecepcion.Enabled := false;
|
|||
|
|
end
|
|||
|
|
else
|
|||
|
|
begin
|
|||
|
|
eFechaEnvio.Enabled := true;
|
|||
|
|
if EsFechaVacia(FAlbaran.FECHA_ENVIO) then
|
|||
|
|
eFechaRecepcion.Enabled := false
|
|||
|
|
else
|
|||
|
|
eFechaRecepcion.Enabled := true;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
{
|
|||
|
|
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;
|
|||
|
|
FViewClienteAlbaran.Albaran := nil;
|
|||
|
|
// FPedidoAsociado := NIL;
|
|||
|
|
dsFormaPago.DataTable := NIL;
|
|||
|
|
dsAlmacenes.DataTable := NIL;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
end.
|