2007-10-29 19:18:51 +00:00
|
|
|
|
unit uViewAlbaranesCliente;
|
|
|
|
|
|
|
|
|
|
|
|
interface
|
|
|
|
|
|
|
|
|
|
|
|
uses
|
|
|
|
|
|
uViewGrid, cxStyles, cxCustomData, cxGraphics, cxFilter,
|
|
|
|
|
|
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,
|
|
|
|
|
|
cxPC, ActnList, TB2Item, TBX, TB2Dock, TB2Toolbar, TBXDkPanels, dxPgsDlg;
|
|
|
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
|
PngImageList: TPngImageList;
|
|
|
|
|
|
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;
|
|
|
|
|
|
procedure cxGridActiveTabChanged(Sender: TcxCustomGrid; ALevel:
|
|
|
|
|
|
TcxGridLevel);
|
|
|
|
|
|
procedure cxGridViewCODIGOCustomDrawCell(Sender: TcxCustomGridTableView;
|
|
|
|
|
|
ACanvas: TcxCanvas; AViewInfo: TcxGridTableDataCellViewInfo; var
|
|
|
|
|
|
ADone: Boolean);
|
|
|
|
|
|
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);
|
|
|
|
|
|
procedure cxGridViewMouseMove(Sender: TObject; Shift: TShiftState; X,
|
|
|
|
|
|
Y: Integer);
|
|
|
|
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
//Filtros relativos a la vista
|
|
|
|
|
|
procedure AnadirFiltroSituaciones;
|
|
|
|
|
|
procedure AnadirFiltroFechas;
|
|
|
|
|
|
|
|
|
|
|
|
protected
|
|
|
|
|
|
FAlbaranes: IBizAlbaranCliente;
|
|
|
|
|
|
function GetAlbaranes: IBizAlbaranCliente;
|
|
|
|
|
|
procedure SetAlbaranes(const Value: IBizAlbaranCliente);
|
|
|
|
|
|
procedure AnadirOtrosFiltros; override;
|
|
|
|
|
|
|
|
|
|
|
|
public
|
|
|
|
|
|
property Albaranes: IBizAlbaranCliente read GetAlbaranes write SetAlbaranes;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
implementation
|
|
|
|
|
|
|
|
|
|
|
|
uses SysUtils, DateUtils, variants, windows, uDataModuleAlbaranesCliente, schAlbaranesClienteClient_Intf,
|
|
|
|
|
|
uViewGridBase;
|
|
|
|
|
|
|
|
|
|
|
|
{$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;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfrViewAlbaranesCliente.cxGridViewCODIGOCustomDrawCell(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, 2);
|
|
|
|
|
|
ADone := True;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfrViewAlbaranesCliente.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_AlbaranesClienteINCIDENCIAS_ACTIVAS).Index)
|
|
|
|
|
|
and (Rec.Selected)
|
|
|
|
|
|
and (Albaranes.DataTable.FieldByName(fld_AlbaranesClienteINCIDENCIAS_ACTIVAS).AsInteger = 1) then begin
|
|
|
|
|
|
sNewHint := Albaranes.DataTable.FieldByName(fld_AlbaranesClienteINCIDENCIAS).AsString;
|
|
|
|
|
|
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 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
|
|
|
|
|
|
AStyle := cxStyleRETRASADOS
|
|
|
|
|
|
else
|
|
|
|
|
|
AStyle := cxStylePENDIENTES
|
|
|
|
|
|
else
|
|
|
|
|
|
AStyle := cxStylePENDIENTES;
|
|
|
|
|
|
end
|
|
|
|
|
|
else if ASituacion = SITUACION_ALBARAN_ENVIADO then
|
|
|
|
|
|
AStyle := cxStyleENVIADOS
|
|
|
|
|
|
else if ASituacion = SITUACION_ALBARAN_SERVIDO then
|
|
|
|
|
|
AStyle := cxStyleSERVIDOS;
|
|
|
|
|
|
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.
|
2008-01-04 11:16:59 +00:00
|
|
|
|
|