2007-11-16 20:58:56 +00:00
|
|
|
|
unit uViewInventario;
|
|
|
|
|
|
|
|
|
|
|
|
interface
|
|
|
|
|
|
|
|
|
|
|
|
uses
|
|
|
|
|
|
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
|
|
|
|
|
Dialogs, frxClass, frxPreview, cxStyles,
|
|
|
|
|
|
cxCustomData, cxGraphics, cxFilter, cxData, cxDataStorage, cxEdit, DB,
|
|
|
|
|
|
cxDBData, ActnList, uDADataTable, cxGridLevel, cxClasses, cxControls,
|
|
|
|
|
|
cxGridCustomView, cxGridCustomTableView, cxGridTableView,
|
|
|
|
|
|
cxGridDBTableView, cxGrid, StdCtrls, ExtCtrls, cxLabel, dxPSGlbl, dxPSUtl,
|
|
|
|
|
|
dxPSEngn, dxPrnPg, dxBkgnd, dxWrap, dxPrnDev, dxPSCompsProvider, dxPSFillPatterns,
|
2008-01-04 11:16:59 +00:00
|
|
|
|
dxPSEdgePatterns, cxIntlPrintSys3, dxPSCore, dxPScxCommon, dxPScxGrid6Lnk, cxImage,
|
2007-11-16 20:58:56 +00:00
|
|
|
|
cxImageComboBox, ImgList, PngImageList, cxTextEdit, Grids, DBGrids, cxDBLookupComboBox,
|
|
|
|
|
|
cxButtonEdit, cxGridCustomPopupMenu, cxGridPopupMenu, uViewGrid,
|
2008-11-05 12:46:33 +00:00
|
|
|
|
uBizInventario, cxSpinEdit, uViewFiltroBase, TB2Item, TBX,
|
2008-05-20 18:50:02 +00:00
|
|
|
|
TB2Toolbar, TBXDkPanels, TB2Dock, dxPgsDlg, cxCurrencyEdit, uDAInterfaces,
|
2010-08-24 17:29:18 +00:00
|
|
|
|
cxContainer, cxMaskEdit, cxDropDownEdit, uCustomView, uViewBase;
|
2008-11-05 12:46:33 +00:00
|
|
|
|
// uBizAlmacenes, uBizObras;
|
2007-11-16 20:58:56 +00:00
|
|
|
|
|
|
|
|
|
|
type
|
|
|
|
|
|
IViewInventario = interface(IViewGrid)
|
|
|
|
|
|
['{4BAE6CBE-4CBB-4103-B85E-80BE5310723A}']
|
|
|
|
|
|
function GetInventario: IBizInventario;
|
|
|
|
|
|
procedure SetInventario(const Value: IBizInventario);
|
|
|
|
|
|
property Inventario: IBizInventario read GetInventario write SetInventario;
|
2008-11-05 12:46:33 +00:00
|
|
|
|
function GetAlmacenes: TStringList;
|
|
|
|
|
|
procedure SetAlmacenes(const Value: TStringList);
|
|
|
|
|
|
property Almacenes: TStringList read GetAlmacenes write SetAlmacenes;
|
|
|
|
|
|
function GetObras: TStringList;
|
|
|
|
|
|
procedure SetObras(const Value: TStringList);
|
|
|
|
|
|
property Obras: TStringList read GetObras write SetObras;
|
2008-11-05 19:43:24 +00:00
|
|
|
|
function DarIDAlmacenObraSeleccionada: Variant;
|
2008-11-07 21:05:48 +00:00
|
|
|
|
function ListaAlmacenesObrasVacia: Boolean;
|
2007-11-16 20:58:56 +00:00
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
TfrViewInventario = class(TfrViewGrid, IViewInventario)
|
|
|
|
|
|
cxGridDBTableView1: TcxGridDBTableView;
|
|
|
|
|
|
cxStyleArticuloSinStock: TcxStyle;
|
|
|
|
|
|
cxGridViewSTOCK: TcxGridDBColumn;
|
|
|
|
|
|
cxGridViewDESCRIPCION: TcxGridDBColumn;
|
|
|
|
|
|
cxGridViewREFERENCIA: TcxGridDBColumn;
|
|
|
|
|
|
cxGridViewFAMILIA: TcxGridDBColumn;
|
|
|
|
|
|
cxGridViewALMACEN: TcxGridDBColumn;
|
|
|
|
|
|
cxGridViewID_ALMACEN: TcxGridDBColumn;
|
|
|
|
|
|
cxGridViewRESERVA: TcxGridDBColumn;
|
|
|
|
|
|
cxGridViewPENDIENTE_RECEPCION: TcxGridDBColumn;
|
|
|
|
|
|
cxGridViewREFERENCIA_PROVEEDOR: TcxGridDBColumn;
|
|
|
|
|
|
cxGridViewUNIDADES_ALMACEN: TcxGridDBColumn;
|
|
|
|
|
|
cxGridViewPRECIO_NETO: TcxGridDBColumn;
|
|
|
|
|
|
cxGridViewCOSTE_UNIDADES: TcxGridDBColumn;
|
2008-07-30 16:25:35 +00:00
|
|
|
|
cxGridViewID: TcxGridDBColumn;
|
|
|
|
|
|
cxGridViewID_ARTICULO: TcxGridDBColumn;
|
2008-09-08 15:01:03 +00:00
|
|
|
|
cxStyleArticuloConStock: TcxStyle;
|
2008-11-06 18:52:39 +00:00
|
|
|
|
pnlAlmacenes: TPanel;
|
2008-11-05 12:46:33 +00:00
|
|
|
|
cxListaAlmacenesObras: TcxComboBox;
|
2008-11-05 19:43:24 +00:00
|
|
|
|
eAlmacen: TLabel;
|
2007-11-16 20:58:56 +00:00
|
|
|
|
procedure cxGridViewStylesGetContentStyle(Sender: TcxCustomGridTableView;
|
|
|
|
|
|
ARecord: TcxCustomGridRecord; AItem: TcxCustomGridTableItem; out
|
|
|
|
|
|
AStyle: TcxStyle);
|
2008-11-05 12:46:33 +00:00
|
|
|
|
procedure cxListaObrasPropertiesEditValueChanged(Sender: TObject);
|
2008-11-05 19:43:24 +00:00
|
|
|
|
procedure CustomViewShow(Sender: TObject);
|
2008-11-13 16:33:20 +00:00
|
|
|
|
procedure cxGridViewDataControllerCompare(
|
|
|
|
|
|
ADataController: TcxCustomDataController; ARecordIndex1, ARecordIndex2,
|
|
|
|
|
|
AItemIndex: Integer; const V1, V2: Variant; var Compare: Integer);
|
2007-11-16 20:58:56 +00:00
|
|
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
//Filtros relativos a la vista
|
2008-07-30 16:25:35 +00:00
|
|
|
|
procedure AnadirFiltroAlmacenesObras;
|
2007-11-16 20:58:56 +00:00
|
|
|
|
|
|
|
|
|
|
protected
|
2008-11-05 12:46:33 +00:00
|
|
|
|
FAlmacenes: TStringList;
|
|
|
|
|
|
FObras: TStringList;
|
2007-11-16 20:58:56 +00:00
|
|
|
|
FInventario: IBizInventario;
|
2008-11-05 12:46:33 +00:00
|
|
|
|
function GetAlmacenes: TStringList;
|
|
|
|
|
|
procedure SetAlmacenes(const Value: TStringList);
|
|
|
|
|
|
function GetObras: TStringList;
|
|
|
|
|
|
procedure SetObras(const Value: TStringList);
|
2007-11-16 20:58:56 +00:00
|
|
|
|
function GetInventario: IBizInventario;
|
|
|
|
|
|
procedure SetInventario(const Value: IBizInventario);
|
|
|
|
|
|
public
|
|
|
|
|
|
property Inventario: IBizInventario read GetInventario write SetInventario;
|
2008-05-20 18:50:02 +00:00
|
|
|
|
procedure AnadirOtrosFiltros; override;
|
2007-11-16 20:58:56 +00:00
|
|
|
|
destructor Destroy; override;
|
2008-11-05 19:43:24 +00:00
|
|
|
|
function DarIDAlmacenObraSeleccionada: Variant;
|
2008-11-07 21:05:48 +00:00
|
|
|
|
function ListaAlmacenesObrasVacia: Boolean;
|
2007-11-16 20:58:56 +00:00
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
implementation
|
|
|
|
|
|
{$R *.dfm}
|
|
|
|
|
|
|
2010-08-24 17:29:18 +00:00
|
|
|
|
uses uFactuGES_App, uDataModuleInventario, schInventarioClient_Intf, uReferenciasUtils, cxVariants;
|
2007-11-16 20:58:56 +00:00
|
|
|
|
|
2008-07-30 16:25:35 +00:00
|
|
|
|
procedure TfrViewInventario.AnadirFiltroAlmacenesObras;
|
2007-11-16 20:58:56 +00:00
|
|
|
|
var
|
|
|
|
|
|
FFiltro : TcxFilterCriteriaItemList;
|
2008-11-05 19:43:24 +00:00
|
|
|
|
CodigoAlmacen: Variant;
|
2007-11-16 20:58:56 +00:00
|
|
|
|
begin
|
|
|
|
|
|
FFiltro := AddFilterGrid(fboAnd);
|
|
|
|
|
|
|
2008-11-05 19:43:24 +00:00
|
|
|
|
CodigoAlmacen := DarIDAlmacenObraSeleccionada;
|
2008-11-05 12:46:33 +00:00
|
|
|
|
|
2008-11-05 19:43:24 +00:00
|
|
|
|
if not VarIsNull(CodigoAlmacen) then
|
2007-11-16 20:58:56 +00:00
|
|
|
|
begin
|
|
|
|
|
|
FFiltro.AddItem(cxGridViewID_ALMACEN, foEqual, CodigoAlmacen, CodigoAlmacen);
|
|
|
|
|
|
cxGridViewALMACEN.Visible := False;
|
|
|
|
|
|
end
|
|
|
|
|
|
else
|
|
|
|
|
|
cxGridViewALMACEN.Visible := True;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfrViewInventario.AnadirOtrosFiltros;
|
|
|
|
|
|
begin
|
|
|
|
|
|
inherited;
|
|
|
|
|
|
|
2008-07-30 16:25:35 +00:00
|
|
|
|
AnadirFiltroAlmacenesObras;
|
2007-11-16 20:58:56 +00:00
|
|
|
|
|
|
|
|
|
|
//Finalmente activamos el filtro si tenemos algo
|
|
|
|
|
|
if cxGridView.DataController.Filter.IsEmpty
|
|
|
|
|
|
then cxGridView.DataController.Filter.Active := False
|
|
|
|
|
|
else cxGridView.DataController.Filter.Active := True;
|
|
|
|
|
|
cxGrid.ActiveLevel.GridView := cxGridView;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
2008-11-05 19:43:24 +00:00
|
|
|
|
procedure TfrViewInventario.CustomViewShow(Sender: TObject);
|
2010-08-24 17:29:18 +00:00
|
|
|
|
var
|
|
|
|
|
|
i, Aindex: integer;
|
2008-11-05 19:43:24 +00:00
|
|
|
|
begin
|
|
|
|
|
|
inherited;
|
2008-11-06 18:52:39 +00:00
|
|
|
|
if Assigned(FAlmacenes) or Assigned(FObras) then
|
2010-08-24 17:29:18 +00:00
|
|
|
|
begin
|
2013-01-17 09:12:47 +00:00
|
|
|
|
Aindex := 0;
|
|
|
|
|
|
if Assigned(FAlmacenes) then
|
|
|
|
|
|
for i := 0 to FAlmacenes.Count - 1 do
|
|
|
|
|
|
begin
|
|
|
|
|
|
if (FAlmacenes.ValueFromIndex[i] = IntToStr(AppFactuGES.EmpresaActiva.ID_ALMACEN)) then
|
|
|
|
|
|
Aindex := i;
|
|
|
|
|
|
end;
|
2010-08-24 17:29:18 +00:00
|
|
|
|
cxListaAlmacenesObras.ItemIndex := Aindex;
|
|
|
|
|
|
end
|
2008-11-06 18:52:39 +00:00
|
|
|
|
//En el caso de ser la vista para la selecci<63>n de articulos de un determinado almac<61>n
|
|
|
|
|
|
else
|
|
|
|
|
|
pnlAlmacenes.Visible:= False;
|
2008-11-05 19:43:24 +00:00
|
|
|
|
end;
|
|
|
|
|
|
|
2008-11-13 16:33:20 +00:00
|
|
|
|
procedure TfrViewInventario.cxGridViewDataControllerCompare(
|
|
|
|
|
|
ADataController: TcxCustomDataController; ARecordIndex1, ARecordIndex2,
|
|
|
|
|
|
AItemIndex: Integer; const V1, V2: Variant; var Compare: Integer);
|
|
|
|
|
|
begin
|
|
|
|
|
|
inherited;
|
|
|
|
|
|
if (AItemIndex = cxGridViewREFERENCIA.Index) and
|
|
|
|
|
|
(VarType(V1) = VarType(V2)) and (VarType(V1) = varString) then
|
|
|
|
|
|
Compare := CompararReferencias(V1, V2)
|
|
|
|
|
|
else
|
|
|
|
|
|
Compare := VarCompare(V1, V2);
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
2007-11-16 20:58:56 +00:00
|
|
|
|
procedure TfrViewInventario.cxGridViewStylesGetContentStyle(Sender:
|
|
|
|
|
|
TcxCustomGridTableView; ARecord: TcxCustomGridRecord; AItem:
|
|
|
|
|
|
TcxCustomGridTableItem; out AStyle: TcxStyle);
|
|
|
|
|
|
var
|
|
|
|
|
|
IndiceCol: Integer;
|
|
|
|
|
|
AStock: Variant;
|
|
|
|
|
|
begin
|
|
|
|
|
|
inherited;
|
|
|
|
|
|
if Assigned(ARecord) then
|
|
|
|
|
|
begin
|
|
|
|
|
|
IndiceCol := (Sender as TcxGridDBTableView).GetColumnByFieldName(fld_INVENTARIOSTOCK).Index;
|
|
|
|
|
|
AStock := ARecord.DisplayTexts[IndiceCol];
|
|
|
|
|
|
if (AStock < 0) then
|
2008-09-08 15:01:03 +00:00
|
|
|
|
AStyle.TextColor := cxStyleArticuloSinStock.TextColor
|
|
|
|
|
|
else
|
|
|
|
|
|
AStyle.TextColor := cxStyleArticuloConStock.TextColor;
|
2007-11-16 20:58:56 +00:00
|
|
|
|
end;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
2008-11-07 21:05:48 +00:00
|
|
|
|
procedure TfrViewInventario.cxListaObrasPropertiesEditValueChanged(Sender: TObject);
|
2008-11-05 12:46:33 +00:00
|
|
|
|
begin
|
|
|
|
|
|
inherited;
|
|
|
|
|
|
RefrescarFiltro;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
2008-11-05 19:43:24 +00:00
|
|
|
|
function TfrViewInventario.DarIDAlmacenObraSeleccionada: Variant;
|
|
|
|
|
|
begin
|
|
|
|
|
|
//INV_ALMACENES
|
|
|
|
|
|
if Assigned(FAlmacenes) then
|
|
|
|
|
|
Result := FAlmacenes.Values[cxListaAlmacenesObras.EditValue]
|
|
|
|
|
|
//INV_OBRAS
|
|
|
|
|
|
else if Assigned(FObras) then
|
|
|
|
|
|
Result := FObras.Values[cxListaAlmacenesObras.EditValue]
|
|
|
|
|
|
else
|
|
|
|
|
|
Raise Exception.Create('No se ha asignado ninguna lista de ALMACENES');
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
2007-11-16 20:58:56 +00:00
|
|
|
|
destructor TfrViewInventario.Destroy;
|
|
|
|
|
|
begin
|
|
|
|
|
|
FAlmacenes := Nil;
|
2008-11-07 21:05:48 +00:00
|
|
|
|
FObras := Nil;
|
2007-11-16 20:58:56 +00:00
|
|
|
|
FInventario := Nil;
|
|
|
|
|
|
inherited;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
2008-11-05 12:46:33 +00:00
|
|
|
|
function TfrViewInventario.GetAlmacenes: TStringList;
|
2007-11-16 20:58:56 +00:00
|
|
|
|
begin
|
|
|
|
|
|
Result := FAlmacenes;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
function TfrViewInventario.GetInventario: IBizInventario;
|
|
|
|
|
|
begin
|
|
|
|
|
|
Result := FInventario;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
2008-11-05 12:46:33 +00:00
|
|
|
|
function TfrViewInventario.GetObras: TStringList;
|
2008-07-30 16:25:35 +00:00
|
|
|
|
begin
|
|
|
|
|
|
Result := FObras;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
2008-11-07 21:05:48 +00:00
|
|
|
|
function TfrViewInventario.ListaAlmacenesObrasVacia: Boolean;
|
|
|
|
|
|
begin
|
|
|
|
|
|
Result := (cxListaAlmacenesObras.Properties.Items.Count = 0);
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
2008-11-05 12:46:33 +00:00
|
|
|
|
procedure TfrViewInventario.SetAlmacenes(const Value: TStringList);
|
2007-11-16 20:58:56 +00:00
|
|
|
|
var
|
|
|
|
|
|
Nivel: TcxGridLevel;
|
2008-11-05 12:46:33 +00:00
|
|
|
|
i: integer;
|
2007-11-16 20:58:56 +00:00
|
|
|
|
begin
|
|
|
|
|
|
FAlmacenes := Value;
|
2008-11-05 19:43:24 +00:00
|
|
|
|
eAlmacen.Caption := 'Almac<61>n';
|
2007-11-16 20:58:56 +00:00
|
|
|
|
|
|
|
|
|
|
if Assigned(FAlmacenes) then
|
|
|
|
|
|
begin
|
2008-11-04 18:01:45 +00:00
|
|
|
|
cxGrid.BeginUpdate;
|
|
|
|
|
|
try
|
2008-11-05 12:46:33 +00:00
|
|
|
|
with cxListaAlmacenesObras.Properties.Items do
|
2008-11-04 18:01:45 +00:00
|
|
|
|
begin
|
2008-11-05 12:46:33 +00:00
|
|
|
|
BeginUpdate;
|
|
|
|
|
|
try
|
|
|
|
|
|
Clear;
|
|
|
|
|
|
for i := 0 to FAlmacenes.Count - 1 do
|
|
|
|
|
|
Add(FAlmacenes.Names[i]);
|
|
|
|
|
|
finally
|
|
|
|
|
|
EndUpdate;
|
|
|
|
|
|
end;
|
2008-11-04 18:01:45 +00:00
|
|
|
|
end;
|
2008-11-05 12:46:33 +00:00
|
|
|
|
|
2008-11-04 18:01:45 +00:00
|
|
|
|
finally
|
|
|
|
|
|
cxGrid.EndUpdate;
|
2007-11-16 20:58:56 +00:00
|
|
|
|
end;
|
|
|
|
|
|
end;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfrViewInventario.SetInventario(const Value: IBizInventario);
|
|
|
|
|
|
begin
|
|
|
|
|
|
FInventario := Value;
|
|
|
|
|
|
if Assigned(FInventario) then
|
|
|
|
|
|
dsDataSource.DataTable := FInventario.DataTable
|
|
|
|
|
|
else
|
|
|
|
|
|
dsDataSource.DataTable := Nil;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
2008-11-05 12:46:33 +00:00
|
|
|
|
procedure TfrViewInventario.SetObras(const Value: TStringList);
|
2008-07-30 16:25:35 +00:00
|
|
|
|
var
|
|
|
|
|
|
Nivel: TcxGridLevel;
|
2008-11-05 12:46:33 +00:00
|
|
|
|
i: integer;
|
2008-07-30 16:25:35 +00:00
|
|
|
|
begin
|
|
|
|
|
|
FObras := Value;
|
2008-11-05 19:43:24 +00:00
|
|
|
|
eAlmacen.Caption := 'Obra';
|
2008-07-30 16:25:35 +00:00
|
|
|
|
|
|
|
|
|
|
if Assigned(FObras) then
|
|
|
|
|
|
begin
|
2008-11-04 18:01:45 +00:00
|
|
|
|
cxGrid.BeginUpdate;
|
|
|
|
|
|
try
|
2008-11-05 12:46:33 +00:00
|
|
|
|
with cxListaAlmacenesObras.Properties.Items do
|
2008-11-04 18:01:45 +00:00
|
|
|
|
begin
|
2008-11-05 12:46:33 +00:00
|
|
|
|
BeginUpdate;
|
|
|
|
|
|
try
|
|
|
|
|
|
Clear;
|
|
|
|
|
|
for i := 0 to FObras.Count - 1 do
|
|
|
|
|
|
Add(FObras.Names[i]);
|
|
|
|
|
|
finally
|
|
|
|
|
|
EndUpdate;
|
|
|
|
|
|
end;
|
2008-11-04 18:01:45 +00:00
|
|
|
|
end;
|
2008-11-05 12:46:33 +00:00
|
|
|
|
|
2008-11-04 18:01:45 +00:00
|
|
|
|
finally
|
|
|
|
|
|
cxGrid.EndUpdate;
|
2008-07-30 16:25:35 +00:00
|
|
|
|
end;
|
|
|
|
|
|
end;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
2007-11-16 20:58:56 +00:00
|
|
|
|
end.
|