178 lines
5.4 KiB
ObjectPascal
178 lines
5.4 KiB
ObjectPascal
|
|
unit uDialogRecepcionPedido;
|
|||
|
|
|
|||
|
|
interface
|
|||
|
|
|
|||
|
|
uses
|
|||
|
|
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
|||
|
|
Dialogs, uDialogBase, ActnList, StdCtrls, ExtCtrls, cxControls, cxContainer,
|
|||
|
|
cxEdit, cxTextEdit, cxMaskEdit, cxSpinEdit, jpeg, cxGraphics, cxDropDownEdit,
|
|||
|
|
cxCalendar, DateUtils, uBizUbicacionesAlmacen, uBizAlmacenes, uUbicacionesAlmacenController,
|
|||
|
|
uAlmacenesController, cxLookupEdit, cxDBLookupEdit, cxDBLookupComboBox, DB,
|
|||
|
|
uDAInterfaces, uDADataTable;
|
|||
|
|
|
|||
|
|
type
|
|||
|
|
TfDialogRecepcionPedido = class(TfDialogBase)
|
|||
|
|
eNumBultos: TcxSpinEdit;
|
|||
|
|
Label2: TLabel;
|
|||
|
|
Label3: TLabel;
|
|||
|
|
Label4: TLabel;
|
|||
|
|
eFechaRecepcion: TcxDateEdit;
|
|||
|
|
Label1: TLabel;
|
|||
|
|
cbubicacion: TcxComboBox;
|
|||
|
|
cbAlmacenes: TcxLookupComboBox;
|
|||
|
|
dsAlmacenes: TDADataSource;
|
|||
|
|
procedure cbubicacionPropertiesInitPopup(Sender: TObject);
|
|||
|
|
procedure cbubicacionPropertiesValidate(Sender: TObject;
|
|||
|
|
var DisplayValue: Variant; var ErrorText: TCaption; var Error: Boolean);
|
|||
|
|
procedure FormDestroy(Sender: TObject);
|
|||
|
|
procedure actAceptarExecute(Sender: TObject);
|
|||
|
|
procedure actCancelarExecute(Sender: TObject);
|
|||
|
|
procedure FormShow(Sender: TObject);
|
|||
|
|
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
|
|||
|
|
|
|||
|
|
private
|
|||
|
|
FAlmacenes: IBizAlmacen;
|
|||
|
|
FUbicacionesController: IUbicacionesAlmacenController;
|
|||
|
|
FAlmacenesController: IAlmacenesController;
|
|||
|
|
|
|||
|
|
public
|
|||
|
|
FNumPedidos: Integer;
|
|||
|
|
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
function ElegirOpcionesRecepcionPedido(const NumeroPedidos: Integer; var AFechaRecepcion: TDateTime; var ABultos: Integer; var AUbicacion : String; var AAlmacen: Variant): Boolean;
|
|||
|
|
|
|||
|
|
implementation
|
|||
|
|
{$R *.dfm}
|
|||
|
|
uses uDialogUtils;
|
|||
|
|
|
|||
|
|
function ElegirOpcionesRecepcionPedido(const NumeroPedidos: Integer; var AFechaRecepcion: TDateTime; var ABultos: Integer; var AUbicacion : String; var AAlmacen: Variant): Boolean;
|
|||
|
|
var
|
|||
|
|
AEditor : TfDialogRecepcionPedido;
|
|||
|
|
begin
|
|||
|
|
AEditor := TfDialogRecepcionPedido.Create(NIL);
|
|||
|
|
try
|
|||
|
|
AEditor.FNumPedidos := NumeroPedidos;
|
|||
|
|
AEditor.eFechaRecepcion.Date := DateOf(Date);
|
|||
|
|
AEditor.cbAlmacenes.EditValue := AAlmacen;
|
|||
|
|
AEditor.cbubicacion.EditValue := AUbicacion;
|
|||
|
|
|
|||
|
|
Result := (AEditor.ShowModal = mrOk);
|
|||
|
|
if Result then
|
|||
|
|
begin
|
|||
|
|
AFechaRecepcion := AEditor.eFechaRecepcion.Date;
|
|||
|
|
ABultos := AEditor.eNumBultos.Value;
|
|||
|
|
AUbicacion := AEditor.cbubicacion.EditValue;
|
|||
|
|
AAlmacen := AEditor.cbAlmacenes.EditValue;
|
|||
|
|
end;
|
|||
|
|
finally
|
|||
|
|
AEditor.Release;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfDialogRecepcionPedido.actAceptarExecute(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
ModalResult := mrOk
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfDialogRecepcionPedido.actCancelarExecute(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
ModalResult := mrCancel;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfDialogRecepcionPedido.cbubicacionPropertiesInitPopup(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
with cbubicacion.Properties.Items do
|
|||
|
|
begin
|
|||
|
|
BeginUpdate;
|
|||
|
|
try
|
|||
|
|
Clear;
|
|||
|
|
AddStrings(FUbicacionesController.DarListaUbicacionesAlmacen);
|
|||
|
|
finally
|
|||
|
|
EndUpdate;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfDialogRecepcionPedido.cbubicacionPropertiesValidate(Sender: TObject;
|
|||
|
|
var DisplayValue: Variant; var ErrorText: TCaption; var Error: Boolean);
|
|||
|
|
var
|
|||
|
|
AUbicacion : IBizUbicacionAlmacen;
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
with (Sender as TcxComboBox) do
|
|||
|
|
begin
|
|||
|
|
if (Length(DisplayValue) > 0) then //and (DisplayValue <> (Contacto as IBizCliente).PROCEDENCIA_CLIENTE) then
|
|||
|
|
if Properties.LookupItems.IndexOf(DisplayValue) < 0 then
|
|||
|
|
begin
|
|||
|
|
Properties.LookupItems.BeginUpdate;
|
|||
|
|
AUbicacion := FUbicacionesController.BuscarTodos;
|
|||
|
|
AUbicacion.DataTable.Active := True;
|
|||
|
|
try
|
|||
|
|
FUbicacionesController.Anadir(AUbicacion);
|
|||
|
|
AUbicacion.DESCRIPCION := DisplayValue;
|
|||
|
|
FUbicacionesController.Guardar(AUbicacion);
|
|||
|
|
Properties.LookupItems.Add(DisplayValue);
|
|||
|
|
finally
|
|||
|
|
Properties.LookupItems.EndUpdate;
|
|||
|
|
AUbicacion := NIL;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfDialogRecepcionPedido.FormCloseQuery(Sender: TObject;
|
|||
|
|
var CanClose: Boolean);
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
if (ModalResult = mrOk) then
|
|||
|
|
begin
|
|||
|
|
|
|||
|
|
if (cbAlmacenes.EditValue = 0) then
|
|||
|
|
if (FNumPedidos = 1) then
|
|||
|
|
begin
|
|||
|
|
if (ShowConfirmMessage('Direcci<63>n de entrega', 'Si no elige almac<61>n de entrega se supondr<64> que la entrega se realiza en la direcci<63>n establecida en el pedido seleccionado, <20>Desea continuar?') = IDNO) then
|
|||
|
|
begin
|
|||
|
|
CanClose := False;
|
|||
|
|
cbAlmacenes.SetFocus;
|
|||
|
|
end;
|
|||
|
|
end
|
|||
|
|
else begin
|
|||
|
|
ShowErrorMessage('Direcci<63>n de entrega', 'Debe elegir un almacen de destino para los pedidos seleccionados.');
|
|||
|
|
CanClose := False;
|
|||
|
|
cbAlmacenes.SetFocus;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfDialogRecepcionPedido.FormDestroy(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
FAlmacenes := Nil;
|
|||
|
|
FUbicacionesController := Nil;
|
|||
|
|
FAlmacenesController := Nil;
|
|||
|
|
inherited;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfDialogRecepcionPedido.FormShow(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
FUbicacionesController := TUbicacionesAlmacenController.Create;
|
|||
|
|
FAlmacenesController := TAlmacenesController.Create;
|
|||
|
|
|
|||
|
|
FAlmacenes := FAlmacenesController.BuscarTodos;
|
|||
|
|
dsAlmacenes.DataTable := FAlmacenes.DataTable;
|
|||
|
|
if not FAlmacenes.DataTable.Active then
|
|||
|
|
FAlmacenes.DataTable.Active := True;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
end.
|