git-svn-id: https://192.168.0.254/svn/Proyectos.AlonsoYSal_FactuGES/tags/1.2.0@4 9a1d36f3-7752-2d40-8ccb-50eb49674c68
200 lines
5.8 KiB
Plaintext
200 lines
5.8 KiB
Plaintext
unit uEditorPagoCliente;
|
||
|
||
interface
|
||
|
||
uses
|
||
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
||
Dialogs, uEditorDBItem, ToolWin, ComCtrls, JvExControls, JvComponent,
|
||
JvNavigationPane, ActnList, uEditorBase, StdActns, TB2Dock, TB2Toolbar, TBX, ImgList, PngImageList,
|
||
TB2Item, uEditorItem, DB, uDADataTable, uEditorDBBase, JvFormAutoSize,
|
||
uDAScriptingProvider, uDACDSDataTable, StdCtrls, pngimage, ExtCtrls,
|
||
TBXDkPanels, JvButton, AppEvnts, uCustomView, uViewBase, uViewMensaje,
|
||
JvAppStorage, JvAppRegistryStorage, JvFormPlacement,
|
||
|
||
uBizPagos, uViewDatosPago, uViewDatosYSeleccionContacto, uViewFormaPago;
|
||
|
||
type
|
||
IEditorPagoCliente = interface(IEditorDBItem)
|
||
['{14498578-0C1A-41D1-A6BE-1F9813F06A5E}']
|
||
function GetPagoCliente: IBizPagos;
|
||
procedure SetPagoCliente(const Value: IBizPagos);
|
||
property PagoCliente: IBizPagos read GetPagoCliente write SetPagoCliente;
|
||
end;
|
||
|
||
TfEditorPagoCliente = class(TfEditorDBItem, IEditorPagoCliente)
|
||
Label5: TLabel;
|
||
Bevel1: TBevel;
|
||
frViewDatosPago: TfrViewDatosPago;
|
||
frViewCliente: TfrViewDatosYSeleccionContacto;
|
||
frViewFormaPago: TfrViewFormaPago;
|
||
|
||
procedure FormShow(Sender: TObject);
|
||
procedure dsDataTableDataChange(Sender: TObject; Field: TField);
|
||
procedure actEliminarExecute(Sender: TObject);
|
||
procedure frViewClienteactElegirContactoExecute(Sender: TObject);
|
||
procedure frViewClienteactAnadirContactoExecute(Sender: TObject);
|
||
private
|
||
FPagoCliente: IBizPagos;
|
||
procedure OnContactoChanged(Sender : TObject);
|
||
protected
|
||
function GetPagoCliente: IBizPagos; virtual;
|
||
procedure SetPagoCliente(const Value: IBizPagos); virtual;
|
||
|
||
public
|
||
property PagoCliente: IBizPagos read GetPagoCliente write SetPagoCliente;
|
||
constructor Create(AOwner: TComponent); override;
|
||
destructor Destroy; override;
|
||
end;
|
||
|
||
implementation
|
||
|
||
{$R *.dfm}
|
||
|
||
uses
|
||
uCustomEditor, uDataModulePagos, uDataModuleBase, uEditorUtils, uBizContacto,
|
||
uDataModuleContactos, uDataModuleCuentas;
|
||
|
||
function ShowEditorPagoCliente (ABizObject : TDADataTableRules): TModalResult;
|
||
var
|
||
AEditor: TfEditorPagoCliente;
|
||
begin
|
||
AEditor := TfEditorPagoCliente.Create(Application);
|
||
try
|
||
AEditor.PagoCliente := (ABizObject as IBizPagos);
|
||
Result := AEditor.ShowModal;
|
||
finally
|
||
AEditor.Release;
|
||
end;
|
||
end;
|
||
|
||
{
|
||
******************************* TfEditorPagoCliente *******************************
|
||
}
|
||
function TfEditorPagoCliente.GetPagoCliente: IBizPagos;
|
||
begin
|
||
Result := FPagoCliente;
|
||
end;
|
||
|
||
procedure TfEditorPagoCliente.SetPagoCliente(const Value: IBizPagos);
|
||
begin
|
||
FPagoCliente := Value;
|
||
dsDataTable.DataTable := FPagoCliente.DataTable;
|
||
|
||
if Assigned(FPagoCliente) then
|
||
begin
|
||
frViewFormaPago.DADataSource.DataTable := dsDataTable.DataTable;
|
||
frViewDatosPago.DADataSource.DataTable := dsDataTable.DataTable;
|
||
frViewDatosPago.Cuentas := dmCuentas.getItems;
|
||
|
||
frViewCliente.Contacto := FPagoCliente.Contacto;
|
||
frViewCliente.OnContactoChanged := OnContactoChanged;
|
||
end
|
||
else
|
||
begin
|
||
frViewFormaPago.DADataSource.DataTable := Nil;
|
||
frViewDatosPago.DADataSource.DataTable := Nil;
|
||
frViewDatosPago.Cuentas := Nil;
|
||
frViewCliente.Contacto := Nil;
|
||
frViewCliente.OnContactoChanged := Nil;
|
||
end;
|
||
end;
|
||
|
||
procedure TfEditorPagoCliente.FormShow(Sender: TObject);
|
||
begin
|
||
inherited;
|
||
|
||
if not Assigned(PagoCliente) then
|
||
raise Exception.Create('No hay ning<6E>n cobro de cliente asignado');
|
||
|
||
PagoCliente.DataTable.Active := True;
|
||
end;
|
||
|
||
destructor TfEditorPagoCliente.Destroy;
|
||
begin
|
||
FPagoCliente := NIL;
|
||
inherited;
|
||
end;
|
||
|
||
constructor TfEditorPagoCliente.Create(AOwner: TComponent);
|
||
begin
|
||
inherited;
|
||
end;
|
||
|
||
procedure TfEditorPagoCliente.dsDataTableDataChange(Sender: TObject;
|
||
Field: TField);
|
||
begin
|
||
inherited;
|
||
if Assigned(FPagoCliente) and (not (FPagoCliente.DataTable.Fetching) or
|
||
not (FPagoCliente.DataTable.Opening) or not (FPagoCliente.DataTable.Closing)) then
|
||
begin
|
||
if Length(FPagoCliente.NOMBRE) = 0 then
|
||
JvNavPanelHeader.Caption := 'Nuevo cobro de cliente'
|
||
else
|
||
JvNavPanelHeader.Caption := 'Cobro de cliente - ' + FPagoCliente.Nombre;
|
||
Caption := JvNavPanelHeader.Caption;
|
||
end;
|
||
end;
|
||
|
||
procedure TfEditorPagoCliente.actEliminarExecute(Sender: TObject);
|
||
begin
|
||
if (Application.MessageBox('<27>Desea borrar este cobro?', 'Atenci<63>n', MB_YESNO) = IDYES) then
|
||
inherited;
|
||
end;
|
||
|
||
procedure TfEditorPagoCliente.OnContactoChanged(Sender: TObject);
|
||
begin
|
||
FPagoCliente.Contacto := (frViewCliente.Contacto as IBizCliente);
|
||
end;
|
||
|
||
procedure TfEditorPagoCliente.frViewClienteactElegirContactoExecute(Sender: TObject);
|
||
|
||
// inherited;
|
||
// frViewCliente.actElegirContactoExecute(Sender);
|
||
var
|
||
AContacto : IBizContacto;
|
||
begin
|
||
inherited;
|
||
{ case FContacto.Categorias.CODIGOCATEGORIA of
|
||
CLIENTE : AContacto := dmContactos.GetClientes;
|
||
PROVEEDOR : AContacto := dmContactos.GetProveedores;
|
||
INSTALADOR : AContacto := dmContactos.GetInstaladores;
|
||
end;}
|
||
|
||
AContacto := dmContactos.GetClientes;
|
||
|
||
try
|
||
if AContacto.ShowForSelect = mrOK then
|
||
begin
|
||
frViewCliente.Contacto := dmContactos.GetItemsSeleccionados(AContacto);
|
||
end;
|
||
finally
|
||
AContacto := NIL;
|
||
end;
|
||
end;
|
||
|
||
procedure TfEditorPagoCliente.frViewClienteactAnadirContactoExecute(Sender: TObject);
|
||
|
||
// inherited;
|
||
// frViewCliente.actAnadirContactoExecute(Sender);
|
||
var
|
||
AContactos : IBizContacto;
|
||
begin
|
||
AContactos := dmContactos.GetCliente(-1);
|
||
|
||
try
|
||
AContactos.DataTable.Active := True;
|
||
AContactos.Insert;
|
||
AContactos.Show;
|
||
if AContactos.DataTable.RecordCount > 0 then
|
||
frViewCliente.Contacto := AContactos;
|
||
finally
|
||
AContactos := NIL;
|
||
end;
|
||
end;
|
||
|
||
initialization
|
||
RegisterEditor(IBizPagos, ShowEditorPagoCliente, etItem);
|
||
|
||
end.
|
||
|