AbetoDesign_FactuGES2/Source/Modulos/Articulos/Views/uViewArticulos.pas
2020-05-06 10:08:12 +00:00

228 lines
7.6 KiB
ObjectPascal
Raw Blame History

unit uViewArticulos;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, uViewGrid, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData,
cxDataStorage, cxEdit, DB, cxDBData, uDADataTable, cxGridLevel,
cxClasses, cxControls, cxGridCustomView, cxGridCustomTableView,
cxGridTableView, cxGridDBTableView, cxGrid, uBizArticulos, ActnList, Menus,
cxGridBandedTableView, cxGridDBBandedTableView, JvComponent,
JvFormAutoSize, PngImageList, ImgList, dxPSGlbl, dxPSUtl, dxPSEngn,
dxPrnPg, dxBkgnd, dxWrap, dxPrnDev, dxPSCompsProvider, dxPSFillPatterns,
dxPSEdgePatterns, dxPSCore, dxPScxCommon, dxPScxGrid6Lnk,
cxGridCustomPopupMenu, cxGridPopupMenu, cxCurrencyEdit, cxSpinEdit, cxCheckBox,
cxCheckComboBox, cxImageComboBox, TB2Item, TBX, TB2Toolbar, TBXDkPanels,
TB2Dock, uViewFiltroBase, dxPgsDlg, uDAInterfaces, uCustomView, uViewBase;
type
IViewArticulos = interface(IViewGrid)
['{4C09BEC8-C82B-4DE8-8C36-40DB62224E95}']
function GetArticulos: IBizArticulo;
procedure SetArticulos(const Value: IBizArticulo);
property Articulos: IBizArticulo read GetArticulos write SetArticulos;
procedure SetPrecioPunto (const AValue: Currency);
function GetPrecioPunto: Currency;
property PrecioPunto : Currency read GetPrecioPunto write SetPrecioPunto;
end;
TfrViewArticulos = class(TfrViewGrid, IViewArticulos)
PngImageList: TPngImageList;
cxGridViewREFERENCIA: TcxGridDBColumn;
cxGridViewDESCRIPCION: TcxGridDBColumn;
cxGridViewFAMILIA: TcxGridDBColumn;
cxGridViewNOMBRE_PROVEEDOR: TcxGridDBColumn;
actFamilia: TAction;
actProveedor: TAction;
TBXItem2: TTBXItem;
TBXItem3: TTBXItem;
TBXSeparatorItem1: TTBXSeparatorItem;
TBXSeparatorItem2: TTBXSeparatorItem;
cxGridViewINVENTARIABLE: TcxGridDBColumn;
cxGridViewPRECIO_COSTE: TcxGridDBColumn;
cxGridViewPRECIO_PVP: TcxGridDBColumn;
cxGridViewPRECIOPVP2: TcxGridDBColumn;
cxGridViewTARIFA: TcxGridDBColumn;
procedure cxGridViewIDCustomDrawCell(
Sender: TcxCustomGridTableView; ACanvas: TcxCanvas;
AViewInfo: TcxGridTableDataCellViewInfo; var ADone: Boolean);
procedure actProveedorExecute(Sender: TObject);
procedure actProveedorUpdate(Sender: TObject);
procedure actFamiliaExecute(Sender: TObject);
procedure actFamiliaUpdate(Sender: TObject);
procedure cxGridViewMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
procedure cxGridViewPRECIOPVP2GetDisplayText(Sender: TcxCustomGridTableItem;
ARecord: TcxCustomGridRecord; var AText: string);
procedure CustomViewCreate(Sender: TObject);
protected
FPrecioPunto: Currency;
FArticulos: IBizArticulo;
function GetArticulos: IBizArticulo; virtual;
procedure SetArticulos(const Value: IBizArticulo); virtual;
procedure SetPrecioPunto (const AValue: Currency);
function GetPrecioPunto: Currency;
public
property Articulos: IBizArticulo read GetArticulos write SetArticulos;
property PrecioPunto : Currency read GetPrecioPunto write SetPrecioPunto;
end;
implementation
{$R *.dfm}
uses //uDataModuleArticulos,
schArticulosClient_Intf, uFactuGES_App, uNumUtils;
{ TfrViewArticulos }
{
******************************* TfrViewArticulos *******************************
}
function TfrViewArticulos.GetArticulos: IBizArticulo;
begin
Result := FArticulos;
end;
function TfrViewArticulos.GetPrecioPunto: Currency;
begin
Result := FPrecioPunto;
end;
procedure TfrViewArticulos.SetArticulos(const Value: IBizArticulo);
begin
FArticulos := Value;
if Assigned(FArticulos) then
dsDataSource.DataTable := FArticulos.DataTable;
end;
procedure TfrViewArticulos.SetPrecioPunto(const AValue: Currency);
begin
FPrecioPunto := AValue;
cxGridViewPRECIOPVP2.Caption := '(' + CurrToStr(FPrecioPunto) + '<27>) Precio PVP';
end;
procedure TfrViewArticulos.actFamiliaExecute(Sender: TObject);
begin
if (cxGridViewFAMILIA.GroupIndex < 0) then
begin
cxGridViewFAMILIA.GroupIndex := cxGridView.GroupedColumnCount;
cxGridViewFAMILIA.Visible := False;
end
else
begin
cxGridViewFAMILIA.GroupIndex := -1;
cxGridViewFAMILIA.Visible := True;
end;
end;
procedure TfrViewArticulos.actFamiliaUpdate(Sender: TObject);
begin
inherited;
(Sender as TAction).Checked := not (cxGridViewFAMILIA.GroupIndex < 0);
end;
procedure TfrViewArticulos.actProveedorExecute(Sender: TObject);
begin
inherited;
if (cxGridViewNOMBRE_PROVEEDOR.GroupIndex < 0) then
begin
cxGridViewNOMBRE_PROVEEDOR.GroupIndex := cxGridView.GroupedColumnCount;
cxGridViewNOMBRE_PROVEEDOR.Visible := False;
end
else
begin
cxGridViewNOMBRE_PROVEEDOR.GroupIndex := -1;
cxGridViewNOMBRE_PROVEEDOR.Visible := True;
end;
end;
procedure TfrViewArticulos.actProveedorUpdate(Sender: TObject);
begin
inherited;
(Sender as TAction).Checked := not (cxGridViewNOMBRE_PROVEEDOR.GroupIndex < 0);
end;
procedure TfrViewArticulos.CustomViewCreate(Sender: TObject);
begin
inherited;
PrecioPunto := AppFactuGES.EmpresaActiva.PRECIO_PUNTO;
end;
procedure TfrViewArticulos.cxGridViewIDCustomDrawCell(
Sender: TcxCustomGridTableView; ACanvas: TcxCanvas;
AViewInfo: TcxGridTableDataCellViewInfo; var ADone: Boolean);
var
R : TRect;
begin
inherited;
R := AViewInfo.ContentBounds;
ACanvas.FillRect(R);
ACanvas.DrawImage(PngImageList, R.Left, R.Top, 0);
ADone := True;
end;
procedure TfrViewArticulos.cxGridViewMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
var
Site : TcxGridSite;
HitTest : TcxCustomGridHitTest;
Item : TcxCustomGridTableItem;
Rec : TcxCustomGridRecord;
sNewHint : string;
begin
{Este m<>todo desaparecer<65> cuando se migre la aplicaci<63>n, es para sacar la causa de la incidencia sin necesidad de entrar en el documento}
Site := Sender as TcxGridSite;
HitTest := Site.GridView.ViewInfo.GetHitTest(X, Y);
if HitTest is TcxGridRecordCellHitTest then
begin
Item := TcxGridRecordCellHitTest(HitTest).Item;
Rec := TcxGridRecordCellHitTest(HitTest).GridRecord;
if (Item.Index = cxGridView.GetColumnByFieldName(fld_ArticulosCOMISIONABLE).Index) then begin
sNewHint := 'Todo art<72>culo comisionable se tendr<64> en cuenta para la liquidaci<63>n de comisiones de los agentes';
if (cxGrid.Hint <> sNewHint) then begin
cxGrid.ShowHint := false;
cxGrid.Hint := sNewHint;
end
else cxGrid.ShowHint := true;
end
else if (Item.Index = cxGridView.GetColumnByFieldName(fld_ArticulosINVENTARIABLE).Index) then begin
sNewHint := 'Todo art<72>culo inventariable se tendr<64> en cuenta para el control de almacenes (inventario de almac<61>n)';
if (cxGrid.Hint <> sNewHint) then begin
cxGrid.ShowHint := false;
cxGrid.Hint := sNewHint;
end
else cxGrid.ShowHint := true;
end
else begin
cxGrid.ShowHint := false;
end;
end;
end;
procedure TfrViewArticulos.cxGridViewPRECIOPVP2GetDisplayText(
Sender: TcxCustomGridTableItem; ARecord: TcxCustomGridRecord;
var AText: string);
var
ImportePVP : Double;
begin
//Se encarga de mostrar el campo calculado de importe PVP
ImportePVP := -1;
if not VarIsNull(ARecord.Values[cxGridViewPRECIO_COSTE.Index]) then
if not VarIsNull(FPrecioPunto) then
ImportePVP := RoundCurrency(ARecord.Values[cxGridViewPRECIO_COSTE.Index] * FPrecioPunto)
else
ImportePVP := 0;
if (ImportePVP <> -1) then
begin
AText := FormatCurr(',0.00 <20>;-,0.00 <20>', FloatToCurr(ImportePVP))
end;
end;
end.