2007-06-21 16:02:50 +00:00
|
|
|
|
unit uEditorComisiones;
|
|
|
|
|
|
|
|
|
|
|
|
interface
|
|
|
|
|
|
|
|
|
|
|
|
uses
|
|
|
|
|
|
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
|
|
|
|
|
Dialogs, uEditorItem, JvAppStorage, JvAppRegistryStorage, JvComponent,
|
|
|
|
|
|
JvFormPlacement, ImgList, PngImageList, StdActns, ActnList, ComCtrls,
|
|
|
|
|
|
TBX, TB2Item, TB2Dock, TB2Toolbar, pngimage, ExtCtrls, JvExControls,
|
|
|
|
|
|
JvNavigationPane, uEditorBase, uCustomView, uViewBase, StdCtrls,
|
|
|
|
|
|
uDADataTable, dxLayoutControl, cxContainer, cxEdit, cxTextEdit,
|
|
|
|
|
|
cxMaskEdit, cxDropDownEdit, cxCalendar, cxControls, dxLayoutLookAndFeels,
|
|
|
|
|
|
cxStyles, DB, cxGrid, cxCustomData, cxGraphics, cxFilter, cxData,
|
|
|
|
|
|
cxDataStorage, cxDBData, cxGridLevel, cxGridCustomTableView,
|
|
|
|
|
|
cxGridTableView, cxGridDBTableView, cxClasses, cxGridCustomView,
|
|
|
|
|
|
cxCurrencyEdit, cxSpinEdit, uBizComisiones, cxCheckBox, cxSplitter,
|
|
|
|
|
|
JvComponentBase, JvExExtCtrls, JvSplitter, JvSplit, dxPSGlbl, dxPSUtl,
|
|
|
|
|
|
dxPSEngn, dxPrnPg, dxBkgnd, dxWrap, dxPrnDev, dxPSCompsProvider,
|
|
|
|
|
|
dxPSFillPatterns, dxPSEdgePatterns, dxPSCore, dxPScxCommon, dxPScxGridLnk,
|
2007-11-07 16:56:36 +00:00
|
|
|
|
dxPSContainerLnk, dxPSdxLCLnk, uEditorGrid, Menus, TB2ExtItems,
|
|
|
|
|
|
TBXExtItems;
|
2007-06-21 16:02:50 +00:00
|
|
|
|
|
|
|
|
|
|
type
|
2007-11-07 16:56:36 +00:00
|
|
|
|
IEditorComisiones = interface(IEditorGrid)
|
2007-06-21 16:02:50 +00:00
|
|
|
|
['{C3894FB2-9030-466C-B2D9-5CF3CF5EA1B8}']
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
2007-11-07 16:56:36 +00:00
|
|
|
|
TfEditorComisiones = class(TfEditorGrid, IEditorComisiones)
|
2007-06-21 16:02:50 +00:00
|
|
|
|
Button1: TButton;
|
|
|
|
|
|
dxLayoutControl1Group_Root: TdxLayoutGroup;
|
|
|
|
|
|
dxLayoutControl1: TdxLayoutControl;
|
|
|
|
|
|
edtFechaIni: TcxDateEdit;
|
|
|
|
|
|
edtFechaFin: TcxDateEdit;
|
|
|
|
|
|
dxLayoutControl1Item2: TdxLayoutItem;
|
|
|
|
|
|
dxLayoutControl1Group1: TdxLayoutGroup;
|
|
|
|
|
|
dxLayoutLookAndFeelList1: TdxLayoutLookAndFeelList;
|
|
|
|
|
|
dxLayoutOfficeLookAndFeel1: TdxLayoutOfficeLookAndFeel;
|
|
|
|
|
|
DADataSource: TDADataSource;
|
|
|
|
|
|
dxLayoutControl1Item4: TdxLayoutItem;
|
|
|
|
|
|
cxGrid: TcxGrid;
|
|
|
|
|
|
cxGridView: TcxGridDBTableView;
|
|
|
|
|
|
cxGridViewVENDEDOR: TcxGridDBColumn;
|
|
|
|
|
|
cxGridViewPORCENTAJE: TcxGridDBColumn;
|
|
|
|
|
|
cxGridViewCOMISION: TcxGridDBColumn;
|
|
|
|
|
|
cxGridLevel: TcxGridLevel;
|
|
|
|
|
|
dxLayoutControl1Item1: TdxLayoutItem;
|
|
|
|
|
|
dxLayoutControl1Group2: TdxLayoutGroup;
|
|
|
|
|
|
dxLayoutControl1Item5: TdxLayoutItem;
|
|
|
|
|
|
edtImporteCobros: TcxCurrencyEdit;
|
|
|
|
|
|
dxLayoutControl1Item6: TdxLayoutItem;
|
|
|
|
|
|
dxLayoutControl1Group3: TdxLayoutGroup;
|
|
|
|
|
|
cxGrid1: TcxGrid;
|
|
|
|
|
|
cxGridDBTableView1: TcxGridDBTableView;
|
|
|
|
|
|
cxGridLevel1: TcxGridLevel;
|
|
|
|
|
|
dxLayoutControl1Item3: TdxLayoutItem;
|
|
|
|
|
|
cxGridDBTableView1RecID: TcxGridDBColumn;
|
|
|
|
|
|
cxGridDBTableView1SELECCION: TcxGridDBColumn;
|
|
|
|
|
|
cxGridDBTableView1CODIGOEMPRESA: TcxGridDBColumn;
|
|
|
|
|
|
cxGridDBTableView1CODIGO: TcxGridDBColumn;
|
|
|
|
|
|
cxGridDBTableView1CODIGOCONTACTO: TcxGridDBColumn;
|
|
|
|
|
|
cxGridDBTableView1NOMBRE: TcxGridDBColumn;
|
|
|
|
|
|
cxGridDBTableView1FECHAPAGO: TcxGridDBColumn;
|
|
|
|
|
|
cxGridDBTableView1IMPORTE: TcxGridDBColumn;
|
|
|
|
|
|
cxStyleRepository1: TcxStyleRepository;
|
|
|
|
|
|
cxStyleEven: TcxStyle;
|
|
|
|
|
|
cxStyleOdd: TcxStyle;
|
|
|
|
|
|
cxStyleSelection: TcxStyle;
|
|
|
|
|
|
DADataSource2: TDADataSource;
|
|
|
|
|
|
cxSplitter1: TcxSplitter;
|
|
|
|
|
|
cxGridDBTableView1DESCRIPCION: TcxGridDBColumn;
|
|
|
|
|
|
dxComponentPrinter: TdxComponentPrinter;
|
|
|
|
|
|
dxComponentPrinterLink1: TdxGridReportLink;
|
|
|
|
|
|
dxComponentPrinterLink3: TdxGridReportLink;
|
2007-11-07 16:56:36 +00:00
|
|
|
|
dxComponentPrinterLink2: TdxCompositionReportLink;
|
|
|
|
|
|
cxStyle1: TcxStyle;
|
2009-06-04 14:37:09 +00:00
|
|
|
|
cxFamilia: TcxComboBox;
|
|
|
|
|
|
dxLayoutControl1Item7: TdxLayoutItem;
|
|
|
|
|
|
dxLayoutControl1Group4: TdxLayoutGroup;
|
2007-06-21 16:02:50 +00:00
|
|
|
|
procedure Button1Click(Sender: TObject);
|
|
|
|
|
|
procedure FormShow(Sender: TObject);
|
|
|
|
|
|
procedure edtFechaIniPropertiesValidate(Sender: TObject;
|
|
|
|
|
|
var DisplayValue: Variant; var ErrorText: TCaption;
|
|
|
|
|
|
var Error: Boolean);
|
|
|
|
|
|
procedure CustomEditorGetModified(Sender: TObject;
|
|
|
|
|
|
var Modified: Boolean);
|
|
|
|
|
|
procedure cxGridDBTableView1CustomDrawCell(
|
|
|
|
|
|
Sender: TcxCustomGridTableView; ACanvas: TcxCanvas;
|
|
|
|
|
|
AViewInfo: TcxGridTableDataCellViewInfo; var ADone: Boolean);
|
|
|
|
|
|
procedure actPrevisualizarExecute(Sender: TObject);
|
2007-11-07 16:56:36 +00:00
|
|
|
|
procedure tbxEditFiltroChange(Sender: TObject; const Text: String);
|
|
|
|
|
|
procedure actQuitarFiltroExecute(Sender: TObject);
|
|
|
|
|
|
procedure actAnchoAutoExecute(Sender: TObject);
|
|
|
|
|
|
procedure actPrevisualizarUpdate(Sender: TObject);
|
2007-06-21 16:02:50 +00:00
|
|
|
|
private
|
|
|
|
|
|
FComisiones : TDADataTable;
|
|
|
|
|
|
FCobrosComision : IBizCobrosComision;
|
|
|
|
|
|
procedure OnTotalChanged(Sender : TObject);
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
var
|
|
|
|
|
|
fEditorComisiones: TfEditorComisiones;
|
|
|
|
|
|
|
|
|
|
|
|
implementation
|
|
|
|
|
|
|
|
|
|
|
|
uses uDataModuleComisiones, DateUtils, FactuGES_Intf, schComisionesClient_Intf;
|
|
|
|
|
|
|
|
|
|
|
|
{$R *.dfm}
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfEditorComisiones.Button1Click(Sender: TObject);
|
|
|
|
|
|
begin
|
|
|
|
|
|
//Liberamos
|
|
|
|
|
|
if Assigned(FCobrosComision) then
|
|
|
|
|
|
FCobrosComision := Nil;
|
|
|
|
|
|
|
2009-06-04 14:37:09 +00:00
|
|
|
|
FCobrosComision := dmComisiones.GetCobrosComision(edtFechaIni.Date, edtFechaFin.Date, cxFamilia.text);
|
2007-06-21 16:02:50 +00:00
|
|
|
|
DADataSource.DataTable := FCobrosComision.DataTable;
|
|
|
|
|
|
DADataSource2.DataTable := FCobrosComision.VendedoresComision.DataTable;
|
|
|
|
|
|
FCobrosComision.OnTotalChanged := OnTotalChanged;
|
|
|
|
|
|
DADataSource2.DataTable.Active := True; //No cambiar el orden es importante que el orden sea este
|
|
|
|
|
|
DADataSource.DataTable.Active := True;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfEditorComisiones.FormShow(Sender: TObject);
|
|
|
|
|
|
begin
|
|
|
|
|
|
inherited;
|
|
|
|
|
|
edtFechaIni.Date := DateOf(StartOfTheMonth(Now));
|
|
|
|
|
|
edtFechaFin.Date := DateOf(EndOfTheMonth(Now));
|
2007-11-07 16:56:36 +00:00
|
|
|
|
|
|
|
|
|
|
ViewGrid
|
2007-06-21 16:02:50 +00:00
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfEditorComisiones.edtFechaIniPropertiesValidate(Sender: TObject;
|
|
|
|
|
|
var DisplayValue: Variant; var ErrorText: TCaption; var Error: Boolean);
|
|
|
|
|
|
begin
|
|
|
|
|
|
inherited;
|
|
|
|
|
|
if Length(DisplayValue) = 0 then
|
|
|
|
|
|
begin
|
|
|
|
|
|
Error := True;
|
|
|
|
|
|
ErrorText := 'La fecha no puede ser vac<61>a';
|
|
|
|
|
|
end;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfEditorComisiones.CustomEditorGetModified(Sender: TObject;
|
|
|
|
|
|
var Modified: Boolean);
|
|
|
|
|
|
begin
|
|
|
|
|
|
inherited;
|
|
|
|
|
|
Modified := False;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfEditorComisiones.cxGridDBTableView1CustomDrawCell(
|
|
|
|
|
|
Sender: TcxCustomGridTableView; ACanvas: TcxCanvas;
|
|
|
|
|
|
AViewInfo: TcxGridTableDataCellViewInfo; var ADone: Boolean);
|
|
|
|
|
|
var
|
|
|
|
|
|
IndiceCol : Integer;
|
|
|
|
|
|
begin
|
|
|
|
|
|
IndiceCol := (Sender as TcxGridDBTableView).GetColumnByFieldName(fld_CobrosCOMISIONSELECCION).Index;
|
|
|
|
|
|
if UPPERCASE(AViewInfo.GridRecord.DisplayTexts[IndiceCol]) = 'FALSE' then
|
|
|
|
|
|
begin
|
2007-11-07 16:56:36 +00:00
|
|
|
|
ACanvas.Canvas.Font := cxStyle1.Font;
|
|
|
|
|
|
// ACanvas.Canvas.Font.Style := [fsStrikeOut];
|
|
|
|
|
|
// ACanvas.Canvas.Font.Color := clGray;
|
2007-06-21 16:02:50 +00:00
|
|
|
|
end;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfEditorComisiones.OnTotalChanged(Sender: TObject);
|
|
|
|
|
|
begin
|
|
|
|
|
|
edtImporteCobros.Value := FCobrosComision.Total;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfEditorComisiones.actPrevisualizarExecute(Sender: TObject);
|
|
|
|
|
|
begin
|
2007-11-07 16:56:36 +00:00
|
|
|
|
// inherited;
|
|
|
|
|
|
|
|
|
|
|
|
dxComponentPrinterLink2.PrinterPage.PageHeader.RightTitle.Clear;
|
|
|
|
|
|
dxComponentPrinterLink2.PrinterPage.PageHeader.RightTitle.Add('Desde ' + edtFechaIni.Text + ' hasta ' + edtFechaFin.Text);
|
|
|
|
|
|
if (tbxEditFiltro.Text <> '') then
|
|
|
|
|
|
dxComponentPrinterLink2.PrinterPage.PageHeader.RightTitle.Add('Filtrado por: ' + tbxEditFiltro.Text);
|
2007-06-21 16:02:50 +00:00
|
|
|
|
dxComponentPrinter.Preview;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
2007-11-07 16:56:36 +00:00
|
|
|
|
procedure TfEditorComisiones.tbxEditFiltroChange(Sender: TObject; const Text: String);
|
|
|
|
|
|
var
|
|
|
|
|
|
Columna: TcxGridDBColumn;
|
|
|
|
|
|
i: Integer;
|
|
|
|
|
|
AItemList: TcxFilterCriteriaItemList;
|
|
|
|
|
|
AItemList2: TcxFilterCriteriaItemList;
|
|
|
|
|
|
EsPrimera: Boolean;
|
|
|
|
|
|
begin
|
|
|
|
|
|
//Sobre escribimos el evento para saltarnos toda la l<>gica del ViewGrid, ya que
|
|
|
|
|
|
//lo hacemos directamente sobre el grid del editor que nos interesa.
|
|
|
|
|
|
// inherited;
|
|
|
|
|
|
|
|
|
|
|
|
with cxGrid1.ActiveView.DataController.Filter do
|
|
|
|
|
|
begin
|
|
|
|
|
|
BeginUpdate;
|
|
|
|
|
|
try
|
|
|
|
|
|
Options := [fcoCaseInsensitive, fcoSoftCompare];
|
|
|
|
|
|
Root.Clear;
|
|
|
|
|
|
if Length(Text) > 0 then
|
|
|
|
|
|
begin
|
|
|
|
|
|
EsPrimera := True;
|
|
|
|
|
|
for i:=0 to (cxGrid1.ActiveView as TcxGridDBTableView).ColumnCount - 1 do
|
|
|
|
|
|
begin
|
|
|
|
|
|
Columna := (cxGrid1.ActiveView as TcxGridDBTableView).Columns[i];
|
|
|
|
|
|
if Columna.Visible then
|
|
|
|
|
|
begin
|
|
|
|
|
|
if EsPrimera then
|
|
|
|
|
|
begin
|
|
|
|
|
|
AItemList := Root;
|
|
|
|
|
|
AItemList.BoolOperatorKind := fboAnd;
|
|
|
|
|
|
AItemList2 := AItemList.AddItemList(fboAnd);
|
|
|
|
|
|
AItemList := AItemList2;
|
|
|
|
|
|
AItemList2 := AItemList.AddItemList(fboOr);
|
|
|
|
|
|
AItemList := AItemList2;
|
|
|
|
|
|
AItemList.AddItem(Columna, foLike, '%'+Text+'%', IntToStr(i));
|
|
|
|
|
|
EsPrimera := False;
|
|
|
|
|
|
end
|
|
|
|
|
|
else begin
|
|
|
|
|
|
AItemList2 := AItemList.AddItemList(fboOr);
|
|
|
|
|
|
AItemList2.AddItem(Columna, foLike, '%'+Text+'%', IntToStr(i));
|
|
|
|
|
|
AItemList := AItemList2;
|
|
|
|
|
|
end;
|
|
|
|
|
|
end;
|
|
|
|
|
|
end;
|
|
|
|
|
|
Active := True;
|
|
|
|
|
|
end
|
|
|
|
|
|
else
|
|
|
|
|
|
Active := False;
|
|
|
|
|
|
finally
|
|
|
|
|
|
EndUpdate;
|
|
|
|
|
|
end;
|
|
|
|
|
|
end;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfEditorComisiones.actQuitarFiltroExecute(Sender: TObject);
|
|
|
|
|
|
begin
|
|
|
|
|
|
// inherited;
|
|
|
|
|
|
tbxEditFiltro.Text := '';
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfEditorComisiones.actAnchoAutoExecute(Sender: TObject);
|
|
|
|
|
|
begin
|
|
|
|
|
|
// inherited;
|
|
|
|
|
|
cxGridDBTableView1.ApplyBestFit;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfEditorComisiones.actPrevisualizarUpdate(Sender: TObject);
|
|
|
|
|
|
begin
|
|
|
|
|
|
// inherited;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
2007-06-21 16:02:50 +00:00
|
|
|
|
end.
|