2007-06-21 16:02:50 +00:00
|
|
|
|
unit uEditorAlbaranesCliente;
|
|
|
|
|
|
|
|
|
|
|
|
interface
|
|
|
|
|
|
|
|
|
|
|
|
uses
|
|
|
|
|
|
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
|
|
|
|
|
Dialogs, uEditorGrid, Menus, DB, uDADataTable, JvAppStorage,
|
|
|
|
|
|
JvAppRegistryStorage, JvComponent, JvFormPlacement, ImgList,
|
|
|
|
|
|
PngImageList, StdActns, ActnList, ComCtrls, TB2ExtItems, TBXExtItems,
|
|
|
|
|
|
TBX, TB2Item, TB2Dock, TB2Toolbar, ExtCtrls, JvExControls,
|
|
|
|
|
|
JvNavigationPane, uBizAlbaranesCliente, uViewGrid, pngimage, uCustomView,
|
|
|
|
|
|
uViewBase, uViewBarraSeleccion, JvComponentBase, StdCtrls, Buttons,
|
|
|
|
|
|
cxControls, cxContainer, cxEdit, cxTextEdit, cxMaskEdit, cxDropDownEdit,
|
|
|
|
|
|
cxCalendar, TBXDkPanels;
|
|
|
|
|
|
|
|
|
|
|
|
type
|
|
|
|
|
|
IEditorAlbaranesCliente = interface(IEditorGrid)
|
|
|
|
|
|
['{AEB08024-B44B-46FD-B145-F8332BB9219F}']
|
|
|
|
|
|
function GetAlbaranesCliente: IBizAlbaranesCliente;
|
|
|
|
|
|
procedure SetAlbaranesCliente(const Value: IBizAlbaranesCliente);
|
|
|
|
|
|
property AlbaranesCliente: IBizAlbaranesCliente read GetAlbaranesCliente
|
|
|
|
|
|
write SetAlbaranesCliente;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
TfEditorAlbaranesCliente = class(TfEditorGrid, IEditorAlbaranesCliente)
|
|
|
|
|
|
frViewBarraSeleccion: TfrViewBarraSeleccion;
|
|
|
|
|
|
actPagar: TAction;
|
|
|
|
|
|
TBXItem36: TTBXItem;
|
|
|
|
|
|
TBXSeparatorItem16: TTBXSeparatorItem;
|
|
|
|
|
|
procedure actEliminarExecute(Sender: TObject);
|
|
|
|
|
|
procedure actModificarExecute(Sender: TObject);
|
|
|
|
|
|
procedure actNuevoExecute(Sender: TObject);
|
|
|
|
|
|
procedure frViewBarraSeleccionactSeleccionarExecute(Sender: TObject);
|
|
|
|
|
|
procedure frViewBarraSeleccionactCancelarExecute(Sender: TObject);
|
|
|
|
|
|
procedure actPagarExecute(Sender: TObject);
|
|
|
|
|
|
procedure edtFechaFiltro1PropertiesEditValueChanged(Sender: TObject);
|
2009-03-05 18:57:06 +00:00
|
|
|
|
procedure OnListaAnosChange(Sender: TObject; const Text: string);
|
|
|
|
|
|
procedure FormShow(Sender: TObject);
|
|
|
|
|
|
|
2007-06-21 16:02:50 +00:00
|
|
|
|
private
|
|
|
|
|
|
FAlbaranesCliente: IBizAlbaranesCliente;
|
2009-03-05 18:57:06 +00:00
|
|
|
|
|
2007-06-21 16:02:50 +00:00
|
|
|
|
protected
|
|
|
|
|
|
function GetAlbaranesCliente: IBizAlbaranesCliente;
|
|
|
|
|
|
procedure SetAlbaranesCliente(const Value: IBizAlbaranesCliente);
|
|
|
|
|
|
procedure SetViewGrid(const Value: IViewGrid); override;
|
|
|
|
|
|
function GetSelectionBarVisible: Boolean;
|
|
|
|
|
|
procedure SetSelectionBarVisible(const Value: Boolean);
|
2009-03-05 18:57:06 +00:00
|
|
|
|
|
2007-06-21 16:02:50 +00:00
|
|
|
|
public
|
|
|
|
|
|
constructor Create(AOwner: TComponent); override;
|
|
|
|
|
|
destructor Destroy; override;
|
|
|
|
|
|
property AlbaranesCliente: IBizAlbaranesCliente read GetAlbaranesCliente
|
|
|
|
|
|
write SetAlbaranesCliente;
|
|
|
|
|
|
property SelectionBarVisible: Boolean read GetSelectionBarVisible write
|
|
|
|
|
|
SetSelectionBarVisible;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
implementation
|
|
|
|
|
|
|
2010-01-04 18:48:47 +00:00
|
|
|
|
uses
|
|
|
|
|
|
uDataModuleAlbaranesCliente, uViewAlbaranesCliente, uEditorUtils,
|
|
|
|
|
|
uDBSelectionList;
|
2007-06-21 16:02:50 +00:00
|
|
|
|
|
|
|
|
|
|
{$R *.dfm}
|
|
|
|
|
|
|
|
|
|
|
|
function ShowEditorAlbaranesCliente (ABizObject : TDADataTableRules) : TModalResult;
|
|
|
|
|
|
var
|
|
|
|
|
|
AEditor: TfEditorAlbaranesCliente;
|
|
|
|
|
|
begin
|
|
|
|
|
|
AEditor := TfEditorAlbaranesCliente.Create(Application);
|
|
|
|
|
|
try
|
|
|
|
|
|
AEditor.AlbaranesCliente := (ABizObject as IBizAlbaranesCliente);
|
|
|
|
|
|
Result := AEditor.ShowModal;
|
|
|
|
|
|
finally
|
|
|
|
|
|
AEditor.Release;
|
|
|
|
|
|
end;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
function ShowSelectEditorAlbaranesCliente (ABizObject : TDADataTableRules) : TModalResult;
|
|
|
|
|
|
var
|
|
|
|
|
|
AEditor: TfEditorAlbaranesCliente;
|
|
|
|
|
|
begin
|
|
|
|
|
|
AEditor := TfEditorAlbaranesCliente.Create(Application);
|
|
|
|
|
|
try
|
|
|
|
|
|
AEditor.AlbaranesCliente := (ABizObject as IBizAlbaranesCliente);
|
|
|
|
|
|
AEditor.SelectionBarVisible := True;
|
|
|
|
|
|
Result := AEditor.ShowModal;
|
|
|
|
|
|
finally
|
|
|
|
|
|
AEditor.Release;
|
|
|
|
|
|
end;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
*************************** TfEditorAlbaranesCliente ***************************
|
|
|
|
|
|
}
|
|
|
|
|
|
constructor TfEditorAlbaranesCliente.Create(AOwner: TComponent);
|
|
|
|
|
|
begin
|
|
|
|
|
|
inherited;
|
|
|
|
|
|
ViewGrid := CreateView(TfrViewAlbaranesCliente) as IViewAlbaranesCliente;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
destructor TfEditorAlbaranesCliente.Destroy;
|
|
|
|
|
|
begin
|
|
|
|
|
|
FAlbaranesCliente := NIL;
|
|
|
|
|
|
inherited;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfEditorAlbaranesCliente.actEliminarExecute(Sender: TObject);
|
|
|
|
|
|
begin
|
|
|
|
|
|
if (Application.MessageBox('<27>Desea borrar este albar<61>n de cliente?', 'Atenci<63>n', MB_YESNO) = IDYES) then
|
|
|
|
|
|
begin
|
|
|
|
|
|
inherited;
|
|
|
|
|
|
ViewGrid.RefreshGrid;
|
|
|
|
|
|
end;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfEditorAlbaranesCliente.actModificarExecute(Sender: TObject);
|
|
|
|
|
|
begin
|
|
|
|
|
|
inherited;
|
|
|
|
|
|
AlbaranesCliente.Show;
|
|
|
|
|
|
ViewGrid.RefreshGrid;
|
|
|
|
|
|
ViewGrid.SyncFocusedRecordsFromDataSet;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfEditorAlbaranesCliente.actNuevoExecute(Sender: TObject);
|
|
|
|
|
|
begin
|
|
|
|
|
|
inherited;
|
|
|
|
|
|
AlbaranesCliente.Insert;
|
|
|
|
|
|
AlbaranesCliente.Show;
|
|
|
|
|
|
ViewGrid.RefreshGrid;
|
|
|
|
|
|
ViewGrid.SyncFocusedRecordsFromDataSet;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
function TfEditorAlbaranesCliente.GetAlbaranesCliente: IBizAlbaranesCliente;
|
|
|
|
|
|
begin
|
|
|
|
|
|
Result := FAlbaranesCliente;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
2009-03-05 18:57:06 +00:00
|
|
|
|
procedure TfEditorAlbaranesCliente.SetAlbaranesCliente(const Value: IBizAlbaranesCliente);
|
2007-06-21 16:02:50 +00:00
|
|
|
|
begin
|
|
|
|
|
|
FAlbaranesCliente := Value;
|
2009-03-05 18:57:06 +00:00
|
|
|
|
|
|
|
|
|
|
if Assigned(FAlbaranesCliente) then
|
|
|
|
|
|
begin
|
|
|
|
|
|
//Se guarda el where de la sentencia origen, por si el editor tiene filtros que
|
|
|
|
|
|
//afecten a este where y en un futuro se desea volver al where origen (filtro de a<>o))
|
|
|
|
|
|
WhereDataTable := FAlbaranesCliente.DataTable.Where.Clause;
|
|
|
|
|
|
|
|
|
|
|
|
dsDataTable.DataTable := FAlbaranesCliente.DataTable;
|
|
|
|
|
|
if Assigned(ViewGrid) then
|
|
|
|
|
|
(ViewGrid as IViewAlbaranesCliente).AlbaranesCliente := AlbaranesCliente;
|
|
|
|
|
|
end;
|
2007-06-21 16:02:50 +00:00
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfEditorAlbaranesCliente.SetViewGrid(const Value: IViewGrid);
|
|
|
|
|
|
begin
|
|
|
|
|
|
inherited;
|
|
|
|
|
|
if Assigned(ViewGrid) and Assigned(AlbaranesCliente) then
|
|
|
|
|
|
(ViewGrid as IViewAlbaranesCliente).AlbaranesCliente := FAlbaranesCliente;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
function TfEditorAlbaranesCliente.GetSelectionBarVisible: Boolean;
|
|
|
|
|
|
begin
|
|
|
|
|
|
Result := frViewBarraSeleccion.Visible;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfEditorAlbaranesCliente.SetSelectionBarVisible(const Value: Boolean);
|
|
|
|
|
|
begin
|
|
|
|
|
|
frViewBarraSeleccion.Visible := True;
|
|
|
|
|
|
ViewGrid.OnDblClick := frViewBarraSeleccion.actSeleccionar.OnExecute;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfEditorAlbaranesCliente.frViewBarraSeleccionactSeleccionarExecute(Sender: TObject);
|
|
|
|
|
|
begin
|
|
|
|
|
|
inherited;
|
|
|
|
|
|
if (AlbaranesCliente.DataTable.RecordCount > 0) then
|
|
|
|
|
|
begin
|
|
|
|
|
|
ViewGrid.SyncFocusedRecordsFromGrid;
|
|
|
|
|
|
ModalResult := mrOK;
|
|
|
|
|
|
end;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfEditorAlbaranesCliente.frViewBarraSeleccionactCancelarExecute(
|
|
|
|
|
|
Sender: TObject);
|
|
|
|
|
|
begin
|
|
|
|
|
|
inherited;
|
|
|
|
|
|
frViewBarraSeleccion.actCancelarExecute(Sender);
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfEditorAlbaranesCliente.actPagarExecute(Sender: TObject);
|
|
|
|
|
|
begin
|
|
|
|
|
|
inherited;
|
|
|
|
|
|
ViewGrid.SyncFocusedRecordsFromGrid;
|
|
|
|
|
|
dmAlbaranesCliente.CambiarSituacion(AlbaranesCliente);
|
|
|
|
|
|
ViewGrid.RefreshGrid;
|
|
|
|
|
|
ViewGrid.SyncFocusedRecordsFromDataSet;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfEditorAlbaranesCliente.edtFechaFiltro1PropertiesEditValueChanged(
|
|
|
|
|
|
Sender: TObject);
|
|
|
|
|
|
begin
|
|
|
|
|
|
inherited;
|
|
|
|
|
|
{
|
|
|
|
|
|
if not VarIsNull(edtFechaFiltro1.EditValue) and not VarIsNull(edtFechaFiltro2.EditValue) then
|
|
|
|
|
|
begin
|
|
|
|
|
|
if (edtFechaFiltro1.EditValue > edtFechaFiltro2.EditValue) then
|
|
|
|
|
|
begin
|
|
|
|
|
|
ShowMessage('La fecha de inicio debe ser anterior a la fecha final');
|
|
|
|
|
|
edtFechaFiltro1.SetFocus;
|
|
|
|
|
|
end
|
|
|
|
|
|
else
|
|
|
|
|
|
(ViewGrid as IViewAlbaranesCliente).AnadirFiltro2(edtFechaFiltro1.EditValue, edtFechaFiltro2.EditValue);
|
|
|
|
|
|
end;
|
|
|
|
|
|
}
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
2009-03-05 18:57:06 +00:00
|
|
|
|
procedure TfEditorAlbaranesCliente.FormShow(Sender: TObject);
|
|
|
|
|
|
begin
|
|
|
|
|
|
ListaAnos := dmAlbaranesCliente.DarListaAnosAlbaranes;
|
|
|
|
|
|
cbxListaAnos.OnChange := OnListaAnosChange; //OJO SIEMPRE ANTES DEL INHERITED
|
|
|
|
|
|
|
|
|
|
|
|
inherited;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfEditorAlbaranesCliente.OnListaAnosChange(Sender: TObject; const Text: string);
|
2010-01-04 18:48:47 +00:00
|
|
|
|
var
|
|
|
|
|
|
aAux : ISelectedRowList;
|
2009-03-05 18:57:06 +00:00
|
|
|
|
begin
|
|
|
|
|
|
dmAlbaranesCliente.FiltrarAno(AlbaranesCliente, WhereDataTable, Text);
|
|
|
|
|
|
if AlbaranesCliente.DataTable.Active then
|
|
|
|
|
|
actRefrescar.Execute;
|
2010-01-04 18:48:47 +00:00
|
|
|
|
|
|
|
|
|
|
// Quitar las selecciones que hubiera anteriormente porque ya no valen
|
|
|
|
|
|
if Supports(AlbaranesCliente, ISelectedRowList, aAux) then
|
|
|
|
|
|
if (aAux.SelectedRows.Count > 0) then
|
|
|
|
|
|
aAux.SelectedRows.Clear;
|
2009-03-05 18:57:06 +00:00
|
|
|
|
end;
|
|
|
|
|
|
|
2007-06-21 16:02:50 +00:00
|
|
|
|
initialization
|
|
|
|
|
|
RegisterEditor(IBizAlbaranesCliente, ShowEditorAlbaranesCliente, etItems);
|
|
|
|
|
|
RegisterEditor(IBizAlbaranesCliente, ShowSelectEditorAlbaranesCliente, etSelectItems);
|
|
|
|
|
|
|
|
|
|
|
|
finalization
|
|
|
|
|
|
|
|
|
|
|
|
end.
|