Tecsitel_FactuGES2/Source/Modulos/Inventario/Views/uViewInventario.pas
david f3f230e414 - Actualización a DevExpress x.38 sin el módulo de skins.
- Limpieza de código para NO usar skins de DevExpress.

git-svn-id: https://192.168.0.254/svn/Proyectos.Tecsitel_FactuGES2/trunk@541 0c75b7a4-871f-7646-8a2f-f78d34cc349f
2008-08-27 16:48:20 +00:00

214 lines
6.5 KiB
ObjectPascal

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, cxIntlPrintSys3, 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,
uBizObras;
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;
function GetObras: IBizObra;
procedure SetObras(const Value: IBizObra);
property Obras: IBizObra read GetObras write SetObras;
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;
cxGridViewID: TcxGridDBColumn;
cxGridViewID_ARTICULO: TcxGridDBColumn;
procedure cxGridActiveTabChanged(Sender: TcxCustomGrid; ALevel: TcxGridLevel);
procedure cxGridViewStylesGetContentStyle(Sender: TcxCustomGridTableView;
ARecord: TcxCustomGridRecord; AItem: TcxCustomGridTableItem; out
AStyle: TcxStyle);
private
//Filtros relativos a la vista
procedure AnadirFiltroAlmacenesObras;
protected
FAlmacenes: IBizAlmacen;
FObras: IBizObra;
FInventario: IBizInventario;
function GetAlmacenes: IBizAlmacen;
procedure SetAlmacenes(const Value: IBizAlmacen);
function GetObras: IBizObra;
procedure SetObras(const Value: IBizObra);
function GetInventario: IBizInventario;
procedure SetInventario(const Value: IBizInventario);
public
property Inventario: IBizInventario read GetInventario write SetInventario;
procedure AnadirOtrosFiltros; override;
destructor Destroy; override;
end;
implementation
{$R *.dfm}
uses uDataModuleInventario, schInventarioClient_Intf;
procedure TfrViewInventario.AnadirFiltroAlmacenesObras;
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;
AnadirFiltroAlmacenesObras;
//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.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.TextColor := cxStyleArticuloSinStock.TextColor;
end;
end;
destructor TfrViewInventario.Destroy;
begin
FAlmacenes := Nil;
FObras := Nil;
FInventario := Nil;
inherited;
end;
function TfrViewInventario.GetAlmacenes: IBizAlmacen;
begin
Result := FAlmacenes;
end;
function TfrViewInventario.GetInventario: IBizInventario;
begin
Result := FInventario;
end;
function TfrViewInventario.GetObras: IBizObra;
begin
Result := FObras;
end;
procedure TfrViewInventario.SetAlmacenes(const Value: IBizAlmacen);
var
Nivel: TcxGridLevel;
begin
FAlmacenes := Value;
if Assigned(FAlmacenes) then
begin
cxGridLevel.Caption := 'Todos los almacenes';
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;
procedure TfrViewInventario.SetObras(const Value: IBizObra);
var
Nivel: TcxGridLevel;
begin
FObras := Value;
if Assigned(FObras) then
begin
cxGridLevel.Caption := 'Todos las obras';
if not FObras.DataTable.Active then
FObras.DataTable.Active := True;
FObras.First;
while not FObras.EOF do
begin
Nivel := cxGrid.Levels.Add;
Nivel.Caption := FObras.NOMBRE;
Nivel.Tag := FObras.ID;
FObras.Next;
end;
end;
end;
end.