git-svn-id: https://192.168.0.254/svn/Proyectos.AbetoDesign_FactuGES/trunk@153 93f398dd-4eb6-7a46-baf6-13f46f578da2
162 lines
5.6 KiB
ObjectPascal
162 lines
5.6 KiB
ObjectPascal
unit uViewDetallesArticulos;
|
||
|
||
interface
|
||
|
||
uses
|
||
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
||
Dialogs, uViewDetallesDTO, cxStyles, cxCustomData, cxGraphics, cxFilter,
|
||
cxData, cxDataStorage, cxEdit, DB, cxDBData, cxImageComboBox, cxRichEdit,
|
||
cxMaskEdit, cxCurrencyEdit, cxCheckBox, ImgList, PngImageList, uDADataTable,
|
||
StdActns, ExtActns, ActnList, TB2Item, TBX, TB2Dock, TB2Toolbar, cxGridLevel,
|
||
cxGridCustomTableView, cxGridTableView, cxGridDBTableView, cxClasses,
|
||
cxControls, cxGridCustomView, cxGrid, ComCtrls, StdCtrls, JvExStdCtrls,
|
||
JvCombobox, JvColorCombo, ToolWin, uControllerDetallesArticulos,
|
||
cxTextEdit, uDAInterfaces;
|
||
|
||
type
|
||
IViewDetallesArticulos = interface(IViewDetallesDTO)
|
||
['{D2F72E72-9CEA-4E43-AA18-625F7561E627}']
|
||
end;
|
||
|
||
TfrViewDetallesArticulos = class(TfrViewDetallesDTO, IViewDetallesArticulos)
|
||
cxGridViewID_ARTICULO: TcxGridDBColumn;
|
||
cxGridViewREFERENCIA: TcxGridDBColumn;
|
||
cxGridViewREFERENCIA_PROVEEDOR: TcxGridDBColumn;
|
||
actAnadirArticulos: TAction;
|
||
TBXItem12: TTBXItem;
|
||
procedure CustomViewCreate(Sender: TObject);
|
||
procedure CustomViewDestroy(Sender: TObject);
|
||
procedure actAnadirArticulosExecute(Sender: TObject);
|
||
procedure actAnadirArticulosUpdate(Sender: TObject);
|
||
procedure OnValidateCantidad(Sender: TObject; var DisplayValue: Variant; var ErrorText: TCaption; var Error: Boolean);
|
||
procedure OnValidateReferencia(Sender: TObject; var DisplayValue: Variant; var ErrorText: TCaption; var Error: Boolean);
|
||
procedure OnValidateReferenciaProveedor(Sender: TObject; var DisplayValue: Variant; var ErrorText: TCaption; var Error: Boolean);
|
||
procedure CustomViewShow(Sender: TObject);
|
||
|
||
protected
|
||
procedure ValidarCantidadInterno(var DisplayValue: Variant; var ErrorText: TCaption; var Error: Boolean); virtual;
|
||
procedure AnadirArticulosInterno; virtual;
|
||
procedure RellenarArticulosInterno; virtual;
|
||
function AnadirArticulo(pReferencia: String; TipoReferencia: TEnumReferencia): Boolean; virtual;
|
||
end;
|
||
|
||
implementation
|
||
{$R *.dfm}
|
||
|
||
uses uViewDetallesBase;
|
||
|
||
procedure TfrViewDetallesArticulos.actAnadirArticulosExecute(Sender: TObject);
|
||
begin
|
||
cxGridView.BeginUpdate;
|
||
try
|
||
if cxGridView.Controller.EditingController.IsEditing then
|
||
cxGridView.Controller.EditingController.Edit.PostEditValue;
|
||
|
||
AnadirArticulosInterno;
|
||
finally
|
||
cxGridView.EndUpdate;
|
||
end;
|
||
|
||
SeleccionarRowActual;
|
||
end;
|
||
|
||
procedure TfrViewDetallesArticulos.AnadirArticulosInterno;
|
||
begin
|
||
(Controller as IControllerDetallesArticulos).AnadirArticulos(Detalles);
|
||
end;
|
||
|
||
procedure TfrViewDetallesArticulos.CustomViewCreate(Sender: TObject);
|
||
begin
|
||
inherited;
|
||
cxGridViewREFERENCIA.Properties.OnValidate := OnValidateReferencia;
|
||
// cxGridViewREFERENCIA_PROVEEDOR.Properties.OnValidate := OnValidateReferenciaProveedor;
|
||
cxGridViewCANTIDAD.Properties.OnValidate := OnValidateCantidad;
|
||
end;
|
||
|
||
procedure TfrViewDetallesArticulos.CustomViewDestroy(Sender: TObject);
|
||
begin
|
||
inherited;
|
||
cxGridViewREFERENCIA.Properties.OnValidate := Nil;
|
||
// cxGridViewREFERENCIA_PROVEEDOR.Properties.OnValidate := Nil;
|
||
cxGridViewCANTIDAD.Properties.OnValidate := Nil;
|
||
end;
|
||
|
||
procedure TfrViewDetallesArticulos.CustomViewShow(Sender: TObject);
|
||
begin
|
||
inherited;
|
||
SeleccionarRowActual;
|
||
end;
|
||
|
||
procedure TfrViewDetallesArticulos.OnValidateCantidad(Sender: TObject;
|
||
var DisplayValue: Variant; var ErrorText: TCaption; var Error: Boolean);
|
||
begin
|
||
Self.ValidarCantidadInterno(DisplayValue, ErrorText, Error);
|
||
end;
|
||
|
||
procedure TfrViewDetallesArticulos.OnValidateReferencia(Sender: TObject; var DisplayValue: Variant; var ErrorText: TCaption; var Error: Boolean);
|
||
var
|
||
lsReferencia : String;
|
||
begin
|
||
//En el caso de cadena vacia no validamos
|
||
if (VarIsNull(DisplayValue)) then
|
||
Exit;
|
||
|
||
lsReferencia := VarToStr(DisplayValue);
|
||
if (length(trim(lsReferencia)) = 0) then
|
||
Exit;
|
||
|
||
|
||
if not AnadirArticulo(lsReferencia, tCliente) then
|
||
begin
|
||
ErrorText := 'La referencia introducida no exite en el cat<61>logo';
|
||
Error := True;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrViewDetallesArticulos.OnValidateReferenciaProveedor(Sender: TObject; var DisplayValue: Variant; var ErrorText: TCaption; var Error: Boolean);
|
||
var
|
||
lsReferencia : String;
|
||
begin
|
||
//NO SE PUEDE BUSCAR POR REFERENCIA PROVEEDOR YA QUE PUEDE HABER VARIOS PROVEEDORES DE UN ARTICULO
|
||
//En el caso de cadena vacia no validamos
|
||
{ if (VarIsNull(DisplayValue)) then
|
||
Exit;
|
||
|
||
lsReferencia := VarToStr(DisplayValue);
|
||
if (length(trim(lsReferencia)) = 0) then
|
||
Exit;
|
||
|
||
if not AnadirArticulo(lsReferencia, tProveedor) then
|
||
begin
|
||
ErrorText := 'La referencia introducida no exite en el cat<61>logo';
|
||
Error := True;
|
||
end;
|
||
}
|
||
end;
|
||
|
||
procedure TfrViewDetallesArticulos.RellenarArticulosInterno;
|
||
begin
|
||
(Controller as IControllerDetallesArticulos).AnadirArticulos(Detalles, False);
|
||
end;
|
||
|
||
procedure TfrViewDetallesArticulos.ValidarCantidadInterno(
|
||
var DisplayValue: Variant; var ErrorText: TCaption; var Error: Boolean);
|
||
begin
|
||
// Este procedimiento sirve para hacer cosas cuando la CANTIDAD cambia.
|
||
// Por ejemplo, meter autom<6F>ticamente el descuento de l<>nea.
|
||
// Se sobreescribe en herencia.
|
||
end;
|
||
|
||
procedure TfrViewDetallesArticulos.actAnadirArticulosUpdate(Sender: TObject);
|
||
begin
|
||
inherited;
|
||
(Sender as TAction).Enabled := actAnadir.Enabled;
|
||
end;
|
||
|
||
function TfrViewDetallesArticulos.AnadirArticulo(pReferencia: String; TipoReferencia: TEnumReferencia): Boolean;
|
||
begin
|
||
Result := (Controller as IControllerDetallesArticulos).AnadirArticulo(Detalles, pReferencia, TipoReferencia);
|
||
end;
|
||
|
||
end.
|