2007-11-16 20:58:56 +00:00
|
|
|
|
unit uViewDetalleReservas;
|
|
|
|
|
|
|
|
|
|
|
|
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,
|
|
|
|
|
|
uBizInventario, uBizAlmacenes, cxSpinEdit, uViewFiltroBase, TB2Item, TBX,
|
2007-11-21 16:03:51 +00:00
|
|
|
|
TB2Toolbar, TBXDkPanels, TB2Dock, dxPgsDlg, cxCurrencyEdit, uAlmacenesController,
|
2013-01-17 09:12:47 +00:00
|
|
|
|
uDAInterfaces, cxContainer, cxMaskEdit, cxDropDownEdit, uCustomView, uViewBase;
|
2009-04-16 15:31:51 +00:00
|
|
|
|
|
2007-11-16 20:58:56 +00:00
|
|
|
|
type
|
|
|
|
|
|
IViewDetalleReservas = interface(IViewGrid)
|
|
|
|
|
|
['{4417F53A-5BB1-4B99-8760-4C0E1D449582}']
|
|
|
|
|
|
function GetDetalleReservas: IBizDetalleReservas;
|
|
|
|
|
|
procedure SetDetalleReservas(const Value: IBizDetalleReservas);
|
|
|
|
|
|
property DetalleReservas: IBizDetalleReservas read GetDetalleReservas write SetDetalleReservas;
|
2008-11-07 21:05:48 +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;
|
|
|
|
|
|
function DarIDAlmacenObraSeleccionada: Variant;
|
|
|
|
|
|
function ListaAlmacenesObrasVacia: Boolean;
|
2009-04-16 15:31:51 +00:00
|
|
|
|
function GetIdAlmacenObra: Integer;
|
|
|
|
|
|
procedure SetAlmacenObra(const Value: Integer);
|
|
|
|
|
|
property IdAlmacenObra: Integer read GetIdAlmacenObra write SetAlmacenObra;
|
2007-11-16 20:58:56 +00:00
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
TfrViewDetalleReservas = class(TfrViewGrid, IViewDetalleReservas)
|
|
|
|
|
|
cxGridDBTableView1: TcxGridDBTableView;
|
|
|
|
|
|
PngImageList: TPngImageList;
|
|
|
|
|
|
cxStyleArticuloSinStock: TcxStyle;
|
|
|
|
|
|
cxGridViewRecID: TcxGridDBColumn;
|
2008-09-04 17:38:49 +00:00
|
|
|
|
cxGridViewFECHA_RESERVA: TcxGridDBColumn;
|
|
|
|
|
|
cxGridViewCAUSA_RESERVA: TcxGridDBColumn;
|
|
|
|
|
|
cxGridViewID_ALMACEN: TcxGridDBColumn;
|
|
|
|
|
|
cxGridViewALMACEN: TcxGridDBColumn;
|
|
|
|
|
|
cxGridViewID_ARTICULO: TcxGridDBColumn;
|
|
|
|
|
|
cxGridViewFAMILIA: TcxGridDBColumn;
|
|
|
|
|
|
cxGridViewREFERENCIA: TcxGridDBColumn;
|
|
|
|
|
|
cxGridViewDESCRIPCION: TcxGridDBColumn;
|
|
|
|
|
|
cxGridViewCANTIDAD: TcxGridDBColumn;
|
|
|
|
|
|
cxGridViewUNIDAD_MEDIDA: TcxGridDBColumn;
|
|
|
|
|
|
cxGridViewFABRICANTE: TcxGridDBColumn;
|
|
|
|
|
|
cxGridViewREFERENCIA_FABR: TcxGridDBColumn;
|
|
|
|
|
|
cxGridViewID_ALMACEN_RESERVA: TcxGridDBColumn;
|
|
|
|
|
|
cxGridViewALMACEN_RESERVA: TcxGridDBColumn;
|
2008-11-07 21:05:48 +00:00
|
|
|
|
pnlAlmacenes: TPanel;
|
|
|
|
|
|
eAlmacen: TLabel;
|
|
|
|
|
|
cxListaAlmacenesObras: TcxComboBox;
|
2007-11-16 20:58:56 +00:00
|
|
|
|
procedure cxGridViewStylesGetContentStyle(Sender: TcxCustomGridTableView;
|
|
|
|
|
|
ARecord: TcxCustomGridRecord; AItem: TcxCustomGridTableItem; out
|
|
|
|
|
|
AStyle: TcxStyle);
|
2008-11-07 21:05:48 +00:00
|
|
|
|
procedure cxListaAlmacenesObrasPropertiesEditValueChanged(Sender: TObject);
|
|
|
|
|
|
procedure CustomViewShow(Sender: TObject);
|
2007-11-16 20:58:56 +00:00
|
|
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
//Filtros relativos a la vista
|
2008-11-07 21:05:48 +00:00
|
|
|
|
procedure AnadirFiltroAlmacenesObras;
|
2007-11-16 20:58:56 +00:00
|
|
|
|
|
|
|
|
|
|
protected
|
2009-04-16 15:31:51 +00:00
|
|
|
|
FIdAlmacenObra: Integer;
|
2008-11-07 21:05:48 +00:00
|
|
|
|
FAlmacenes: TStringList;
|
|
|
|
|
|
FObras: TStringList;
|
2007-11-16 20:58:56 +00:00
|
|
|
|
FDetalleReservas: IBizDetalleReservas;
|
2008-11-07 21:05:48 +00:00
|
|
|
|
|
2009-04-16 15:31:51 +00:00
|
|
|
|
function GetIdAlmacenObra: Integer;
|
|
|
|
|
|
procedure SetAlmacenObra(const Value: Integer);
|
2008-11-07 21:05:48 +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 GetDetalleReservas: IBizDetalleReservas;
|
|
|
|
|
|
procedure SetDetalleReservas(const Value: IBizDetalleReservas);
|
2008-11-07 21:05:48 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// FAlmacenesController: IAlmacenesController;
|
|
|
|
|
|
// function GetAlmacenes: IBizAlmacen;
|
|
|
|
|
|
// procedure SetAlmacenes(const Value: IBizAlmacen);
|
|
|
|
|
|
|
|
|
|
|
|
|
2007-11-16 20:58:56 +00:00
|
|
|
|
public
|
2009-04-16 15:31:51 +00:00
|
|
|
|
property IdAlmacenObra: Integer read GetIdAlmacenObra write SetAlmacenObra;
|
2007-11-16 20:58:56 +00:00
|
|
|
|
property DetalleReservas: IBizDetalleReservas read GetDetalleReservas write SetDetalleReservas;
|
2008-05-20 18:50:02 +00:00
|
|
|
|
procedure AnadirOtrosFiltros; override;
|
2008-11-07 21:05:48 +00:00
|
|
|
|
|
|
|
|
|
|
// property Almacenes: IBizAlmacen read GetAlmacenes write SetAlmacenes;
|
|
|
|
|
|
|
2007-11-16 20:58:56 +00:00
|
|
|
|
destructor Destroy; override;
|
2008-11-07 21:05:48 +00:00
|
|
|
|
|
|
|
|
|
|
function DarIDAlmacenObraSeleccionada: Variant;
|
|
|
|
|
|
function ListaAlmacenesObrasVacia: Boolean;
|
|
|
|
|
|
|
2007-11-16 20:58:56 +00:00
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
implementation
|
|
|
|
|
|
{$R *.dfm}
|
|
|
|
|
|
|
|
|
|
|
|
uses uDataModuleInventario, schInventarioClient_Intf;
|
|
|
|
|
|
|
2008-11-07 21:05:48 +00:00
|
|
|
|
procedure TfrViewDetalleReservas.AnadirFiltroAlmacenesObras;
|
2007-11-16 20:58:56 +00:00
|
|
|
|
var
|
|
|
|
|
|
FFiltro : TcxFilterCriteriaItemList;
|
2008-11-07 21:05:48 +00:00
|
|
|
|
CodigoAlmacen: Variant;
|
2007-11-16 20:58:56 +00:00
|
|
|
|
begin
|
|
|
|
|
|
FFiltro := AddFilterGrid(fboAnd);
|
|
|
|
|
|
|
2008-11-07 21:05:48 +00:00
|
|
|
|
CodigoAlmacen := DarIDAlmacenObraSeleccionada;
|
|
|
|
|
|
|
|
|
|
|
|
if not VarIsNull(CodigoAlmacen) then
|
2007-11-16 20:58:56 +00:00
|
|
|
|
begin
|
2008-09-04 17:38:49 +00:00
|
|
|
|
FFiltro.AddItem(cxGridViewID_ALMACEN, foEqual, CodigoAlmacen, CodigoAlmacen);
|
|
|
|
|
|
cxGridViewALMACEN.Visible := False;
|
2007-11-16 20:58:56 +00:00
|
|
|
|
end
|
|
|
|
|
|
else
|
2008-09-04 17:38:49 +00:00
|
|
|
|
cxGridViewALMACEN.Visible := True;
|
2007-11-16 20:58:56 +00:00
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfrViewDetalleReservas.AnadirOtrosFiltros;
|
|
|
|
|
|
begin
|
|
|
|
|
|
inherited;
|
|
|
|
|
|
|
2008-11-07 21:05:48 +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-07 21:05:48 +00:00
|
|
|
|
procedure TfrViewDetalleReservas.CustomViewShow(Sender: TObject);
|
2009-04-16 15:31:51 +00:00
|
|
|
|
var
|
|
|
|
|
|
i: Integer;
|
|
|
|
|
|
|
2007-11-16 20:58:56 +00:00
|
|
|
|
begin
|
|
|
|
|
|
inherited;
|
2009-04-16 15:31:51 +00:00
|
|
|
|
|
|
|
|
|
|
//INV_ALMACENES
|
|
|
|
|
|
if Assigned(FAlmacenes) then
|
|
|
|
|
|
begin
|
|
|
|
|
|
i := 0;
|
|
|
|
|
|
while (i < FAlmacenes.Count) and (FAlmacenes.ValueFromIndex[i] <> IntToStr(IdAlmacenObra)) do
|
|
|
|
|
|
Inc(i);
|
|
|
|
|
|
if (FAlmacenes.ValueFromIndex[i] = IntToStr(IdAlmacenObra)) then
|
|
|
|
|
|
cxListaAlmacenesObras.ItemIndex := i
|
|
|
|
|
|
end
|
|
|
|
|
|
//INV_OBRAS
|
|
|
|
|
|
else if Assigned(FObras) then
|
|
|
|
|
|
begin
|
|
|
|
|
|
i := 0;
|
|
|
|
|
|
while (i < FObras.Count) and (FObras.ValueFromIndex[i] <> IntToStr(IdAlmacenObra)) do
|
|
|
|
|
|
Inc(i);
|
|
|
|
|
|
if (FObras.ValueFromIndex[i] = IntToStr(IdAlmacenObra)) then
|
|
|
|
|
|
cxListaAlmacenesObras.ItemIndex := i
|
|
|
|
|
|
end
|
2008-11-07 21:05:48 +00:00
|
|
|
|
else
|
2009-04-16 15:31:51 +00:00
|
|
|
|
//En el caso de ser la vista para la selecci<63>n de articulos de un determinado almac<61>n
|
|
|
|
|
|
pnlAlmacenes.Visible:= False;
|
2007-11-16 20:58:56 +00:00
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfrViewDetalleReservas.cxGridViewStylesGetContentStyle(Sender:
|
|
|
|
|
|
TcxCustomGridTableView; ARecord: TcxCustomGridRecord; AItem:
|
|
|
|
|
|
TcxCustomGridTableItem; out AStyle: TcxStyle);
|
2008-05-20 18:50:02 +00:00
|
|
|
|
{var
|
2007-11-16 20:58:56 +00:00
|
|
|
|
IndiceCol: Integer;
|
2008-05-20 18:50:02 +00:00
|
|
|
|
AStock: Variant;}
|
2007-11-16 20:58:56 +00:00
|
|
|
|
begin
|
|
|
|
|
|
inherited;
|
|
|
|
|
|
{
|
|
|
|
|
|
if Assigned(ARecord) then
|
|
|
|
|
|
begin
|
|
|
|
|
|
IndiceCol := (Sender as TcxGridDBTableView).GetColumnByFieldName(fld_DetalleReservasSTOCK).Index;
|
|
|
|
|
|
AStock := ARecord.DisplayTexts[IndiceCol];
|
|
|
|
|
|
if (AStock < 0) then
|
|
|
|
|
|
AStyle := cxStyleArticuloSinStock;
|
|
|
|
|
|
end;
|
|
|
|
|
|
}
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
2008-11-07 21:05:48 +00:00
|
|
|
|
procedure TfrViewDetalleReservas.cxListaAlmacenesObrasPropertiesEditValueChanged(Sender: TObject);
|
|
|
|
|
|
begin
|
|
|
|
|
|
inherited;
|
|
|
|
|
|
RefrescarFiltro;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
function TfrViewDetalleReservas.DarIDAlmacenObraSeleccionada: Variant;
|
|
|
|
|
|
begin
|
2009-01-09 17:38:39 +00:00
|
|
|
|
Result := Null;
|
|
|
|
|
|
|
|
|
|
|
|
if VarIsNull(cxListaAlmacenesObras.EditValue) then
|
|
|
|
|
|
Exit;
|
|
|
|
|
|
|
2008-11-07 21:05:48 +00:00
|
|
|
|
//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 TfrViewDetalleReservas.Destroy;
|
|
|
|
|
|
begin
|
|
|
|
|
|
FAlmacenes := Nil;
|
2008-11-07 21:05:48 +00:00
|
|
|
|
FObras := Nil;
|
2007-11-16 20:58:56 +00:00
|
|
|
|
FDetalleReservas := Nil;
|
|
|
|
|
|
inherited;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
2008-11-07 21:05:48 +00:00
|
|
|
|
function TfrViewDetalleReservas.GetAlmacenes: TStringList;
|
2007-11-16 20:58:56 +00:00
|
|
|
|
begin
|
|
|
|
|
|
Result := FAlmacenes;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
function TfrViewDetalleReservas.GetDetalleReservas: IBizDetalleReservas;
|
|
|
|
|
|
begin
|
|
|
|
|
|
Result := FDetalleReservas;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
2009-04-16 15:31:51 +00:00
|
|
|
|
function TfrViewDetalleReservas.GetIdAlmacenObra: Integer;
|
|
|
|
|
|
begin
|
|
|
|
|
|
Result := FIDAlmacenObra;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
2008-11-07 21:05:48 +00:00
|
|
|
|
function TfrViewDetalleReservas.GetObras: TStringList;
|
|
|
|
|
|
begin
|
|
|
|
|
|
Result := FObras;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
function TfrViewDetalleReservas.ListaAlmacenesObrasVacia: Boolean;
|
|
|
|
|
|
begin
|
|
|
|
|
|
Result := (cxListaAlmacenesObras.Properties.Items.Count = 0);
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfrViewDetalleReservas.SetAlmacenes(const Value: TStringList);
|
2007-11-16 20:58:56 +00:00
|
|
|
|
var
|
|
|
|
|
|
Nivel: TcxGridLevel;
|
2008-11-07 21:05:48 +00:00
|
|
|
|
i: integer;
|
2007-11-16 20:58:56 +00:00
|
|
|
|
begin
|
|
|
|
|
|
FAlmacenes := Value;
|
2008-11-07 21:05:48 +00:00
|
|
|
|
eAlmacen.Caption := 'Almac<61>n';
|
2007-11-16 20:58:56 +00:00
|
|
|
|
|
|
|
|
|
|
if Assigned(FAlmacenes) then
|
|
|
|
|
|
begin
|
2008-11-07 21:05:48 +00:00
|
|
|
|
cxGrid.BeginUpdate;
|
|
|
|
|
|
try
|
|
|
|
|
|
with cxListaAlmacenesObras.Properties.Items do
|
|
|
|
|
|
begin
|
|
|
|
|
|
BeginUpdate;
|
|
|
|
|
|
try
|
|
|
|
|
|
Clear;
|
|
|
|
|
|
for i := 0 to FAlmacenes.Count - 1 do
|
|
|
|
|
|
Add(FAlmacenes.Names[i]);
|
|
|
|
|
|
finally
|
|
|
|
|
|
EndUpdate;
|
|
|
|
|
|
end;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
finally
|
|
|
|
|
|
cxGrid.EndUpdate;
|
2007-11-16 20:58:56 +00:00
|
|
|
|
end;
|
|
|
|
|
|
end;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
2009-04-16 15:31:51 +00:00
|
|
|
|
procedure TfrViewDetalleReservas.SetAlmacenObra(const Value: Integer);
|
|
|
|
|
|
begin
|
|
|
|
|
|
FIDAlmacenObra := Value;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
2007-11-16 20:58:56 +00:00
|
|
|
|
procedure TfrViewDetalleReservas.SetDetalleReservas(const Value: IBizDetalleReservas);
|
|
|
|
|
|
begin
|
|
|
|
|
|
FDetalleReservas := Value;
|
|
|
|
|
|
if Assigned(FDetalleReservas) then
|
|
|
|
|
|
dsDataSource.DataTable := FDetalleReservas.DataTable
|
|
|
|
|
|
else
|
|
|
|
|
|
dsDataSource.DataTable := Nil;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
2008-11-07 21:05:48 +00:00
|
|
|
|
procedure TfrViewDetalleReservas.SetObras(const Value: TStringList);
|
|
|
|
|
|
var
|
|
|
|
|
|
Nivel: TcxGridLevel;
|
|
|
|
|
|
i: integer;
|
|
|
|
|
|
begin
|
|
|
|
|
|
FObras := Value;
|
|
|
|
|
|
eAlmacen.Caption := 'Obra';
|
|
|
|
|
|
|
|
|
|
|
|
if Assigned(FObras) then
|
|
|
|
|
|
begin
|
|
|
|
|
|
cxGrid.BeginUpdate;
|
|
|
|
|
|
try
|
|
|
|
|
|
with cxListaAlmacenesObras.Properties.Items do
|
|
|
|
|
|
begin
|
|
|
|
|
|
BeginUpdate;
|
|
|
|
|
|
try
|
|
|
|
|
|
Clear;
|
|
|
|
|
|
for i := 0 to FObras.Count - 1 do
|
|
|
|
|
|
Add(FObras.Names[i]);
|
|
|
|
|
|
finally
|
|
|
|
|
|
EndUpdate;
|
|
|
|
|
|
end;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
finally
|
|
|
|
|
|
cxGrid.EndUpdate;
|
|
|
|
|
|
end;
|
|
|
|
|
|
end;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
2007-11-16 20:58:56 +00:00
|
|
|
|
end.
|