AlonsoYSal_FactuGES2/Source/Modulos/Inventario/Views/uViewInventario.pas
2019-11-18 10:36:42 +00:00

193 lines
6.2 KiB
ObjectPascal
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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,
dxPSEdgePatterns, dxPSCore, dxPScxCommon, dxPScxGrid6Lnk, cxImage,
cxImageComboBox, ImgList, PngImageList, cxTextEdit, Grids, DBGrids, cxDBLookupComboBox,
cxButtonEdit, cxGridCustomPopupMenu, cxGridPopupMenu, uViewGrid,
uBizInventario, uBizAlmacenes, cxSpinEdit, uViewFiltroBase, TB2Item, TBX,
TB2Toolbar, TBXDkPanels, TB2Dock, dxPgsDlg, cxCurrencyEdit, uDAInterfaces,
uCustomView, uViewBase;
type
IViewInventario = interface(IViewGrid)
['{4BAE6CBE-4CBB-4103-B85E-80BE5310723A}']
function GetInventario: IBizInventario;
procedure SetInventario(const Value: IBizInventario);
property Inventario: IBizInventario read GetInventario write SetInventario;
function GetAlmacenes: IBizAlmacen;
procedure SetAlmacenes(const Value: IBizAlmacen);
property Almacenes: IBizAlmacen read GetAlmacenes write SetAlmacenes;
end;
TfrViewInventario = class(TfrViewGrid, IViewInventario)
cxGridDBTableView1: TcxGridDBTableView;
PngImageList: TPngImageList;
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;
procedure cxGridActiveTabChanged(Sender: TcxCustomGrid; ALevel: TcxGridLevel);
procedure cxGridViewStylesGetContentStyle(Sender: TcxCustomGridTableView;
ARecord: TcxCustomGridRecord; AItem: TcxCustomGridTableItem; out
AStyle: TcxStyle);
procedure cxGridViewDataControllerCompare(
ADataController: TcxCustomDataController; ARecordIndex1, ARecordIndex2,
AItemIndex: Integer; const V1, V2: Variant; var Compare: Integer);
private
//Filtros relativos a la vista
procedure AnadirFiltroAlmacenes;
protected
FAlmacenes: IBizAlmacen;
FInventario: IBizInventario;
function GetAlmacenes: IBizAlmacen;
procedure SetAlmacenes(const Value: IBizAlmacen);
function GetInventario: IBizInventario;
procedure SetInventario(const Value: IBizInventario);
procedure AnadirOtrosFiltros; override;
public
property Inventario: IBizInventario read GetInventario write SetInventario;
destructor Destroy; override;
end;
implementation
{$R *.dfm}
uses uReferenciasUtils, cxVariants, uDataModuleInventario, schInventarioClient_Intf;
procedure TfrViewInventario.AnadirFiltroAlmacenes;
var
FFiltro : TcxFilterCriteriaItemList;
CodigoAlmacen: String;
begin
FFiltro := AddFilterGrid(fboAnd);
CodigoAlmacen := IntToStr(cxGrid.Levels.Items[cxGrid.ActiveLevel.Index].Tag);
if CodigoAlmacen <> '-1' then
begin
FFiltro.AddItem(cxGridViewID_ALMACEN, foEqual, CodigoAlmacen, CodigoAlmacen);
cxGridViewALMACEN.Visible := False;
end
else
cxGridViewALMACEN.Visible := True;
end;
procedure TfrViewInventario.AnadirOtrosFiltros;
begin
inherited;
AnadirFiltroAlmacenes;
//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;
procedure TfrViewInventario.cxGridActiveTabChanged(Sender: TcxCustomGrid; ALevel: TcxGridLevel);
begin
inherited;
RefrescarFiltro;
end;
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;
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
AStyle := cxStyleArticuloSinStock;
end;
end;
destructor TfrViewInventario.Destroy;
begin
FAlmacenes := Nil;
FInventario := Nil;
inherited;
end;
function TfrViewInventario.GetAlmacenes: IBizAlmacen;
begin
Result := FAlmacenes;
end;
function TfrViewInventario.GetInventario: IBizInventario;
begin
Result := FInventario;
end;
procedure TfrViewInventario.SetAlmacenes(const Value: IBizAlmacen);
var
Nivel: TcxGridLevel;
begin
FAlmacenes := Value;
if Assigned(FAlmacenes) then
begin
if not FAlmacenes.DataTable.Active then
FAlmacenes.DataTable.Active := True;
FAlmacenes.First;
while not FAlmacenes.EOF do
begin
Nivel := cxGrid.Levels.Add;
Nivel.Caption := FAlmacenes.NOMBRE;
Nivel.Tag := FAlmacenes.ID;
FAlmacenes.Next;
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;
end.