190 lines
6.1 KiB
ObjectPascal
190 lines
6.1 KiB
ObjectPascal
|
|
unit uEditorFacturaCliente;
|
|||
|
|
|
|||
|
|
interface
|
|||
|
|
|
|||
|
|
uses
|
|||
|
|
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
|||
|
|
Dialogs, uEditorDBItem, DB, uDADataTable, JvAppStorage,
|
|||
|
|
JvAppRegistryStorage, JvComponent, JvFormPlacement, ImgList,
|
|||
|
|
PngImageList, StdActns, ActnList, ComCtrls, TBX, TB2Item, TB2Dock,
|
|||
|
|
TB2Toolbar, ExtCtrls, JvExControls, JvNavigationPane,
|
|||
|
|
uViewFacturaCliente, uCustomView, uViewBase, uViewContenido, uViewTotales,
|
|||
|
|
StdCtrls, pngimage, AppEvnts,
|
|||
|
|
uBizFacturasCliente, uViewDetallesNormales, uViewDetallesFacturaCliente,
|
|||
|
|
uViewDetallesFamilias, JvComponentBase;
|
|||
|
|
|
|||
|
|
type
|
|||
|
|
IEditorFacturaCliente = interface(IEditorDBItem)
|
|||
|
|
['{6989A930-FB5B-47E7-A836-7EEB8108128F}']
|
|||
|
|
function GetFacturaCliente: IBizFacturasCliente;
|
|||
|
|
procedure SetFacturaCliente(const Value: IBizFacturasCliente);
|
|||
|
|
property FacturaCliente: IBizFacturasCliente read GetFacturaCliente write
|
|||
|
|
SetFacturaCliente;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
TfEditorFacturaCliente = class(TfEditorDBItem, IEditorFacturaCliente)
|
|||
|
|
frViewTotales1: TfrViewTotales;
|
|||
|
|
pagContenido: TTabSheet;
|
|||
|
|
frViewDetallesFacturaCliente1: TfrViewDetallesFacturaCliente;
|
|||
|
|
frViewFacturaCliente1: TfrViewFacturaCliente;
|
|||
|
|
actDesglosarIVA: TAction;
|
|||
|
|
TBXSeparatorItem14: TTBXSeparatorItem;
|
|||
|
|
TBXItem7: TTBXItem;
|
|||
|
|
TBXSubmenuItem2: TTBXSubmenuItem;
|
|||
|
|
TBXItem33: TTBXItem;
|
|||
|
|
procedure actEliminarExecute(Sender: TObject);
|
|||
|
|
procedure dsDataTableDataChange(Sender: TObject; Field: TField);
|
|||
|
|
procedure FormShow(Sender: TObject); override;
|
|||
|
|
procedure frViewDatosYSeleccionContacto1edtlNombrePropertiesChange(
|
|||
|
|
Sender: TObject);
|
|||
|
|
procedure actDesglosarIVAExecute(Sender: TObject);
|
|||
|
|
private
|
|||
|
|
FFacturaCliente: IBizFacturasCliente;
|
|||
|
|
FViewFacturaCliente: IViewFacturaCliente;
|
|||
|
|
protected
|
|||
|
|
function GetFacturaCliente: IBizFacturasCliente;
|
|||
|
|
function GetViewFactura: IViewFacturaCliente;
|
|||
|
|
procedure SetFacturaCliente(const Value: IBizFacturasCliente);
|
|||
|
|
procedure SetViewFactura(const Value: IViewFacturaCliente);
|
|||
|
|
property ViewFacturaCliente: IViewFacturaCliente read GetViewFactura write
|
|||
|
|
SetViewFactura;
|
|||
|
|
public
|
|||
|
|
constructor Create(AOwner: TComponent); override;
|
|||
|
|
destructor Destroy; override;
|
|||
|
|
property FacturaCliente: IBizFacturasCliente read GetFacturaCliente write
|
|||
|
|
SetFacturaCliente;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
var
|
|||
|
|
fEditorFacturaCliente: TfEditorFacturaCliente;
|
|||
|
|
|
|||
|
|
implementation
|
|||
|
|
|
|||
|
|
uses uEditorUtils, uDataModuleFacturasCliente, uBizImportesDetalleBase,
|
|||
|
|
uDataModulePresupuestos, schFacturasClienteClient_Intf, uExceptions;
|
|||
|
|
|
|||
|
|
{$R *.dfm}
|
|||
|
|
|
|||
|
|
function ShowEditorFacturaCliente (ABizObject : TDADataTableRules) : TModalResult;
|
|||
|
|
var
|
|||
|
|
AEditor: TfEditorFacturaCliente;
|
|||
|
|
begin
|
|||
|
|
AEditor := TfEditorFacturaCliente.Create(Application);
|
|||
|
|
try
|
|||
|
|
AEditor.FacturaCliente := (ABizObject as IBizFacturasCliente);
|
|||
|
|
Result := AEditor.ShowModal;
|
|||
|
|
finally
|
|||
|
|
AEditor.Release;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
{ TfEditorFacturaCliente }
|
|||
|
|
|
|||
|
|
{
|
|||
|
|
**************************** TfEditorFacturaCliente ****************************
|
|||
|
|
}
|
|||
|
|
constructor TfEditorFacturaCliente.Create(AOwner: TComponent);
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
// ViewFacturaCliente := CreateView(TfrViewFacturaCliente) as IViewFacturaCliente;
|
|||
|
|
pgPaginas.ActivePageIndex := 0;
|
|||
|
|
ViewFacturaCliente := frViewFacturaCliente1;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
destructor TfEditorFacturaCliente.Destroy;
|
|||
|
|
begin
|
|||
|
|
FViewFacturaCliente := NIL;
|
|||
|
|
FFacturaCliente := NIL;
|
|||
|
|
inherited;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfEditorFacturaCliente.actEliminarExecute(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
if (Application.MessageBox('<27>Desea borrar este albar<61>n de cliente?', 'Atenci<63>n', MB_YESNO) = IDYES) then
|
|||
|
|
inherited;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfEditorFacturaCliente.dsDataTableDataChange(Sender: TObject; Field:
|
|||
|
|
TField);
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
if Assigned(FFacturaCliente) and (not (FFacturaCliente.DataTable.Fetching) or
|
|||
|
|
not (FFacturaCliente.DataTable.Opening) or not (FFacturaCliente.DataTable.Closing)) then
|
|||
|
|
begin
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfEditorFacturaCliente.FormShow(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
|
|||
|
|
if not Assigned(FViewFacturaCliente) then
|
|||
|
|
raise Exception.Create('No hay ninguna vista asignada');
|
|||
|
|
|
|||
|
|
if not Assigned(FacturaCliente) then
|
|||
|
|
raise Exception.Create('No hay ning<6E>n albar<61>n asignado');
|
|||
|
|
|
|||
|
|
FacturaCliente.DataTable.Active := True;
|
|||
|
|
// FViewFacturaCliente.ShowEmbedded(pagGeneral);
|
|||
|
|
// FViewFacturaCliente.SetFocus;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
function TfEditorFacturaCliente.GetFacturaCliente: IBizFacturasCliente;
|
|||
|
|
begin
|
|||
|
|
Result := FFacturaCliente;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
function TfEditorFacturaCliente.GetViewFactura: IViewFacturaCliente;
|
|||
|
|
begin
|
|||
|
|
Result := FViewFacturaCliente;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfEditorFacturaCliente.SetFacturaCliente(const Value:
|
|||
|
|
IBizFacturasCliente);
|
|||
|
|
begin
|
|||
|
|
FFacturaCliente := Value;
|
|||
|
|
|
|||
|
|
if Assigned(FFacturaCliente) then
|
|||
|
|
begin
|
|||
|
|
dsDataTable.DataTable := FFacturaCliente.DataTable;
|
|||
|
|
frViewTotales1.DADataSource.DataTable := FFacturaCliente.DataTable;
|
|||
|
|
frViewDetallesFacturaCliente1.DADataSource.DataTable := FFacturaCliente.Detalles.DataTable;
|
|||
|
|
|
|||
|
|
if Assigned(FViewFacturaCliente) then
|
|||
|
|
FViewFacturaCliente.FacturaCliente := FFacturaCliente;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfEditorFacturaCliente.SetViewFactura(const Value:
|
|||
|
|
IViewFacturaCliente);
|
|||
|
|
begin
|
|||
|
|
FViewFacturaCliente := Value;
|
|||
|
|
|
|||
|
|
if Assigned(FViewFacturaCliente) and Assigned(FacturaCliente) then
|
|||
|
|
FViewFacturaCliente.FacturaCliente := FacturaCliente;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfEditorFacturaCliente.frViewDatosYSeleccionContacto1edtlNombrePropertiesChange(
|
|||
|
|
Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
if Length(frViewFacturaCliente1.frViewDatosYSeleccionContacto1.edtlNombre.Text) = 0 then
|
|||
|
|
JvNavPanelHeader.Caption := 'Nueva factura de cliente'
|
|||
|
|
else
|
|||
|
|
JvNavPanelHeader.Caption := 'Factura de ' + frViewFacturaCliente1.frViewDatosYSeleccionContacto1.edtlNombre.Text;
|
|||
|
|
Caption := JvNavPanelHeader.Caption;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfEditorFacturaCliente.actDesglosarIVAExecute(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
FFacturaCliente.DesglosarIVA
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
initialization
|
|||
|
|
RegisterEditor(IBizFacturasCliente, ShowEditorFacturaCliente, etItem);
|
|||
|
|
|
|||
|
|
finalization
|
|||
|
|
|
|||
|
|
end.
|