git-svn-id: https://192.168.0.254/svn/Proyectos.LuisLeon_FactuGES2/trunk@112 b2cfbe5a-eba1-4a0c-8b32-7feea0a119f2
307 lines
13 KiB
ObjectPascal
307 lines
13 KiB
ObjectPascal
unit uViewInfMargenArticulo;
|
|
|
|
interface
|
|
|
|
uses
|
|
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
|
Dialogs, uViewInformeBase, ActnList, ImgList, PngImageList, uViewGrid,
|
|
uViewInformeBaseGrid, uViewSumarios, TBXDkPanels, StdCtrls,
|
|
uViewAgrupaciones, uCustomView, uViewBase, uViewColumnas, ComCtrls,
|
|
TB2Dock, uViewInformeBaseParametros, uBizInformes, cxStyles,
|
|
cxCustomData, cxGraphics, cxFilter, cxData, cxDataStorage, cxEdit, DB,
|
|
cxDBData, cxGridLevel, cxClasses, cxControls, cxGridCustomView,
|
|
cxGridCustomTableView, cxGridTableView, cxGridDBTableView, cxGrid,
|
|
cxTextEdit, uViewFiltros, uBizInfMargenArticulo,
|
|
uViewPeriodoFechasInforme, uViewInfMargenArticuloGrid, cxContainer, uViewFiltroBase,
|
|
uDADataTable, uInfMargenArticuloController, uDAInterfaces, uIDataModuleInfMargenArticulo;
|
|
|
|
type
|
|
IViewInfMargenArticulo = interface(IViewInformeBase)
|
|
['{B9426535-792E-47C3-825E-1EB378FD4AB7}']
|
|
function GetDatos : IBizInfMargenArticulo;
|
|
procedure SetDatos (const Value : IBizInfMargenArticulo);
|
|
property Datos : IBizInfMargenArticulo read GetDatos write SetDatos;
|
|
|
|
function GetController : IInfMargenArticuloController;
|
|
procedure SetController (const Value : IInfMargenArticuloController);
|
|
property Controller: IInfMargenArticuloController read GetController write SetController;
|
|
end;
|
|
|
|
TfrViewInfMargenArticulo = class(TfrViewInformeBase, IViewInfMargenArticulo)
|
|
actPeriodoFechas: TAction;
|
|
frViewInfMargenArticuloGrid1: TfrViewInfMargenArticuloGrid;
|
|
frViewPeriodoFechasInforme1: TfrViewPeriodoFechasInforme;
|
|
dsVentasTerminadas: TDADataSource;
|
|
procedure actRefrescarExecute(Sender: TObject);
|
|
procedure actPeriodoFechasExecute(Sender: TObject);
|
|
procedure frViewInfMargenArticuloGrid1cxGridViewPOR_MARGEN_PRO_COMPHeaderClick(
|
|
Sender: TObject);
|
|
procedure frViewInfMargenArticuloGrid1cxGridViewCANTIDADHeaderClick(
|
|
Sender: TObject);
|
|
procedure frViewInfMargenArticuloGrid1cxGridViewIMP_MARGEN_PRO_COMP_TOTALHeaderClick(
|
|
Sender: TObject);
|
|
procedure frViewInfMargenArticuloGrid1cxGridViewPOR_MARGEN_ULT_VENT_ULT_COMPHeaderClick(
|
|
Sender: TObject);
|
|
procedure frViewInfMargenArticuloGrid1cxGridViewIMP_MARGEN_ULT_VENT_ULT_COMPHeaderClick(
|
|
Sender: TObject);
|
|
procedure frViewInfMargenArticuloGrid1cxGridViewPOR_MARGEN_PRO_VENT_PRO_COMPHeaderClick(
|
|
Sender: TObject);
|
|
procedure frViewInfMargenArticuloGrid1cxGridViewIMP_MARGEN_PRO_VENT_PRO_COMPHeaderClick(
|
|
Sender: TObject);
|
|
|
|
protected
|
|
FDatos : IBizInfMargenArticulo;
|
|
FController : IInfMargenArticuloController;
|
|
FModificado : Boolean;
|
|
procedure OnViewInformeBaseGridChanged(Sender : TObject);
|
|
procedure OnFilterChanged(Sender : TObject);
|
|
procedure ActivarTarea(const ATarea: Integer); override;
|
|
function GetFocusedView: TcxGridDBTableView; override;
|
|
function GetDatos : IBizInfMargenArticulo;
|
|
procedure SetDatos (const Value : IBizInfMargenArticulo);
|
|
function GetController : IInfMargenArticuloController;
|
|
procedure SetController (const Value : IInfMargenArticuloController);
|
|
|
|
public
|
|
FAgrupado: TEnumAgrupaciones;
|
|
property Datos : IBizInfMargenArticulo read GetDatos write SetDatos;
|
|
constructor Create(AOwner: TComponent); override;
|
|
procedure Refresh; override;
|
|
end;
|
|
|
|
implementation
|
|
{$R *.dfm}
|
|
|
|
uses schInfMargenArticuloClient_Intf, StrUtils;
|
|
|
|
const
|
|
PERIODO = 0;
|
|
|
|
|
|
|
|
{ TfrViewInfMargenArticulo }
|
|
|
|
constructor TfrViewInfMargenArticulo.Create(AOwner: TComponent);
|
|
begin
|
|
inherited;
|
|
frViewInfMargenArticuloGrid1.OnViewChanged := OnViewInformeBaseGridChanged;
|
|
frViewInfMargenArticuloGrid1.OnFilterChanged := OnFilterChanged;
|
|
frViewColumnas1.ViewInformeBaseGrid := frViewInfMargenArticuloGrid1;
|
|
frViewAgrupaciones1.ViewInformeBaseGrid := frViewInfMargenArticuloGrid1;
|
|
frViewSumarios1.ViewInformeBaseGrid := frViewInfMargenArticuloGrid1;
|
|
frViewFiltros1.ViewInformeBaseGrid := frViewInfMargenArticuloGrid1;
|
|
pcParametros.ActivePage := TabSheet5;
|
|
end;
|
|
|
|
|
|
procedure TfrViewInfMargenArticulo.frViewInfMargenArticuloGrid1cxGridViewCANTIDADHeaderClick(
|
|
Sender: TObject);
|
|
begin
|
|
inherited;
|
|
frViewInfMargenArticuloGrid1.cxGridView.DataController.Groups.DataController.BeginUpdate;
|
|
frViewInfMargenArticuloGrid1.cxGridView.GetColumnByFieldName(fld_InfMargenPorFacturaCANTIDAD).SortOrder := soAscending;
|
|
frViewInfMargenArticuloGrid1.cxGridView.GetColumnByFieldName(fld_InfMargenPorFacturaCANTIDAD).Summary.SortByGroupFooterSummary := True;
|
|
frViewInfMargenArticuloGrid1.cxGridView.DataController.Groups.DataController.EndUpdate;
|
|
end;
|
|
|
|
procedure TfrViewInfMargenArticulo.frViewInfMargenArticuloGrid1cxGridViewIMP_MARGEN_PRO_COMP_TOTALHeaderClick(
|
|
Sender: TObject);
|
|
begin
|
|
inherited;
|
|
frViewInfMargenArticuloGrid1.cxGridView.DataController.Groups.DataController.BeginUpdate;
|
|
frViewInfMargenArticuloGrid1.cxGridView.GetColumnByFieldName(fld_InfMargenPorFacturaIMP_MARGEN_PRO_COMP_TOTAL).SortOrder := soAscending;
|
|
frViewInfMargenArticuloGrid1.cxGridView.GetColumnByFieldName(fld_InfMargenPorFacturaIMP_MARGEN_PRO_COMP_TOTAL).Summary.SortByGroupFooterSummary := True;
|
|
frViewInfMargenArticuloGrid1.cxGridView.DataController.Groups.DataController.EndUpdate;
|
|
end;
|
|
|
|
procedure TfrViewInfMargenArticulo.frViewInfMargenArticuloGrid1cxGridViewIMP_MARGEN_PRO_VENT_PRO_COMPHeaderClick(
|
|
Sender: TObject);
|
|
begin
|
|
inherited;
|
|
frViewInfMargenArticuloGrid1.cxGridView.DataController.Groups.DataController.BeginUpdate;
|
|
frViewInfMargenArticuloGrid1.cxGridView.GetColumnByFieldName(fld_InfMargenPorClienteIMP_MARGEN_PRO_VENT_PRO_COMP).SortOrder := soAscending;
|
|
frViewInfMargenArticuloGrid1.cxGridView.GetColumnByFieldName(fld_InfMargenPorClienteIMP_MARGEN_PRO_VENT_PRO_COMP).Summary.SortByGroupFooterSummary := True;
|
|
frViewInfMargenArticuloGrid1.cxGridView.DataController.Groups.DataController.EndUpdate;
|
|
end;
|
|
|
|
procedure TfrViewInfMargenArticulo.frViewInfMargenArticuloGrid1cxGridViewIMP_MARGEN_ULT_VENT_ULT_COMPHeaderClick(
|
|
Sender: TObject);
|
|
begin
|
|
inherited;
|
|
frViewInfMargenArticuloGrid1.cxGridView.DataController.Groups.DataController.BeginUpdate;
|
|
frViewInfMargenArticuloGrid1.cxGridView.GetColumnByFieldName(fld_InfMargenPorClienteIMP_MARGEN_ULT_VENT_ULT_COMP).SortOrder := soAscending;
|
|
frViewInfMargenArticuloGrid1.cxGridView.GetColumnByFieldName(fld_InfMargenPorClienteIMP_MARGEN_ULT_VENT_ULT_COMP).Summary.SortByGroupFooterSummary := True;
|
|
frViewInfMargenArticuloGrid1.cxGridView.DataController.Groups.DataController.EndUpdate;
|
|
end;
|
|
|
|
procedure TfrViewInfMargenArticulo.frViewInfMargenArticuloGrid1cxGridViewPOR_MARGEN_PRO_COMPHeaderClick(
|
|
Sender: TObject);
|
|
begin
|
|
inherited;
|
|
frViewInfMargenArticuloGrid1.cxGridView.DataController.Groups.DataController.BeginUpdate;
|
|
frViewInfMargenArticuloGrid1.cxGridView.GetColumnByFieldName(fld_InfMargenPorFacturaPOR_MARGEN_PRO_COMP).SortOrder := soAscending;
|
|
frViewInfMargenArticuloGrid1.cxGridView.GetColumnByFieldName(fld_InfMargenPorFacturaPOR_MARGEN_PRO_COMP).Summary.SortByGroupFooterSummary := True;
|
|
frViewInfMargenArticuloGrid1.cxGridView.DataController.Groups.DataController.EndUpdate;
|
|
end;
|
|
|
|
procedure TfrViewInfMargenArticulo.frViewInfMargenArticuloGrid1cxGridViewPOR_MARGEN_PRO_VENT_PRO_COMPHeaderClick(
|
|
Sender: TObject);
|
|
begin
|
|
inherited;
|
|
frViewInfMargenArticuloGrid1.cxGridView.DataController.Groups.DataController.BeginUpdate;
|
|
frViewInfMargenArticuloGrid1.cxGridView.GetColumnByFieldName(fld_InfMargenPorClientePOR_MARGEN_PRO_VENT_PRO_COMP).SortOrder := soAscending;
|
|
frViewInfMargenArticuloGrid1.cxGridView.GetColumnByFieldName(fld_InfMargenPorClientePOR_MARGEN_PRO_VENT_PRO_COMP).Summary.SortByGroupFooterSummary := True;
|
|
frViewInfMargenArticuloGrid1.cxGridView.DataController.Groups.DataController.EndUpdate;
|
|
end;
|
|
|
|
procedure TfrViewInfMargenArticulo.frViewInfMargenArticuloGrid1cxGridViewPOR_MARGEN_ULT_VENT_ULT_COMPHeaderClick(
|
|
Sender: TObject);
|
|
begin
|
|
inherited;
|
|
frViewInfMargenArticuloGrid1.cxGridView.DataController.Groups.DataController.BeginUpdate;
|
|
frViewInfMargenArticuloGrid1.cxGridView.GetColumnByFieldName(fld_InfMargenPorClientePOR_MARGEN_ULT_VENT_ULT_COMP).SortOrder := soAscending;
|
|
frViewInfMargenArticuloGrid1.cxGridView.GetColumnByFieldName(fld_InfMargenPorClientePOR_MARGEN_ULT_VENT_ULT_COMP).Summary.SortByGroupFooterSummary := True;
|
|
frViewInfMargenArticuloGrid1.cxGridView.DataController.Groups.DataController.EndUpdate;
|
|
end;
|
|
|
|
function TfrViewInfMargenArticulo.GetController: IInfMargenArticuloController;
|
|
begin
|
|
Result := FController;
|
|
end;
|
|
|
|
function TfrViewInfMargenArticulo.GetDatos: IBizInfMargenArticulo;
|
|
begin
|
|
Result := FDatos;
|
|
end;
|
|
|
|
function TfrViewInfMargenArticulo.GetFocusedView: TcxGridDBTableView;
|
|
begin
|
|
Result := frViewInfMargenArticuloGrid1.cxGridView;
|
|
end;
|
|
|
|
procedure TfrViewInfMargenArticulo.Refresh;
|
|
var
|
|
AColumns : TStringList;
|
|
AColumnsGroup : TStringList;
|
|
i: Integer;
|
|
AWhere : String;
|
|
begin
|
|
inherited;
|
|
ShowHourglassCursor;
|
|
actRefrescar.Enabled := False;
|
|
|
|
AWhere := '''' + ReplaceStr(DateToStr(frViewPeriodoFechasInforme1.FechaInicial),'/','.') + ''' and ''' + ReplaceStr(DateToStr(frViewPeriodoFechasInforme1.FechaFinal),'/','.') + '''';
|
|
// FiltrarEmpresa(Result);
|
|
|
|
frViewInfMargenArticuloGrid1.OnViewChanged := nil;
|
|
frViewInfMargenArticuloGrid1.OnFilterChanged := nil;
|
|
|
|
try
|
|
// Calcular las columnas a pedir al servidor
|
|
AColumns := frViewColumnas1.GetCheckedColumns;
|
|
AColumns.sorted := true;
|
|
AColumns.Duplicates := dupIgnore;
|
|
|
|
//Añadimos el nombre de los campos a los que referencia los captions de agrupacion
|
|
AColumnsGroup := frViewAgrupaciones1.GetAgrupaciones;
|
|
for i:= 0 to AColumnsGroup.Count - 1 do
|
|
AColumns.Add((frViewInfMargenArticuloGrid1 as IViewInformeBaseGrid).GetColumnByCaption(AColumnsGroup.Strings[i]).DataBinding.FieldName);
|
|
|
|
case FAgrupado of
|
|
tCliente: FDatos := FController.BuscarAgrupadoPorCliente(AColumns.CommaText, Awhere);
|
|
tArticulo: FDatos := FController.BuscarAgrupadoPorArticulo(AColumns.CommaText, Awhere);
|
|
tFactura: FDatos := FController.BuscarAgrupadoPorFactura(AColumns.CommaText, Awhere);
|
|
end;
|
|
dsVentasTerminadas.DataTable := FDatos.Datatable;
|
|
frViewInfMargenArticuloGrid1.FocusedView.DataController.DataSource := dsVentasTerminadas;
|
|
|
|
with Datos.DataTable do
|
|
begin
|
|
DisableControls;
|
|
try
|
|
Active := False;
|
|
{
|
|
LoadSchema;
|
|
|
|
ParamByName('FECHAINI').AsDateTime := frViewPeriodoFechasInforme1.FechaInicial;
|
|
ParamByName('FECHAFIN').AsDateTime := frViewPeriodoFechasInforme1.FechaFinal;
|
|
|
|
// ParamByName('FECHAINI2').AsDateTime := frViewPeriodoFechasInforme1.FechaInicial; //'12.12.2000';
|
|
// ParamByName('FECHAFIN2').AsDateTime := frViewPeriodoFechasInforme1.FechaFinal;
|
|
}
|
|
Active := True;
|
|
|
|
frViewColumnas1.Execute;
|
|
frViewAgrupaciones1.Execute;
|
|
frViewSumarios1.Refresh;
|
|
frViewFiltros1.Refresh;
|
|
pnlTareas.Visible := True;
|
|
|
|
if Assigned(FOnViewChanged) then
|
|
FOnViewChanged(Self);
|
|
finally
|
|
EnableControls;
|
|
frViewInfMargenArticuloGrid1.Refresh;
|
|
frViewInfMargenArticuloGrid1.ExpandirTodo;
|
|
frViewInfMargenArticuloGrid1.GotoFirst;
|
|
|
|
//Para que no lo incluya en la agrupacion del distinc y luego no salga
|
|
frViewInfMargenArticuloGrid1.cxGridViewID_DETALLE.Visible := False;
|
|
end;
|
|
end;
|
|
|
|
finally
|
|
FreeAndNil(AColumns);
|
|
// ViewInfMargenArticuloGrid.OnViewChanged := OnViewInformeBaseGridChanged;
|
|
// ViewInfMargenArticuloGrid.OnFilterChanged := OnFilterChanged;
|
|
actRefrescar.Enabled := True;
|
|
HideHourglassCursor;
|
|
end;
|
|
end;
|
|
|
|
procedure TfrViewInfMargenArticulo.SetController(const Value: IInfMargenArticuloController);
|
|
begin
|
|
FController := Value;
|
|
end;
|
|
|
|
procedure TfrViewInfMargenArticulo.SetDatos(const Value: IBizInfMargenArticulo);
|
|
begin
|
|
FDatos := Value;
|
|
end;
|
|
|
|
procedure TfrViewInfMargenArticulo.actRefrescarExecute(Sender: TObject);
|
|
begin
|
|
inherited;
|
|
Refresh;
|
|
end;
|
|
|
|
procedure TfrViewInfMargenArticulo.OnViewInformeBaseGridChanged(
|
|
Sender: TObject);
|
|
begin
|
|
if Assigned(Self.OnViewChanged) then
|
|
Self.OnViewChanged(Self);
|
|
end;
|
|
|
|
procedure TfrViewInfMargenArticulo.OnFilterChanged(Sender: TObject);
|
|
begin
|
|
frViewFiltros1.Refresh;
|
|
end;
|
|
|
|
procedure TfrViewInfMargenArticulo.actPeriodoFechasExecute(
|
|
Sender: TObject);
|
|
begin
|
|
inherited;
|
|
ActivarTarea(PERIODO);
|
|
end;
|
|
|
|
procedure TfrViewInfMargenArticulo.ActivarTarea(const ATarea: Integer);
|
|
begin
|
|
inherited;
|
|
case ATarea of
|
|
PERIODO : pcParametros.ActivePage := TabSheet5;
|
|
end;
|
|
end;
|
|
|
|
end.
|
|
|