2009-12-16 17:16:54 +00:00
|
|
|
|
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, cxDropDownEdit, cxButtonEdit,
|
|
|
|
|
|
Menus, cxGridCustomPopupMenu,
|
|
|
|
|
|
cxGridPopupMenu, cxEditRepositoryItems;
|
|
|
|
|
|
|
|
|
|
|
|
type
|
|
|
|
|
|
IViewDetallesArticulos = interface(IViewDetallesDTO)
|
|
|
|
|
|
['{D2F72E72-9CEA-4E43-AA18-625F7561E627}']
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
TfrViewDetallesArticulos = class(TfrViewDetallesDTO, IViewDetallesArticulos)
|
|
|
|
|
|
cxGridViewID_ARTICULO: TcxGridDBColumn;
|
|
|
|
|
|
cxGridViewREFERENCIA: TcxGridDBColumn;
|
|
|
|
|
|
cxGridViewREFERENCIA_PROVEEDOR: TcxGridDBColumn;
|
|
|
|
|
|
actAnadirArticulos: TAction;
|
|
|
|
|
|
cxGridViewUNIDAD_MEDIDA: TcxGridDBColumn;
|
|
|
|
|
|
actBuscarArticulo: TAction;
|
|
|
|
|
|
TBXSeparatorItem8: TTBXSeparatorItem;
|
|
|
|
|
|
cxGridViewREFERENCIA_FABRICANTE: TcxGridDBColumn;
|
|
|
|
|
|
cxEditRepository1: TcxEditRepository;
|
|
|
|
|
|
cxEditRepositoryComboBox_IMPORTEUNIDAD: TcxEditRepositoryComboBoxItem;
|
|
|
|
|
|
cxEditRepositoryCurrencyItem_IMPORTEUNIDAD: TcxEditRepositoryCurrencyItem;
|
|
|
|
|
|
procedure CustomViewCreate(Sender: TObject);
|
|
|
|
|
|
procedure CustomViewDestroy(Sender: TObject);
|
|
|
|
|
|
procedure actAnadirArticulosExecute(Sender: TObject);
|
|
|
|
|
|
procedure actAnadirArticulosUpdate(Sender: TObject);
|
|
|
|
|
|
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);
|
|
|
|
|
|
procedure cxGridViewREFERENCIAPropertiesButtonClick(Sender: TObject;
|
|
|
|
|
|
AButtonIndex: Integer);
|
|
|
|
|
|
procedure actBuscarArticuloExecute(Sender: TObject);
|
|
|
|
|
|
procedure actBuscarArticuloUpdate(Sender: TObject);
|
|
|
|
|
|
procedure actDetalleCopiarExecute(Sender: TObject);
|
|
|
|
|
|
procedure actDetallePegarExecute(Sender: TObject);
|
|
|
|
|
|
procedure actDetalleCortarExecute(Sender: TObject);
|
|
|
|
|
|
procedure cxGridViewREFERENCIA_PROVEEDORPropertiesButtonClick(
|
|
|
|
|
|
Sender: TObject; AButtonIndex: Integer);
|
|
|
|
|
|
procedure cxGridViewREFERENCIA_FABRICANTEPropertiesButtonClick(
|
|
|
|
|
|
Sender: TObject; AButtonIndex: Integer);
|
|
|
|
|
|
private
|
|
|
|
|
|
procedure RecuperarListaUnidadesMedida;
|
|
|
|
|
|
protected
|
|
|
|
|
|
procedure AnadirArticulosInterno; virtual;
|
|
|
|
|
|
procedure RellenarArticulosInterno; virtual;
|
|
|
|
|
|
function AnadirArticulo(pReferencia: String; TipoReferencia: TEnumReferencia): Boolean; virtual;
|
|
|
|
|
|
function EsTipoEditable(AItem: TcxCustomGridTableItem): Boolean; override;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
implementation
|
|
|
|
|
|
{$R *.dfm}
|
|
|
|
|
|
|
|
|
|
|
|
uses
|
|
|
|
|
|
uCalculosUtils, uViewDetallesBase, uControllerDetallesBase, uUnidadesMedidaController;
|
|
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
|
|
SeleccionarFilaActual;
|
|
|
|
|
|
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;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfrViewDetallesArticulos.CustomViewDestroy(Sender: TObject);
|
|
|
|
|
|
begin
|
|
|
|
|
|
inherited;
|
|
|
|
|
|
cxGridViewREFERENCIA.Properties.OnValidate := Nil;
|
|
|
|
|
|
cxGridViewREFERENCIA_PROVEEDOR.Properties.OnValidate := Nil;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfrViewDetallesArticulos.CustomViewShow(Sender: TObject);
|
|
|
|
|
|
begin
|
|
|
|
|
|
inherited;
|
|
|
|
|
|
|
2010-01-13 18:30:03 +00:00
|
|
|
|
{ with DADataSource.DataTable do
|
2009-12-16 17:16:54 +00:00
|
|
|
|
begin
|
|
|
|
|
|
cxGridView.BeginUpdate;
|
|
|
|
|
|
try
|
|
|
|
|
|
if Assigned(FindField('UNIDAD_MEDIDA')) then
|
|
|
|
|
|
begin
|
|
|
|
|
|
cxGridViewUNIDAD_MEDIDA.DataBinding.FieldName := 'UNIDAD_MEDIDA';
|
|
|
|
|
|
cxGridViewUNIDAD_MEDIDA.Visible := True;
|
|
|
|
|
|
cxGridViewUNIDAD_MEDIDA.VisibleForCustomization := True;
|
|
|
|
|
|
RecuperarListaUnidadesMedida;
|
|
|
|
|
|
end
|
|
|
|
|
|
else begin
|
|
|
|
|
|
cxGridViewUNIDAD_MEDIDA.DataBinding.FieldName := '';
|
|
|
|
|
|
cxGridViewUNIDAD_MEDIDA.Visible := False;
|
|
|
|
|
|
cxGridViewUNIDAD_MEDIDA.VisibleForCustomization := False;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if Assigned(FindField('REFERENCIA_FABRICANTE')) then
|
|
|
|
|
|
begin
|
|
|
|
|
|
cxGridViewREFERENCIA_FABRICANTE.DataBinding.FieldName := 'REFERENCIA_FABRICANTE';
|
|
|
|
|
|
cxGridViewREFERENCIA_FABRICANTE.Visible := True;
|
|
|
|
|
|
cxGridViewREFERENCIA_FABRICANTE.VisibleForCustomization := True;
|
|
|
|
|
|
end
|
|
|
|
|
|
else begin
|
|
|
|
|
|
cxGridViewREFERENCIA_FABRICANTE.DataBinding.FieldName := '';
|
|
|
|
|
|
cxGridViewREFERENCIA_FABRICANTE.Visible := False;
|
|
|
|
|
|
cxGridViewREFERENCIA_FABRICANTE.VisibleForCustomization := False;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
finally
|
|
|
|
|
|
cxGridView.EndUpdate;
|
|
|
|
|
|
end;
|
|
|
|
|
|
end;
|
2010-01-13 18:30:03 +00:00
|
|
|
|
}
|
2009-12-16 17:16:54 +00:00
|
|
|
|
SeleccionarFilaActual;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfrViewDetallesArticulos.cxGridViewREFERENCIAPropertiesButtonClick(
|
|
|
|
|
|
Sender: TObject; AButtonIndex: Integer);
|
|
|
|
|
|
begin
|
|
|
|
|
|
inherited;
|
|
|
|
|
|
actBuscarArticulo.Execute;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfrViewDetallesArticulos.cxGridViewREFERENCIA_FABRICANTEPropertiesButtonClick(
|
|
|
|
|
|
Sender: TObject; AButtonIndex: Integer);
|
|
|
|
|
|
begin
|
|
|
|
|
|
inherited;
|
|
|
|
|
|
actBuscarArticulo.Execute;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfrViewDetallesArticulos.cxGridViewREFERENCIA_PROVEEDORPropertiesButtonClick(
|
|
|
|
|
|
Sender: TObject; AButtonIndex: Integer);
|
|
|
|
|
|
begin
|
|
|
|
|
|
inherited;
|
|
|
|
|
|
actBuscarArticulo.Execute;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
function TfrViewDetallesArticulos.EsTipoEditable(
|
|
|
|
|
|
AItem: TcxCustomGridTableItem): Boolean;
|
|
|
|
|
|
var
|
|
|
|
|
|
IndiceCol : Integer;
|
|
|
|
|
|
begin
|
|
|
|
|
|
Result := True;
|
|
|
|
|
|
|
|
|
|
|
|
if (AItem.Index in [cxGridViewREFERENCIA.Index, cxGridViewREFERENCIA_PROVEEDOR.Index]) then
|
|
|
|
|
|
begin
|
|
|
|
|
|
IndiceCol := cxGridView.GetColumnByFieldName(CAMPO_TIPO).Index;
|
|
|
|
|
|
if ((AItem.GridView.Items[IndiceCol].EditValue = TIPO_DETALLE_SALTO) or
|
|
|
|
|
|
(AItem.GridView.Items[IndiceCol].EditValue = TIPO_DETALLE_SUBTOTAL) or
|
|
|
|
|
|
(AItem.GridView.Items[IndiceCol].EditValue = TIPO_DETALLE_DESCUENTO) or
|
|
|
|
|
|
(AItem.GridView.Items[IndiceCol].EditValue = TIPO_DETALLE_TITULO)) then
|
|
|
|
|
|
Result := False;
|
|
|
|
|
|
end
|
|
|
|
|
|
else
|
|
|
|
|
|
Result := inherited EsTipoEditable(AItem);
|
|
|
|
|
|
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
|
|
|
|
|
|
//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.RecuperarListaUnidadesMedida;
|
|
|
|
|
|
var
|
|
|
|
|
|
AUnidController : IUnidadesMedidaController;
|
|
|
|
|
|
begin
|
|
|
|
|
|
inherited;
|
|
|
|
|
|
with TcxComboBoxProperties(cxGridViewUNIDAD_MEDIDA.Properties).Items do
|
|
|
|
|
|
begin
|
|
|
|
|
|
if (Count = 0) then
|
|
|
|
|
|
begin
|
|
|
|
|
|
ShowHourglassCursor;
|
|
|
|
|
|
BeginUpdate;
|
|
|
|
|
|
AUnidController := TUnidadesMedidaController.Create;
|
|
|
|
|
|
try
|
|
|
|
|
|
Clear;
|
|
|
|
|
|
AddStrings(AUnidController.DarListaUnidadesMedida);
|
|
|
|
|
|
finally
|
|
|
|
|
|
EndUpdate;
|
|
|
|
|
|
AUnidController := NIL;
|
|
|
|
|
|
HideHourglassCursor;
|
|
|
|
|
|
end;
|
|
|
|
|
|
end;
|
|
|
|
|
|
end;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfrViewDetallesArticulos.RellenarArticulosInterno;
|
|
|
|
|
|
begin
|
|
|
|
|
|
(Controller as IControllerDetallesArticulos).AnadirArticulos(Detalles, False);
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfrViewDetallesArticulos.actAnadirArticulosUpdate(Sender: TObject);
|
|
|
|
|
|
begin
|
|
|
|
|
|
inherited;
|
|
|
|
|
|
(Sender as TAction).Enabled := actAnadir.Enabled;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfrViewDetallesArticulos.actBuscarArticuloExecute(Sender: TObject);
|
|
|
|
|
|
begin
|
|
|
|
|
|
cxGridView.BeginUpdate;
|
|
|
|
|
|
try
|
|
|
|
|
|
if cxGridView.Controller.EditingController.IsEditing then
|
|
|
|
|
|
cxGridView.Controller.EditingController.Edit.PostEditValue;
|
|
|
|
|
|
|
|
|
|
|
|
RellenarArticulosInterno;
|
|
|
|
|
|
finally
|
|
|
|
|
|
cxGridView.EndUpdate;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
SeleccionarFilaActual;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfrViewDetallesArticulos.actBuscarArticuloUpdate(Sender: TObject);
|
|
|
|
|
|
begin
|
|
|
|
|
|
inherited;
|
|
|
|
|
|
(Sender as TAction).Enabled := actAnadir.Enabled;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfrViewDetallesArticulos.actDetalleCopiarExecute(Sender: TObject);
|
|
|
|
|
|
begin
|
|
|
|
|
|
inherited;
|
|
|
|
|
|
cxGridView.CopyToClipboard(False);
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfrViewDetallesArticulos.actDetalleCortarExecute(Sender: TObject);
|
|
|
|
|
|
begin
|
|
|
|
|
|
inherited;
|
|
|
|
|
|
//
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfrViewDetallesArticulos.actDetallePegarExecute(Sender: TObject);
|
|
|
|
|
|
begin
|
|
|
|
|
|
inherited;
|
|
|
|
|
|
//
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
function TfrViewDetallesArticulos.AnadirArticulo(pReferencia: String; TipoReferencia: TEnumReferencia): Boolean;
|
|
|
|
|
|
begin
|
|
|
|
|
|
Result := (Controller as IControllerDetallesArticulos).AnadirArticulo(Detalles, pReferencia, TipoReferencia);
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
end.
|