git-svn-id: https://192.168.0.254/svn/Proyectos.AlonsoYSal_FactuGES/trunk@17 9a1d36f3-7752-2d40-8ccb-50eb49674c68
247 lines
7.8 KiB
ObjectPascal
247 lines
7.8 KiB
ObjectPascal
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);
|
||
procedure OnListaAnosChange(Sender: TObject; const Text: string);
|
||
procedure FormShow(Sender: TObject);
|
||
|
||
private
|
||
FAlbaranesCliente: IBizAlbaranesCliente;
|
||
|
||
protected
|
||
function GetAlbaranesCliente: IBizAlbaranesCliente;
|
||
procedure SetAlbaranesCliente(const Value: IBizAlbaranesCliente);
|
||
procedure SetViewGrid(const Value: IViewGrid); override;
|
||
function GetSelectionBarVisible: Boolean;
|
||
procedure SetSelectionBarVisible(const Value: Boolean);
|
||
|
||
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
|
||
|
||
uses
|
||
uDataModuleAlbaranesCliente, uViewAlbaranesCliente, uEditorUtils,
|
||
uDBSelectionList;
|
||
|
||
{$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;
|
||
|
||
procedure TfEditorAlbaranesCliente.SetAlbaranesCliente(const Value: IBizAlbaranesCliente);
|
||
begin
|
||
FAlbaranesCliente := Value;
|
||
|
||
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;
|
||
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;
|
||
|
||
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);
|
||
var
|
||
aAux : ISelectedRowList;
|
||
begin
|
||
dmAlbaranesCliente.FiltrarAno(AlbaranesCliente, WhereDataTable, Text);
|
||
if AlbaranesCliente.DataTable.Active then
|
||
actRefrescar.Execute;
|
||
|
||
// 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;
|
||
end;
|
||
|
||
initialization
|
||
RegisterEditor(IBizAlbaranesCliente, ShowEditorAlbaranesCliente, etItems);
|
||
RegisterEditor(IBizAlbaranesCliente, ShowSelectEditorAlbaranesCliente, etSelectItems);
|
||
|
||
finalization
|
||
|
||
end.
|