2007-10-29 19:18:51 +00:00
|
|
|
unit uViewAlbaranesCliente;
|
|
|
|
|
|
|
|
|
|
interface
|
|
|
|
|
|
|
|
|
|
uses
|
2008-05-20 18:50:02 +00:00
|
|
|
Types, uViewGrid, cxStyles, cxCustomData, cxGraphics, cxFilter,
|
2007-10-29 19:18:51 +00:00
|
|
|
cxData, cxDataStorage, cxEdit, DB, cxDBData, dxPSGlbl, dxPSUtl, dxPSEngn,
|
|
|
|
|
dxPrnPg, dxBkgnd, dxWrap, dxPrnDev, dxPSCompsProvider, dxPSFillPatterns,
|
|
|
|
|
dxPSEdgePatterns, cxImageComboBox, ImgList, Controls, PngImageList,
|
|
|
|
|
cxGridCustomTableView, cxGridTableView, cxGridDBTableView,
|
2008-01-04 11:16:59 +00:00
|
|
|
cxGridCustomPopupMenu, cxGridPopupMenu, dxPSCore, dxPScxCommon, dxPScxGrid6Lnk,
|
2007-10-29 19:18:51 +00:00
|
|
|
uDADataTable, cxGridLevel, cxClasses, cxControls, cxGridCustomView, Classes,
|
|
|
|
|
cxGrid,
|
|
|
|
|
uBizAlbaranesCliente, cxCurrencyEdit, Forms, uViewFiltroBase, ComCtrls, Tabs,
|
2008-01-13 21:43:11 +00:00
|
|
|
cxPC, ActnList, TB2Item, TBX, TB2Dock, TB2Toolbar, TBXDkPanels, dxPgsDlg,
|
2011-01-19 17:09:58 +00:00
|
|
|
uDAInterfaces, uCustomView, uViewBase;
|
2008-08-27 16:48:20 +00:00
|
|
|
|
2007-10-29 19:18:51 +00:00
|
|
|
type
|
|
|
|
|
IViewAlbaranesCliente = interface(IViewGrid)
|
|
|
|
|
['{C0B0D9D9-2E0E-4CA5-88C8-B8C71CFAD59B}']
|
|
|
|
|
function GetAlbaranes: IBizAlbaranCliente;
|
|
|
|
|
procedure SetAlbaranes(const Value: IBizAlbaranCliente);
|
|
|
|
|
property Albaranes: IBizAlbaranCliente read GetAlbaranes write SetAlbaranes;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
TfrViewAlbaranesCliente = class(TfrViewGrid, IViewAlbaranesCliente)
|
|
|
|
|
cxGridViewREF_FACTURA: TcxGridDBColumn;
|
|
|
|
|
cxGridViewREFERENCIA: TcxGridDBColumn;
|
|
|
|
|
cxGridViewFECHA_ALBARAN: TcxGridDBColumn;
|
|
|
|
|
cxGridViewINCIDENCIAS_ACTIVAS: TcxGridDBColumn;
|
|
|
|
|
cxGridViewNOMBRE: TcxGridDBColumn;
|
|
|
|
|
cxGridViewSITUACION: TcxGridDBColumn;
|
|
|
|
|
cxGridViewCALLE: TcxGridDBColumn;
|
|
|
|
|
cxGridViewCODIGO_POSTAL: TcxGridDBColumn;
|
|
|
|
|
cxGridViewPOBLACION: TcxGridDBColumn;
|
|
|
|
|
cxGridViewPROVINCIA: TcxGridDBColumn;
|
|
|
|
|
cxGridViewPERSONA_CONTACTO: TcxGridDBColumn;
|
|
|
|
|
cxGridViewTELEFONO: TcxGridDBColumn;
|
|
|
|
|
cxGridViewFECHA_ENVIO: TcxGridDBColumn;
|
|
|
|
|
cxGridViewFECHA_RECEPCION: TcxGridDBColumn;
|
|
|
|
|
cxGridViewREF_PEDIDO: TcxGridDBColumn;
|
|
|
|
|
cxGridViewNOMBRE_ALMACEN: TcxGridDBColumn;
|
|
|
|
|
cxGridLevelPendientes: TcxGridLevel;
|
|
|
|
|
cxGridLevelEnviados: TcxGridLevel;
|
|
|
|
|
cxGridLevelServidos: TcxGridLevel;
|
|
|
|
|
cxGridLevelProximosAEnviar: TcxGridLevel;
|
|
|
|
|
cxStyleProximosAEnviar: TcxStyle;
|
|
|
|
|
cxStylePENDIENTES: TcxStyle;
|
|
|
|
|
cxStyleENVIADOS: TcxStyle;
|
|
|
|
|
cxStyleSERVIDOS: TcxStyle;
|
|
|
|
|
cxGridViewIMPORTE_TOTAL: TcxGridDBColumn;
|
|
|
|
|
actClientes: TAction;
|
|
|
|
|
actAlmacenes: TAction;
|
|
|
|
|
TBXItem2: TTBXItem;
|
|
|
|
|
TBXItem3: TTBXItem;
|
|
|
|
|
TBXSeparatorItem1: TTBXSeparatorItem;
|
|
|
|
|
TBXSeparatorItem2: TTBXSeparatorItem;
|
|
|
|
|
cxGridViewFECHA_PREVISTA_ENVIO: TcxGridDBColumn;
|
|
|
|
|
cxStyleRETRASADOS: TcxStyle;
|
2008-05-20 18:50:02 +00:00
|
|
|
cxGridViewINCIDENCIAS: TcxGridDBColumn;
|
2011-01-19 17:09:58 +00:00
|
|
|
cxGridViewREFERENCIA_CLIENTE: TcxGridDBColumn;
|
2007-10-29 19:18:51 +00:00
|
|
|
procedure cxGridActiveTabChanged(Sender: TcxCustomGrid; ALevel:
|
|
|
|
|
TcxGridLevel);
|
|
|
|
|
procedure cxGridViewStylesGetContentStyle(Sender: TcxCustomGridTableView;
|
|
|
|
|
ARecord: TcxCustomGridRecord; AItem: TcxCustomGridTableItem; out
|
|
|
|
|
AStyle: TcxStyle);
|
|
|
|
|
|
|
|
|
|
procedure actClientesExecute(Sender: TObject);
|
|
|
|
|
procedure actClientesUpdate(Sender: TObject);
|
|
|
|
|
procedure actAlmacenesExecute(Sender: TObject);
|
|
|
|
|
procedure actAlmacenesUpdate(Sender: TObject);
|
2008-05-20 18:50:02 +00:00
|
|
|
procedure cxGridViewINCIDENCIAS_ACTIVASGetCellHint(
|
|
|
|
|
Sender: TcxCustomGridTableItem; ARecord: TcxCustomGridRecord;
|
|
|
|
|
ACellViewInfo: TcxGridTableDataCellViewInfo; const AMousePos: TPoint;
|
|
|
|
|
var AHintText: TCaption; var AIsHintMultiLine: Boolean;
|
|
|
|
|
var AHintTextRect: TRect);
|
2008-06-03 11:15:51 +00:00
|
|
|
procedure cxGridViewDataControllerCompare(
|
|
|
|
|
ADataController: TcxCustomDataController; ARecordIndex1, ARecordIndex2,
|
|
|
|
|
AItemIndex: Integer; const V1, V2: Variant; var Compare: Integer);
|
2007-10-29 19:18:51 +00:00
|
|
|
|
|
|
|
|
private
|
|
|
|
|
//Filtros relativos a la vista
|
|
|
|
|
procedure AnadirFiltroSituaciones;
|
|
|
|
|
procedure AnadirFiltroFechas;
|
|
|
|
|
|
|
|
|
|
protected
|
|
|
|
|
FAlbaranes: IBizAlbaranCliente;
|
|
|
|
|
function GetAlbaranes: IBizAlbaranCliente;
|
|
|
|
|
procedure SetAlbaranes(const Value: IBizAlbaranCliente);
|
|
|
|
|
public
|
2008-05-20 18:50:02 +00:00
|
|
|
procedure AnadirOtrosFiltros; override;
|
2007-10-29 19:18:51 +00:00
|
|
|
property Albaranes: IBizAlbaranCliente read GetAlbaranes write SetAlbaranes;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
implementation
|
|
|
|
|
|
2008-06-03 11:15:51 +00:00
|
|
|
uses
|
|
|
|
|
SysUtils, DateUtils, variants, windows, uDataModuleAlbaranesCliente, schAlbaranesClienteClient_Intf,
|
|
|
|
|
uViewGridBase, uReferenciasUtils, cxVariants;
|
2007-10-29 19:18:51 +00:00
|
|
|
|
|
|
|
|
{$R *.dfm}
|
|
|
|
|
|
|
|
|
|
procedure TfrViewAlbaranesCliente.actAlmacenesExecute(Sender: TObject);
|
|
|
|
|
begin
|
|
|
|
|
if (cxGridViewNOMBRE_ALMACEN.GroupIndex < 0) then
|
|
|
|
|
begin
|
|
|
|
|
cxGridViewNOMBRE_ALMACEN.GroupIndex := cxGridView.GroupedColumnCount;
|
|
|
|
|
cxGridViewNOMBRE_ALMACEN.Visible := False;
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
begin
|
|
|
|
|
cxGridViewNOMBRE_ALMACEN.GroupIndex := -1;
|
|
|
|
|
cxGridViewNOMBRE_ALMACEN.Visible := True;
|
|
|
|
|
end;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
procedure TfrViewAlbaranesCliente.actAlmacenesUpdate(Sender: TObject);
|
|
|
|
|
begin
|
|
|
|
|
inherited;
|
|
|
|
|
(Sender as TAction).Checked := not (cxGridViewNOMBRE_ALMACEN.GroupIndex < 0);
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
procedure TfrViewAlbaranesCliente.actClientesExecute(Sender: TObject);
|
|
|
|
|
begin
|
|
|
|
|
inherited;
|
|
|
|
|
if (cxGridViewNOMBRE.GroupIndex < 0) then
|
|
|
|
|
begin
|
|
|
|
|
cxGridViewNOMBRE.GroupIndex := cxGridView.GroupedColumnCount;
|
|
|
|
|
cxGridViewNOMBRE.Visible := False;
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
begin
|
|
|
|
|
cxGridViewNOMBRE.GroupIndex := -1;
|
|
|
|
|
cxGridViewNOMBRE.Visible := True;
|
|
|
|
|
end;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
procedure TfrViewAlbaranesCliente.actClientesUpdate(Sender: TObject);
|
|
|
|
|
begin
|
|
|
|
|
inherited;
|
|
|
|
|
(Sender as TAction).Checked := not (cxGridViewNOMBRE.GroupIndex < 0);
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
procedure TfrViewAlbaranesCliente.AnadirFiltroFechas;
|
|
|
|
|
var
|
|
|
|
|
Columna: TcxGridDBColumn;
|
|
|
|
|
Fecha1, Fecha2: Variant;
|
|
|
|
|
FFiltro : TcxFilterCriteriaItemList;
|
|
|
|
|
begin
|
|
|
|
|
Fecha1 := frViewFiltroBase1.edtFechaIniFiltro.EditValue;
|
|
|
|
|
Fecha2 := frViewFiltroBase1.edtFechaFinFiltro.EditValue;
|
|
|
|
|
|
|
|
|
|
if not VarIsNull(Fecha1)
|
|
|
|
|
and not VarIsNull(Fecha2) then
|
|
|
|
|
begin
|
|
|
|
|
cxGridView.DataController.Filter.Options := [fcoCaseInsensitive, fcoSoftCompare];
|
|
|
|
|
FFiltro := AddFilterGrid(fboAnd);
|
|
|
|
|
|
|
|
|
|
Columna := (cxGridView as TcxGridDBTableView).GetColumnByFieldName('FECHA_PREVISTA_ENVIO');
|
|
|
|
|
FFiltro.AddItem(Columna, foBetween, varArrayOf([Fecha1, Fecha2]), VarToStr(Fecha1) + ' and ' + VarToStr(Fecha2));
|
|
|
|
|
|
|
|
|
|
// FFiltro.BoolOperatorKind := fboOr;
|
|
|
|
|
// Columna := (cxGridView as TcxGridDBTableView).GetColumnByFieldName('FECHA_ALBARAN');
|
|
|
|
|
// FFiltro.AddItem(Columna, foBetween, varArrayOf([Fecha1, Fecha2]), VarToStr(Fecha1) + ' and ' + VarToStr(Fecha2));
|
|
|
|
|
end;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
procedure TfrViewAlbaranesCliente.AnadirFiltroSituaciones;
|
|
|
|
|
var
|
|
|
|
|
FFiltro : TcxFilterCriteriaItemList;
|
|
|
|
|
begin
|
|
|
|
|
FFiltro := AddFilterGrid(fboAnd);
|
|
|
|
|
|
|
|
|
|
case cxGrid.ActiveLevel.Index of
|
|
|
|
|
1 : FFiltro.AddItem(cxGridViewSITUACION, foEqual, SITUACION_ALBARAN_PENDIENTE, SITUACION_ALBARAN_PENDIENTE);
|
|
|
|
|
2 : FFiltro.AddItem(cxGridViewSITUACION, foEqual, SITUACION_ALBARAN_ENVIADO, SITUACION_ALBARAN_ENVIADO);
|
|
|
|
|
3 : FFiltro.AddItem(cxGridViewSITUACION, foEqual, SITUACION_ALBARAN_SERVIDO, SITUACION_ALBARAN_SERVIDO);
|
|
|
|
|
4 : begin
|
|
|
|
|
FFiltro.AddItem(cxGridViewSITUACION, foEqual, SITUACION_ALBARAN_PENDIENTE, SITUACION_ALBARAN_PENDIENTE);
|
|
|
|
|
FFiltro := AddFilterGrid(fboAnd);
|
|
|
|
|
FFiltro.AddItem(cxGridViewFECHA_PREVISTA_ENVIO, foNotEqual, null, 'NO_NULO');
|
|
|
|
|
FFiltro := AddFilterGrid(fboAnd);
|
|
|
|
|
FFiltro.AddItem(cxGridViewFECHA_PREVISTA_ENVIO, foLess, DateOf(Now), 'RETRASADOS');
|
|
|
|
|
end;
|
|
|
|
|
end;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
procedure TfrViewAlbaranesCliente.AnadirOtrosFiltros;
|
|
|
|
|
begin
|
|
|
|
|
inherited;
|
|
|
|
|
|
|
|
|
|
AnadirFiltroSituaciones;
|
|
|
|
|
AnadirFiltroFechas;
|
|
|
|
|
|
|
|
|
|
//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 TfrViewAlbaranesCliente.cxGridActiveTabChanged(Sender: TcxCustomGrid; ALevel: TcxGridLevel);
|
|
|
|
|
begin
|
|
|
|
|
inherited;
|
|
|
|
|
RefrescarFiltro;
|
|
|
|
|
end;
|
|
|
|
|
|
2008-06-03 11:15:51 +00:00
|
|
|
procedure TfrViewAlbaranesCliente.cxGridViewDataControllerCompare(
|
|
|
|
|
ADataController: TcxCustomDataController; ARecordIndex1, ARecordIndex2,
|
|
|
|
|
AItemIndex: Integer; const V1, V2: Variant; var Compare: Integer);
|
|
|
|
|
begin
|
|
|
|
|
inherited;
|
|
|
|
|
if ((AItemIndex = cxGridViewREFERENCIA.Index) or
|
|
|
|
|
(AItemIndex = cxGridViewREF_FACTURA.Index) or
|
|
|
|
|
(AItemIndex = cxGridViewREF_PEDIDO.Index)) and
|
|
|
|
|
(VarType(V1) = VarType(V2)) and (VarType(V1) = varString) then
|
|
|
|
|
Compare := CompararReferencias(V1, V2)
|
|
|
|
|
else
|
|
|
|
|
Compare := VarCompare(V1, V2);
|
|
|
|
|
end;
|
|
|
|
|
|
2008-05-20 18:50:02 +00:00
|
|
|
procedure TfrViewAlbaranesCliente.cxGridViewINCIDENCIAS_ACTIVASGetCellHint(
|
|
|
|
|
Sender: TcxCustomGridTableItem; ARecord: TcxCustomGridRecord;
|
|
|
|
|
ACellViewInfo: TcxGridTableDataCellViewInfo; const AMousePos: TPoint;
|
|
|
|
|
var AHintText: TCaption; var AIsHintMultiLine: Boolean;
|
|
|
|
|
var AHintTextRect: TRect);
|
2007-10-29 19:18:51 +00:00
|
|
|
begin
|
|
|
|
|
inherited;
|
2008-05-20 18:50:02 +00:00
|
|
|
if (ARecord.Values[Sender.Index] = '1') then
|
|
|
|
|
begin
|
|
|
|
|
AIsHintMultiLine := True;
|
2014-02-18 22:41:52 +00:00
|
|
|
if not VarIsNull(ARecord.Values[cxGridViewINCIDENCIAS.Index]) then
|
|
|
|
|
AHintText := ARecord.Values[cxGridViewINCIDENCIAS.Index];
|
2007-10-29 19:18:51 +00:00
|
|
|
end;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
procedure TfrViewAlbaranesCliente.cxGridViewStylesGetContentStyle(Sender:
|
|
|
|
|
TcxCustomGridTableView; ARecord: TcxCustomGridRecord; AItem:
|
|
|
|
|
TcxCustomGridTableItem; out AStyle: TcxStyle);
|
|
|
|
|
var
|
|
|
|
|
IndiceCol: Integer;
|
|
|
|
|
ASituacion: string;
|
|
|
|
|
begin
|
|
|
|
|
inherited;
|
|
|
|
|
if Assigned(ARecord) then
|
|
|
|
|
begin
|
|
|
|
|
if Assigned((Sender as TcxGridDBTableView).GetColumnByFieldName(fld_AlbaranesClienteSITUACION)) then
|
|
|
|
|
begin
|
|
|
|
|
IndiceCol := (Sender as TcxGridDBTableView).GetColumnByFieldName(fld_AlbaranesClienteSITUACION).Index;
|
|
|
|
|
ASituacion := VarToStr(ARecord.DisplayTexts[IndiceCol]);
|
|
|
|
|
if ASituacion = SITUACION_ALBARAN_PENDIENTE then
|
|
|
|
|
begin
|
|
|
|
|
if not VarIsNull(ARecord.Values[cxGridViewFECHA_PREVISTA_ENVIO.Index]) then
|
|
|
|
|
if (StrToDate(ARecord.DisplayTexts[cxGridViewFECHA_PREVISTA_ENVIO.Index]) < DateOf(Now)) then
|
2008-05-20 18:50:02 +00:00
|
|
|
AStyle.TextColor := cxStyleRETRASADOS.TextColor
|
2007-10-29 19:18:51 +00:00
|
|
|
else
|
2008-05-20 18:50:02 +00:00
|
|
|
AStyle.TextColor := cxStylePENDIENTES.TextColor
|
2007-10-29 19:18:51 +00:00
|
|
|
else
|
2008-05-20 18:50:02 +00:00
|
|
|
AStyle.TextColor := cxStylePENDIENTES.TextColor;
|
2007-10-29 19:18:51 +00:00
|
|
|
end
|
|
|
|
|
else if ASituacion = SITUACION_ALBARAN_ENVIADO then
|
2008-05-20 18:50:02 +00:00
|
|
|
AStyle.TextColor := cxStyleENVIADOS.TextColor
|
2007-10-29 19:18:51 +00:00
|
|
|
else if ASituacion = SITUACION_ALBARAN_SERVIDO then
|
2008-05-20 18:50:02 +00:00
|
|
|
AStyle.TextColor := cxStyleSERVIDOS.TextColor;
|
2007-10-29 19:18:51 +00:00
|
|
|
end;
|
|
|
|
|
end;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
function TfrViewAlbaranesCliente.GetAlbaranes: IBizAlbaranCliente;
|
|
|
|
|
begin
|
|
|
|
|
Result := FAlbaranes;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
procedure TfrViewAlbaranesCliente.SetAlbaranes(const Value: IBizAlbaranCliente);
|
|
|
|
|
begin
|
|
|
|
|
FAlbaranes := Value;
|
|
|
|
|
if Assigned(FAlbaranes) then
|
|
|
|
|
dsDataSource.DataTable := FAlbaranes.DataTable;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
end.
|