2007-06-21 16:02:50 +00:00
|
|
|
|
unit uEditorPresupuesto;
|
|
|
|
|
|
|
|
|
|
|
|
interface
|
|
|
|
|
|
|
|
|
|
|
|
uses
|
|
|
|
|
|
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
|
|
|
|
|
Dialogs, uEditorItem, ImgList, PngImageList, StdActns, ActnList, TBX,
|
|
|
|
|
|
TB2Item, TB2Dock, TB2Toolbar, ComCtrls, JvExControls, JvComponent,
|
|
|
|
|
|
JvNavigationPane, uEditorDBItem, DB, uDADataTable, uBizPresupuestosCliente,
|
|
|
|
|
|
uViewPresupuesto, uCustomView, uViewBase, uViewTotales, uViewGrid,
|
|
|
|
|
|
uViewContenido, TBXDkPanels, ExtCtrls, uDAScriptingProvider,
|
|
|
|
|
|
uDACDSDataTable, uViewMensaje, JvAppStorage, JvAppRegistryStorage,
|
|
|
|
|
|
JvFormPlacement, uViewDetallesPresupuesto, pngimage, StdCtrls, Mask,
|
|
|
|
|
|
DBCtrls, uViewDetallesFamilias, uViewDocumentosAsociados, uBizDocumentosAsociados,
|
|
|
|
|
|
JvComponentBase;
|
|
|
|
|
|
|
|
|
|
|
|
type
|
|
|
|
|
|
IEditorPresupuesto = interface(IEditorDBItem)
|
|
|
|
|
|
['{E06BB9E1-A95D-4983-B08D-6E1719C48D91}']
|
|
|
|
|
|
function GetPresupuesto: IBizPresupuestos;
|
|
|
|
|
|
procedure SetPresupuesto(const Value: IBizPresupuestos);
|
|
|
|
|
|
property Presupuesto: IBizPresupuestos read GetPresupuesto write SetPresupuesto;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
TfEditorPresupuesto = class(TfEditorDBItem, IEditorPresupuesto)
|
|
|
|
|
|
pagContenido: TTabSheet;
|
|
|
|
|
|
pagPlanos: TTabSheet;
|
|
|
|
|
|
frViewDetallesPresupuesto1: TfrViewDetallesPresupuesto;
|
|
|
|
|
|
frViewTotales1: TfrViewTotales;
|
|
|
|
|
|
frViewPresupuesto1: TfrViewPresupuesto;
|
|
|
|
|
|
procedure FormShow(Sender: TObject);
|
|
|
|
|
|
procedure actEliminarExecute(Sender: TObject);
|
|
|
|
|
|
procedure frViewClientePresupuesto1edtlNombrePropertiesChange(
|
|
|
|
|
|
Sender: TObject);
|
|
|
|
|
|
procedure actGuardarExecute(Sender: TObject);
|
|
|
|
|
|
private
|
|
|
|
|
|
FPresupuesto : IBizPresupuestos;
|
|
|
|
|
|
FViewPresupuesto : IViewPresupuesto;
|
|
|
|
|
|
FViewDocumentosPresupuesto : IViewDocumentosAsociados;
|
|
|
|
|
|
protected
|
|
|
|
|
|
function GetPresupuesto: IBizPresupuestos;
|
|
|
|
|
|
procedure SetPresupuesto(const Value: IBizPresupuestos);
|
|
|
|
|
|
|
|
|
|
|
|
function GetViewPresupuesto: IViewPresupuesto;
|
|
|
|
|
|
procedure SetViewPresupuesto(const Value: IViewPresupuesto);
|
|
|
|
|
|
property ViewPresupuesto: IViewPresupuesto read GetViewPresupuesto write
|
|
|
|
|
|
SetViewPresupuesto;
|
|
|
|
|
|
|
|
|
|
|
|
//DOCUMENTOS ASOCIADOS
|
|
|
|
|
|
function GetViewDocumentosPresupuesto: IViewDocumentosAsociados;
|
|
|
|
|
|
procedure SetViewDocumentosPresupuesto(const Value: IViewDocumentosAsociados);
|
|
|
|
|
|
property ViewDocumentosPresupuesto: IViewDocumentosAsociados read GetViewDocumentosPresupuesto write
|
|
|
|
|
|
SetViewDocumentosPresupuesto;
|
|
|
|
|
|
public
|
|
|
|
|
|
property Presupuesto: IBizPresupuestos read GetPresupuesto write SetPresupuesto;
|
|
|
|
|
|
constructor Create(AOwner: TComponent); override;
|
|
|
|
|
|
destructor Destroy; override;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
implementation
|
|
|
|
|
|
|
|
|
|
|
|
{$R *.dfm}
|
|
|
|
|
|
|
|
|
|
|
|
uses
|
|
|
|
|
|
uEditorUtils, DateUtils, schPresupuestosClient_Intf, uDataModuleMontajes;
|
|
|
|
|
|
|
|
|
|
|
|
function ShowEditorPresupuesto (ABizObject : TDADataTableRules) : TModalResult;
|
|
|
|
|
|
var
|
|
|
|
|
|
AEditor: TfEditorPresupuesto;
|
|
|
|
|
|
begin
|
|
|
|
|
|
AEditor := TfEditorPresupuesto.Create(Application);
|
|
|
|
|
|
try
|
|
|
|
|
|
AEditor.Presupuesto := (ABizObject as IBizPresupuestos);
|
|
|
|
|
|
Result := AEditor.ShowModal;
|
|
|
|
|
|
finally
|
|
|
|
|
|
AEditor.Release;
|
|
|
|
|
|
end;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
{ TfEditorPresupuesto }
|
|
|
|
|
|
|
|
|
|
|
|
function TfEditorPresupuesto.GetPresupuesto: IBizPresupuestos;
|
|
|
|
|
|
begin
|
|
|
|
|
|
Result := FPresupuesto;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
function TfEditorPresupuesto.GetViewPresupuesto: IViewPresupuesto;
|
|
|
|
|
|
begin
|
|
|
|
|
|
Result := FViewPresupuesto;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfEditorPresupuesto.SetPresupuesto(const Value: IBizPresupuestos);
|
|
|
|
|
|
begin
|
|
|
|
|
|
FPresupuesto := Value;
|
|
|
|
|
|
|
|
|
|
|
|
if Assigned(FPresupuesto) then
|
|
|
|
|
|
begin
|
|
|
|
|
|
dsDataTable.DataTable := FPresupuesto.DataTable;
|
|
|
|
|
|
frViewTotales1.DADataSource.DataTable := FPresupuesto.DataTable;
|
|
|
|
|
|
frViewDetallesPresupuesto1.DADataSource.DataTable := FPresupuesto.Detalles.DataTable;
|
|
|
|
|
|
|
|
|
|
|
|
if Assigned(FViewPresupuesto) then
|
|
|
|
|
|
FViewPresupuesto.Presupuesto := Presupuesto;
|
|
|
|
|
|
|
|
|
|
|
|
//DOCUMENTOS ASOCIADOS
|
|
|
|
|
|
if Assigned(FViewDocumentosPresupuesto) then
|
|
|
|
|
|
begin
|
|
|
|
|
|
FViewDocumentosPresupuesto.GestorDocumentos := (Presupuesto as IBizDocumentosAsociados).GestorDocumentos;
|
|
|
|
|
|
FViewDocumentosPresupuesto.GestorDocumentos.ModoInsert := (Presupuesto.DataTable.State = dsInsert);
|
|
|
|
|
|
end;
|
|
|
|
|
|
end;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfEditorPresupuesto.SetViewPresupuesto(
|
|
|
|
|
|
const Value: IViewPresupuesto);
|
|
|
|
|
|
begin
|
|
|
|
|
|
FViewPresupuesto := Value;
|
|
|
|
|
|
|
|
|
|
|
|
if Assigned(FViewPresupuesto) and Assigned(Presupuesto) then
|
|
|
|
|
|
FViewPresupuesto.Presupuesto := Presupuesto;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfEditorPresupuesto.FormShow(Sender: TObject);
|
|
|
|
|
|
begin
|
|
|
|
|
|
inherited;
|
|
|
|
|
|
|
|
|
|
|
|
if not Assigned(FViewPresupuesto) then
|
|
|
|
|
|
raise Exception.Create('No hay ninguna vista asignada');
|
|
|
|
|
|
|
|
|
|
|
|
if not Assigned(Presupuesto) then
|
|
|
|
|
|
raise Exception.Create('No hay ning<6E>n presupuesto asignado');
|
|
|
|
|
|
|
|
|
|
|
|
//DOCUMENTOS ASOCIADOS
|
|
|
|
|
|
//En el caso de no existir el gestor de documentos no habilitamos la vista
|
|
|
|
|
|
if Assigned(Presupuesto.GestorDocumentos) then
|
|
|
|
|
|
begin
|
|
|
|
|
|
ViewDocumentosPresupuesto := CreateView(TfrViewDocumentosAsociados) as IViewDocumentosAsociados;
|
|
|
|
|
|
ViewDocumentosPresupuesto.ShowEmbedded(pagPlanos);
|
|
|
|
|
|
end
|
|
|
|
|
|
else
|
|
|
|
|
|
pagPlanos.TabVisible := False;
|
|
|
|
|
|
|
|
|
|
|
|
Presupuesto.DataTable.Active := True;
|
|
|
|
|
|
pgPaginas.ActivePage := pagGeneral;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
constructor TfEditorPresupuesto.Create(AOwner: TComponent);
|
|
|
|
|
|
begin
|
|
|
|
|
|
inherited;
|
|
|
|
|
|
pgPaginas.ActivePageIndex := 0;
|
|
|
|
|
|
ViewPresupuesto := frViewPresupuesto1;
|
|
|
|
|
|
|
|
|
|
|
|
//DOCUMENTOS ASOCIADOS
|
|
|
|
|
|
FViewDocumentosPresupuesto := Nil;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
destructor TfEditorPresupuesto.Destroy;
|
|
|
|
|
|
begin
|
|
|
|
|
|
FViewPresupuesto := NIL;
|
|
|
|
|
|
FPresupuesto := NIL;
|
|
|
|
|
|
|
|
|
|
|
|
//DOCUMENTOS ASOCIADOS
|
|
|
|
|
|
FViewDocumentosPresupuesto := NIL;
|
|
|
|
|
|
|
|
|
|
|
|
inherited;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfEditorPresupuesto.actEliminarExecute(Sender: TObject);
|
|
|
|
|
|
begin
|
|
|
|
|
|
if (Application.MessageBox('<27>Desea borrar este presupuesto?', 'Atenci<63>n', MB_YESNO) = IDYES) then
|
|
|
|
|
|
inherited;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfEditorPresupuesto.frViewClientePresupuesto1edtlNombrePropertiesChange(
|
|
|
|
|
|
Sender: TObject);
|
|
|
|
|
|
begin
|
|
|
|
|
|
inherited;
|
|
|
|
|
|
if Length(frViewPresupuesto1.frViewClientePresupuesto1.edtlNombre.Text) = 0 then
|
|
|
|
|
|
JvNavPanelHeader.Caption := 'Nuevo presupuesto de cliente'
|
|
|
|
|
|
else
|
|
|
|
|
|
JvNavPanelHeader.Caption := 'Presupuesto de ' +
|
|
|
|
|
|
frViewPresupuesto1.frViewClientePresupuesto1.edtlNombre.Text +
|
|
|
|
|
|
' (' + FPresupuesto.SITUACION + ')';
|
|
|
|
|
|
Caption := JvNavPanelHeader.Caption;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
function TfEditorPresupuesto.GetViewDocumentosPresupuesto: IViewDocumentosAsociados;
|
|
|
|
|
|
begin
|
|
|
|
|
|
Result := FViewDocumentosPresupuesto;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfEditorPresupuesto.SetViewDocumentosPresupuesto(const Value: IViewDocumentosAsociados);
|
|
|
|
|
|
begin
|
|
|
|
|
|
FViewDocumentosPresupuesto := Value;
|
|
|
|
|
|
|
|
|
|
|
|
if Assigned(FViewDocumentosPresupuesto) and Assigned(Presupuesto) then
|
|
|
|
|
|
FViewDocumentosPresupuesto.GestorDocumentos := (Presupuesto as IBizDocumentosASociados).GestorDocumentos;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfEditorPresupuesto.actGuardarExecute(Sender: TObject);
|
|
|
|
|
|
var
|
|
|
|
|
|
ADiasValidez : Integer;
|
|
|
|
|
|
begin
|
|
|
|
|
|
if (FPresupuesto.SITUACION = SITUACION_PENDIENTE) and
|
|
|
|
|
|
(DateOf(FPresupuesto.FECHAPRESUPUESTO) < DateOf(Now)) then
|
|
|
|
|
|
begin
|
|
|
|
|
|
if (MessageDlg('La fecha del presupuesto es antigua. <20>Desea actualizarla a d<>a de hoy?' + #10#13 +
|
|
|
|
|
|
'(La nueva fecha de validez del presupuesto se calcular<61> autom<6F>ticamente)',
|
|
|
|
|
|
mtConfirmation, [mbYes, mbNo], 0) = mrYes) then
|
|
|
|
|
|
begin
|
|
|
|
|
|
ADiasValidez := DaysBetween(FPresupuesto.VIGENCIAPRESUPUESTO, FPresupuesto.FECHAPRESUPUESTO);
|
|
|
|
|
|
FPresupuesto.Edit;
|
|
|
|
|
|
FPresupuesto.FECHAPRESUPUESTO := DateOf(Now);
|
|
|
|
|
|
FPresupuesto.VIGENCIAPRESUPUESTO := FPresupuesto.FECHAPRESUPUESTO + ADiasValidez;
|
|
|
|
|
|
FPresupuesto.Post;
|
|
|
|
|
|
end;
|
|
|
|
|
|
end
|
|
|
|
|
|
else if (FPresupuesto.SITUACION = SITUACION_ACEPTADO)
|
|
|
|
|
|
and (FPresupuesto.REFERENCIA = '') then
|
|
|
|
|
|
if (Application.MessageBox('<27>Desea crear un montaje asociado a este presupuesto?', 'Atenci<63>n', MB_YESNO) = IDYES) then
|
2017-06-01 16:26:14 +00:00
|
|
|
|
begin
|
|
|
|
|
|
inherited;
|
2007-06-21 16:02:50 +00:00
|
|
|
|
dmMontajes.NuevoMontaje(Nil, FPresupuesto);
|
2017-06-01 16:26:14 +00:00
|
|
|
|
Exit;
|
|
|
|
|
|
end;
|
2007-06-21 16:02:50 +00:00
|
|
|
|
|
|
|
|
|
|
inherited;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
initialization
|
|
|
|
|
|
RegisterEditor(IBizPresupuestos, ShowEditorPresupuesto, etItem);
|
|
|
|
|
|
|
|
|
|
|
|
finalization
|
|
|
|
|
|
|
|
|
|
|
|
end.
|