2629 lines
79 KiB
ObjectPascal
2629 lines
79 KiB
ObjectPascal
|
|
{
|
|||
|
|
===============================================================================
|
|||
|
|
Copyright (<EFBFBD>) 2003. Rodax Software.
|
|||
|
|
===============================================================================
|
|||
|
|
Los contenidos de este fichero son propiedad de Rodax Software titular del
|
|||
|
|
copyright. Este fichero s<EFBFBD>lo podr<EFBFBD> ser copiado, distribuido y utilizado,
|
|||
|
|
en su totalidad o en parte, con el permiso escrito de Rodax Software, o de
|
|||
|
|
acuerdo con los t<EFBFBD>rminos y condiciones establecidas en el acuerdo/contrato
|
|||
|
|
bajo el que se suministra.
|
|||
|
|
-----------------------------------------------------------------------------
|
|||
|
|
Web: www.rodax-software.com
|
|||
|
|
===============================================================================
|
|||
|
|
Fecha primera versi<EFBFBD>n: 09-11-2003
|
|||
|
|
Versi<EFBFBD>n actual: 1.0.4
|
|||
|
|
Fecha versi<EFBFBD>n actual: 17-11-2004
|
|||
|
|
===============================================================================
|
|||
|
|
Modificaciones:
|
|||
|
|
|
|||
|
|
Fecha Comentarios
|
|||
|
|
---------------------------------------------------------------------------
|
|||
|
|
19-07-2004 p13. En los menus contextuales deben aparecer las opciones
|
|||
|
|
de cortar, copiar y pegar.
|
|||
|
|
|
|||
|
|
05-10-2004 p26.
|
|||
|
|
|
|||
|
|
11-11-2004 p34. Las observaciones en contratos de armarios no funcionaban
|
|||
|
|
correctamente.
|
|||
|
|
|
|||
|
|
15-11-2004 Error en SalvarDetalles y SalvarPropiedades para armarios.
|
|||
|
|
|
|||
|
|
17-11-2004 Cuando ha mejorado la inserci<EFBFBD>n de un contrato cuando el c<EFBFBD>digo
|
|||
|
|
ya ha sido utilizado por otro usuario.
|
|||
|
|
===============================================================================
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
unit ContratoCliente;
|
|||
|
|
|
|||
|
|
interface
|
|||
|
|
|
|||
|
|
uses
|
|||
|
|
Windows, RdxBarras, RdxBotones, StdCtrls, RdxComboBox, RdxCampos,
|
|||
|
|
RdxMemo, RdxTitulos, Controls, ExtCtrls, RdxPaneles, Forms, Classes,
|
|||
|
|
RdxFrameContratos, ComCtrls, RdxPageControl, Grids, DBGrids, RXDBCtrl,
|
|||
|
|
Db, RdxRichEdit, Graphics, RxMemDS,IBCustomDataSet, Configuracion,
|
|||
|
|
Colores, cxDBEdit, cxDropDownEdit, cxCalendar, cxControls, cxContainer, cxEdit, cxTextEdit,
|
|||
|
|
cxMaskEdit, cxButtonEdit, AdvPanel, cxStyles, cxCustomData, cxGraphics,
|
|||
|
|
cxFilter, cxData, cxDBData, cxGridLevel, cxClasses, cxGridCustomView,
|
|||
|
|
cxGridCustomTableView, cxGridTableView, cxGridDBTableView, cxGrid,
|
|||
|
|
cxSpinEdit, ActnList, RdxFrame, cxMemo,
|
|||
|
|
cxGridCardView, cxGridDBCardView, TablaArticulos, DBCtrls, ArticuloModelo,
|
|||
|
|
Menus, am2000menuitem, am2000popupmenu, am2000, IBQuery, cxLookupEdit,
|
|||
|
|
cxDBLookupEdit, cxDBLookupComboBox, TablaDocumentos, TablaPropiedades,
|
|||
|
|
RdxEmpresaActiva, am2000utils, cxCurrencyEdit, RXCtrls, Mask, dbcgrids,
|
|||
|
|
cxDataStorage, JvExForms, JvBaseThumbnail, JvThumbViews, JvExComCtrls,
|
|||
|
|
JvComCtrls, Dialogs;
|
|||
|
|
|
|||
|
|
type
|
|||
|
|
TfrContratoCliente = class(TRdxFrameContratos)
|
|||
|
|
brSalir: TRdxBarraInferior;
|
|||
|
|
bSalir: TRdxBoton;
|
|||
|
|
brGuardar: TRdxBarraInferior;
|
|||
|
|
bGuardar: TRdxBoton;
|
|||
|
|
bCancelar: TRdxBoton;
|
|||
|
|
pnlPaginas: TRdxPanel;
|
|||
|
|
Paginas: TRdxPagesControl;
|
|||
|
|
pagCliente: TTabSheet;
|
|||
|
|
pagContenido: TTabSheet;
|
|||
|
|
pnlGridArticulos: TPanel;
|
|||
|
|
pnlBarraContenido: TRdxPanel;
|
|||
|
|
bAnadirCon: TRdxBoton;
|
|||
|
|
bEliminar: TRdxBoton;
|
|||
|
|
bEliminarTodo: TRdxBoton;
|
|||
|
|
dsContrato: TDataSource;
|
|||
|
|
dsDetallesContrato: TDataSource;
|
|||
|
|
pnlTitulo: TRdxPanelTituloOperacion;
|
|||
|
|
pnlCuerpo: TPanel;
|
|||
|
|
pnlFactura: TAdvPanel;
|
|||
|
|
eCodigo: TLabel;
|
|||
|
|
eFechaAlta: TLabel;
|
|||
|
|
eSituacion: TLabel;
|
|||
|
|
Codigo: TcxDBButtonEdit;
|
|||
|
|
FechaContrato: TcxDBDateEdit;
|
|||
|
|
cbxSituacion: TcxDBComboBox;
|
|||
|
|
Label2: TLabel;
|
|||
|
|
CodCliente: TcxDBButtonEdit;
|
|||
|
|
eNIFCIF: TLabel;
|
|||
|
|
NIFCIF: TcxDBTextEdit;
|
|||
|
|
eNumero: TLabel;
|
|||
|
|
Numero: TcxDBTextEdit;
|
|||
|
|
ePiso: TLabel;
|
|||
|
|
Piso: TcxDBTextEdit;
|
|||
|
|
CodigoPostal: TcxDBTextEdit;
|
|||
|
|
eCodigoPostal: TLabel;
|
|||
|
|
eNombre: TLabel;
|
|||
|
|
Nombre: TcxDBTextEdit;
|
|||
|
|
eDireccion: TLabel;
|
|||
|
|
Calle: TcxDBTextEdit;
|
|||
|
|
eProvincia: TLabel;
|
|||
|
|
Provincia: TcxDBButtonEdit;
|
|||
|
|
ePoblacion: TLabel;
|
|||
|
|
Poblacion: TcxDBButtonEdit;
|
|||
|
|
gridDetalles: TcxGrid;
|
|||
|
|
VistaDetalles: TcxGridDBTableView;
|
|||
|
|
gridDetallesLevel1: TcxGridLevel;
|
|||
|
|
ActionList1: TActionList;
|
|||
|
|
actAnadirDetalle: TAction;
|
|||
|
|
actEliminarDetalle: TAction;
|
|||
|
|
actEliminarTodoDetalle: TAction;
|
|||
|
|
pagNotasVarias: TTabSheet;
|
|||
|
|
pnlFormasPago: TPanel;
|
|||
|
|
RdxPanel4: TPanel;
|
|||
|
|
eFormasPago: TLabel;
|
|||
|
|
RdxPanel5: TPanel;
|
|||
|
|
FormasPago: TcxDBMemo;
|
|||
|
|
dsPropiedadesContrato: TDataSource;
|
|||
|
|
eDocumento: TLabel;
|
|||
|
|
pnlImportes: TAdvPanel;
|
|||
|
|
cbxDocumento: TcxDBLookupComboBox;
|
|||
|
|
dsDocumentos: TDataSource;
|
|||
|
|
TablaDocumentos: TIBQuery;
|
|||
|
|
VistaPropiedades: TcxGridDBCardView;
|
|||
|
|
VistaPropiedadesDBCardViewRow2: TcxGridDBCardViewRow;
|
|||
|
|
VistaPropiedadesDBCardViewRow3: TcxGridDBCardViewRow;
|
|||
|
|
TablaPropiedades: TIBQuery;
|
|||
|
|
TablaValores: TIBQuery;
|
|||
|
|
dsValores: TDataSource;
|
|||
|
|
dsPropiedades: TDataSource;
|
|||
|
|
Label7: TLabel;
|
|||
|
|
Descuento: TcxDBTextEdit;
|
|||
|
|
Label8: TLabel;
|
|||
|
|
IVA: TcxDBTextEdit;
|
|||
|
|
actAnadirPropiedad: TAction;
|
|||
|
|
actEliminarPropiedad: TAction;
|
|||
|
|
pnlBarraPropiedades: TRdxPanel;
|
|||
|
|
bAnadirProp: TRdxBoton;
|
|||
|
|
bEliminarProp: TRdxBoton;
|
|||
|
|
bSubir: TRdxBoton;
|
|||
|
|
bBajar: TRdxBoton;
|
|||
|
|
pagPrecios: TTabSheet;
|
|||
|
|
pnlPrecios: TPanel;
|
|||
|
|
pnlBarraPrecio: TRdxPanel;
|
|||
|
|
RdxBoton1: TRdxBoton;
|
|||
|
|
RdxBoton2: TRdxBoton;
|
|||
|
|
gridPrecios: TDBCtrlGrid;
|
|||
|
|
DBEdit1: TDBEdit;
|
|||
|
|
DBEdit2: TDBEdit;
|
|||
|
|
pnlGrid: TRdxPanel;
|
|||
|
|
Label5: TLabel;
|
|||
|
|
Label10: TLabel;
|
|||
|
|
Label11: TLabel;
|
|||
|
|
Label9: TLabel;
|
|||
|
|
BaseImponible: TcxDBTextEdit;
|
|||
|
|
ImporteDescuento: TcxDBTextEdit;
|
|||
|
|
ImporteIVA: TcxDBTextEdit;
|
|||
|
|
ImporteTotal: TcxDBTextEdit;
|
|||
|
|
eSeccion: TLabel;
|
|||
|
|
Seccion: TcxComboBox;
|
|||
|
|
pnlObservaciones: TRdxPanel;
|
|||
|
|
Label1: TLabel;
|
|||
|
|
Observaciones: TcxMemo;
|
|||
|
|
eTelefono1: TLabel;
|
|||
|
|
Telefono1: TcxDBTextEdit;
|
|||
|
|
eTelefono2: TLabel;
|
|||
|
|
Telefono2: TcxDBTextEdit;
|
|||
|
|
Fax: TcxDBTextEdit;
|
|||
|
|
eFax: TLabel;
|
|||
|
|
eMovil1: TLabel;
|
|||
|
|
Movil1: TcxDBTextEdit;
|
|||
|
|
eMovil2: TLabel;
|
|||
|
|
Movil2: TcxDBTextEdit;
|
|||
|
|
ePersona: TLabel;
|
|||
|
|
PersonaContacto: TcxDBTextEdit;
|
|||
|
|
pnlContenido: TPanel;
|
|||
|
|
pnlPlazosEntrega: TPanel;
|
|||
|
|
Panel2: TPanel;
|
|||
|
|
ePlazosEntrega: TLabel;
|
|||
|
|
Panel3: TPanel;
|
|||
|
|
PlazosEntrega: TcxDBMemo;
|
|||
|
|
pnlNota: TPanel;
|
|||
|
|
Panel4: TPanel;
|
|||
|
|
eNota: TLabel;
|
|||
|
|
Panel5: TPanel;
|
|||
|
|
Nota: TcxDBMemo;
|
|||
|
|
pagPlanos: TTabSheet;
|
|||
|
|
Panel14: TPanel;
|
|||
|
|
Label6: TLabel;
|
|||
|
|
RdxBoton3: TRdxBoton;
|
|||
|
|
RdxBoton4: TRdxBoton;
|
|||
|
|
JvTrackBar1: TJvTrackBar;
|
|||
|
|
RdxBoton6: TRdxBoton;
|
|||
|
|
tvPlanos: TJvThumbView;
|
|||
|
|
OpenDialog1: TOpenDialog;
|
|||
|
|
procedure bSalirClick(Sender: TObject);
|
|||
|
|
procedure bGuardarClick(Sender: TObject);
|
|||
|
|
procedure bCancelarClick(Sender: TObject);
|
|||
|
|
procedure CodClienteButtonClick(Sender: TObject);
|
|||
|
|
procedure ProvinciaButtonClick(Sender: TObject);
|
|||
|
|
procedure PoblacionButtonClick(Sender: TObject);
|
|||
|
|
procedure actAnadirDetalleExecute(Sender: TObject);
|
|||
|
|
procedure actEliminarDetalleExecute(Sender: TObject);
|
|||
|
|
procedure actEliminarTodoDetalleExecute(Sender: TObject);
|
|||
|
|
procedure CodClientePropertiesButtonClick(Sender: TObject;
|
|||
|
|
AButtonIndex: Integer);
|
|||
|
|
procedure ProvinciaPropertiesButtonClick(Sender: TObject;
|
|||
|
|
AButtonIndex: Integer);
|
|||
|
|
procedure PoblacionPropertiesButtonClick(Sender: TObject;
|
|||
|
|
AButtonIndex: Integer);
|
|||
|
|
procedure CodigoPropertiesButtonClick(Sender: TObject;
|
|||
|
|
AButtonIndex: Integer);
|
|||
|
|
procedure actEliminarDetalleUpdate(Sender: TObject);
|
|||
|
|
procedure actEliminarTodoDetalleUpdate(Sender: TObject);
|
|||
|
|
procedure cbXDocumentoPropertiesValidate(Sender: TObject;
|
|||
|
|
var DisplayValue: Variant; var ErrorText: TCaption;
|
|||
|
|
var Error: Boolean);
|
|||
|
|
procedure actEditarPropiedadesUpdate(Sender: TObject);
|
|||
|
|
procedure actAnadirDetalleUpdate(Sender: TObject);
|
|||
|
|
procedure TablaDetallesNewRecord(DataSet: TDataSet);
|
|||
|
|
procedure actAnadirPropiedadExecute(Sender: TObject);
|
|||
|
|
procedure actAnadirPropiedadUpdate(Sender: TObject);
|
|||
|
|
procedure actEliminarPropiedadExecute(Sender: TObject);
|
|||
|
|
procedure actEliminarPropiedadUpdate(Sender: TObject);
|
|||
|
|
procedure actSubirExecute(Sender: TObject);
|
|||
|
|
procedure actSubirUpdate(Sender: TObject);
|
|||
|
|
procedure actBajarExecute(Sender: TObject);
|
|||
|
|
procedure actBajarUpdate(Sender: TObject);
|
|||
|
|
procedure gridDetallesResize(Sender: TObject);
|
|||
|
|
procedure pnlPreciosResize(Sender: TObject);
|
|||
|
|
procedure SeccionPropertiesChange(Sender: TObject);
|
|||
|
|
procedure ObservacionesExit(Sender: TObject);
|
|||
|
|
procedure VistaPropiedadesDBCardViewRow3CustomDrawCell(
|
|||
|
|
Sender: TcxCustomGridTableView; ACanvas: TcxCanvas;
|
|||
|
|
AViewInfo: TcxGridTableDataCellViewInfo; var ADone: Boolean);
|
|||
|
|
procedure pagNotasVariasResize(Sender: TObject);
|
|||
|
|
procedure actAnadirPlanoExecute(Sender: TObject);
|
|||
|
|
procedure actEliminarPlanoExecute(Sender: TObject);
|
|||
|
|
procedure actEliminarPlanoUpdate(Sender: TObject);
|
|||
|
|
procedure actRefrescarPlanoExecute(Sender: TObject);
|
|||
|
|
procedure actAnadirPlanoUpdate(Sender: TObject);
|
|||
|
|
procedure tvPlanosDblClick(Sender: TObject);
|
|||
|
|
procedure JvTrackBar1Change(Sender: TObject);
|
|||
|
|
private
|
|||
|
|
FRootPlanos: Variant;
|
|||
|
|
FDirectorio: Variant;
|
|||
|
|
FCodigoProvincia : Variant;
|
|||
|
|
FCodigoPoblacion : Variant;
|
|||
|
|
FCodigoCliente : Variant;
|
|||
|
|
FCodigoArticulo : Variant;
|
|||
|
|
FTablaDetallesMem : TRxMemoryData;
|
|||
|
|
FTablaPropiedadesMem : TRxMemoryData;
|
|||
|
|
FObservaciones1 : String;
|
|||
|
|
FObservaciones2 : String;
|
|||
|
|
procedure CalcularTotalDetalle;
|
|||
|
|
procedure CalcularTotalContrato;
|
|||
|
|
procedure ActivarEventosCampos;
|
|||
|
|
procedure DesactivarEventosCampos;
|
|||
|
|
|
|||
|
|
function darRutaPlanosContrato: Variant;
|
|||
|
|
function AnadirPlano(RutaPlano: String): Boolean;
|
|||
|
|
|
|||
|
|
procedure HabilitarPlanos;
|
|||
|
|
procedure DeshabilitarPlanos;
|
|||
|
|
function CrearDirPlanos: Boolean;
|
|||
|
|
procedure ComprobarEstadoDirPlanos;
|
|||
|
|
function EliminarDirPlanos : Boolean;
|
|||
|
|
|
|||
|
|
procedure SalvarDetalles;
|
|||
|
|
procedure SalvarPropiedades;
|
|||
|
|
procedure CargarDetalles;
|
|||
|
|
procedure CargarPropiedades;
|
|||
|
|
procedure DetalleAfterDelete (DataSet: TDataSet);
|
|||
|
|
procedure DetallesAfterInsert(DataSet: TDataSet);
|
|||
|
|
procedure PropiedadesAfterDelete (DataSet: TDataSet);
|
|||
|
|
procedure PropiedadesAfterInsert(DataSet: TDataSet);
|
|||
|
|
procedure CodCliSetText(Sender: TField; const Text: String);
|
|||
|
|
procedure ProvinciaSetText(Sender: TField; const Text: String);
|
|||
|
|
procedure IVASetText(Sender: TField; const Text: String);
|
|||
|
|
procedure DtoSetText(Sender: TField; const Text: String);
|
|||
|
|
procedure CodigoArticuloDetalleSetText(Sender: TField; const Text: String);
|
|||
|
|
procedure ReferenciaArticuloDetalleSetText(Sender: TField; const Text: String);
|
|||
|
|
procedure CantidadDetalleSetText(Sender: TField; const Text: String);
|
|||
|
|
procedure PrecioDetalleSetText(Sender: TField; const Text: String);
|
|||
|
|
procedure GridBotonCodigoArticuloClick(Sender: TObject; AButtonIndex: Integer);
|
|||
|
|
procedure GridBotonReferenciaArticuloClick(Sender: TObject; AButtonIndex: Integer);
|
|||
|
|
procedure InsertarPropiedades(NumConcepto : Integer; Seccion : String = '');
|
|||
|
|
procedure CargarPropiedadesArticulo(NumConcepto : Integer; DatosArticulo : TDatosArticulo);
|
|||
|
|
procedure BorrarPropiedadesConcepto(NumConcepto : Integer);
|
|||
|
|
procedure AsignarNumConceptoDetalles;
|
|||
|
|
procedure AsignarNumPropiedad;
|
|||
|
|
procedure ReasignarNumConceptoPropiedades(NumConAnt, NumConNue : Integer);
|
|||
|
|
procedure SetCodigoProvincia (Value : Variant); virtual;
|
|||
|
|
procedure SetCodigoPoblacion (Value : Variant); virtual;
|
|||
|
|
procedure SetCodigoCliente (Value : Variant);
|
|||
|
|
procedure SetCodigoArticulo (Value : Variant);
|
|||
|
|
function ArticuloConPropiedades(NumConcepto : Integer) : Boolean;
|
|||
|
|
procedure CargarDatosDocumento(CodigoDocumento : String);
|
|||
|
|
procedure CargarPreciosDocumento (CodigoDocumento : String; NumConcepto : Integer);
|
|||
|
|
procedure VALORGetProperties(
|
|||
|
|
Sender: TcxCustomGridTableItem; ARecord: TcxCustomGridRecord;
|
|||
|
|
var AProperties: TcxCustomEditProperties);
|
|||
|
|
procedure ConfigurarPantallaDocumento;
|
|||
|
|
procedure InsertarDetallesDefecto;
|
|||
|
|
procedure TablaMemDetallesFilterRecord(DataSet: TDataSet;
|
|||
|
|
var Accept: Boolean);
|
|||
|
|
procedure TablaMemPropiedadesFilterRecord(DataSet: TDataSet;
|
|||
|
|
var Accept: Boolean);
|
|||
|
|
protected
|
|||
|
|
procedure ActivarModoAnadir; override;
|
|||
|
|
procedure ActivarModoModificar; override;
|
|||
|
|
procedure ActivarModoConsultar; override;
|
|||
|
|
procedure ActivarModoEliminar; override;
|
|||
|
|
function AnadirDatos : Boolean; override;
|
|||
|
|
function ModificarDatos : Boolean; override;
|
|||
|
|
function EliminarDatos : Boolean; override;
|
|||
|
|
function CancelarAnadir : Boolean; override;
|
|||
|
|
function CancelarModificar : Boolean; override;
|
|||
|
|
function CancelarEliminar : Boolean; override;
|
|||
|
|
function ComprobarDatos : Boolean; override;
|
|||
|
|
procedure VerModal; override;
|
|||
|
|
procedure FreeContenido; override;
|
|||
|
|
procedure BuscarContrato; override;
|
|||
|
|
property CodigoProvincia : Variant read FCodigoProvincia write SetCodigoProvincia;
|
|||
|
|
property CodigoPoblacion : Variant read FCodigoPoblacion write SetCodigoPoblacion;
|
|||
|
|
property CodigoCliente : Variant read FCodigoCliente write SetCodigoCliente;
|
|||
|
|
property CodigoArticulo : Variant read FCodigoArticulo write SetCodigoArticulo;
|
|||
|
|
property TablaDetallesMem : TRxMemoryData read FTablaDetallesMem write FTablaDetallesMem;
|
|||
|
|
property TablaPropiedadesMem : TRxMemoryData read FTablaPropiedadesMem write FTablaPropiedadesMem;
|
|||
|
|
public
|
|||
|
|
constructor Create (AOwner : TComponent); override;
|
|||
|
|
destructor Destroy; override;
|
|||
|
|
published
|
|||
|
|
property TablaContratos;
|
|||
|
|
property TablaDetallesContratos;
|
|||
|
|
property CodigoContrato;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
var
|
|||
|
|
frContratoCliente: TfrContratoCliente;
|
|||
|
|
|
|||
|
|
implementation
|
|||
|
|
|
|||
|
|
{$R *.DFM}
|
|||
|
|
|
|||
|
|
uses
|
|||
|
|
cxGridDBDataDefinitions, ContratosClientes, BaseDatos, TablaContratos,
|
|||
|
|
IBDatabase, Literales, Mensajes, Clientes, RdxFrameProvincias, RdxFramePoblaciones,
|
|||
|
|
TablaProvincias, Provincias, Poblaciones, TablaClientes, RdxFrameClientes,
|
|||
|
|
IB, Articulos, RdxFrameArticulos, Variants, Entidades, TablaPropiedadesArticulo,
|
|||
|
|
StrFunc, Sysutils, TablaPoblaciones, Excepciones, IBErrorCodes,
|
|||
|
|
IBSQL, NumFunc, Vendedores, TablaVendedores, PropiedadesArticulo,
|
|||
|
|
RdxDBFrame, TablaFamilias, ElegirDireccionCliente, TablaEmpresas,
|
|||
|
|
TablaPresupuestos, SysFunc, Constantes, ShellApi;
|
|||
|
|
|
|||
|
|
{ TfrContratoCliente }
|
|||
|
|
|
|||
|
|
procedure TfrContratoCliente.ActivarModoAnadir;
|
|||
|
|
var
|
|||
|
|
CodNuevo : Variant;
|
|||
|
|
begin
|
|||
|
|
dsContrato.AutoEdit := True;
|
|||
|
|
dsDetallesContrato.AutoEdit := True;
|
|||
|
|
dsPropiedadesContrato.AutoEdit := True;
|
|||
|
|
|
|||
|
|
Codigo.Properties.Buttons[0].Visible := False;
|
|||
|
|
Codigo.Properties.ReadOnly := False;
|
|||
|
|
CodCliente.Properties.Buttons[0].Visible := True;
|
|||
|
|
Poblacion.Properties.Buttons[0].Visible := True;
|
|||
|
|
Provincia.Properties.Buttons[0].Visible := True;
|
|||
|
|
|
|||
|
|
DesactivarEventosCampos;
|
|||
|
|
try
|
|||
|
|
CodNuevo := dmTablaContratos.DarNuevoCodigo;
|
|||
|
|
|
|||
|
|
with TablaContratos do
|
|||
|
|
begin
|
|||
|
|
Close;
|
|||
|
|
Prepare;
|
|||
|
|
Open;
|
|||
|
|
FieldByName('PROVINCIA').OnSetText := ProvinciaSetText;
|
|||
|
|
Insert;
|
|||
|
|
FCodigoContrato := CodNuevo;
|
|||
|
|
Codigo.DataBinding.Field.AsString := FCodigoContrato;
|
|||
|
|
Codigo.Properties.ReadOnly := True;
|
|||
|
|
FieldByName('FECHAALTA').AsDateTime := dmBaseDatos.DarFecha;
|
|||
|
|
FieldByName('USUARIO').AsString := dmBaseDatos.Usuario;
|
|||
|
|
FieldByName('IVA').AsString := EmpresaActiva.IvaDefecto;
|
|||
|
|
FechaContrato.DataBinding.Field.AsDateTime := dmBaseDatos.DarFecha;
|
|||
|
|
cbxSituacion.DataBinding.Field.AsString := cbxSituacion.Properties.Items[0];
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
with TablaDetallesContratos do
|
|||
|
|
begin
|
|||
|
|
Close;
|
|||
|
|
Params.ByName('CODIGOCONTRATO').AsString := CodNuevo;
|
|||
|
|
Prepare;
|
|||
|
|
Open;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
with TablaPropiedadesContratos do
|
|||
|
|
begin
|
|||
|
|
Close;
|
|||
|
|
Params.ByName('CODIGOCONTRATO').AsString := CodNuevo;
|
|||
|
|
Prepare;
|
|||
|
|
Open;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
with TablaDetallesMem do
|
|||
|
|
begin
|
|||
|
|
Close;
|
|||
|
|
Filtered := False;
|
|||
|
|
OnFilterRecord := NIL;
|
|||
|
|
Open;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
with TablaPropiedadesMem do
|
|||
|
|
begin
|
|||
|
|
Close;
|
|||
|
|
Filtered := False;
|
|||
|
|
onFilterRecord := NIL;
|
|||
|
|
Open;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
dmTablaContratos.InicializarTablaContratos(@TablaContratos);
|
|||
|
|
dmTablaContratos.InicializarTablaDetalles(@TablaDetallesMem);
|
|||
|
|
|
|||
|
|
ActivarEdicionGridDetalles(VistaDetalles);
|
|||
|
|
|
|||
|
|
cbxDocumento.DataBinding.Field.AsString := dmTablaDocumentos.DarCodigoDocumento(Entidad);
|
|||
|
|
CargarDatosDocumento(cbxDocumento.DataBinding.Field.AsString);
|
|||
|
|
|
|||
|
|
ConfigurarPantallaDocumento;
|
|||
|
|
InsertarDetallesDefecto;
|
|||
|
|
|
|||
|
|
with TablaDetallesMem do
|
|||
|
|
begin
|
|||
|
|
if not (Entidad in [entContratoCliente, entContratoVarios, entContratoElectro]) then
|
|||
|
|
begin
|
|||
|
|
OnFilterRecord := TablaMemDetallesFilterRecord;
|
|||
|
|
Filtered := True;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
with TablaPropiedadesMem do
|
|||
|
|
begin
|
|||
|
|
if (Entidad = entContratoArmarios) then
|
|||
|
|
begin
|
|||
|
|
OnFilterRecord := TablaMemPropiedadesFilterRecord;
|
|||
|
|
Filtered := True;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
FObservaciones1 := '';
|
|||
|
|
FObservaciones2 := '';
|
|||
|
|
Observaciones.Lines.Text := '';
|
|||
|
|
|
|||
|
|
//Planos asociados al presupuesto
|
|||
|
|
if Entidad = entContratoCocina then
|
|||
|
|
CrearDirPlanos;
|
|||
|
|
|
|||
|
|
ActivarEventosCampos;
|
|||
|
|
Visible := True;
|
|||
|
|
FechaContrato.SetFocus;
|
|||
|
|
except
|
|||
|
|
on E : EIBError do
|
|||
|
|
TratarExcepcion(E);
|
|||
|
|
on E : Exception do
|
|||
|
|
TratarExcepcion(E);
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrContratoCliente.ActivarModoConsultar;
|
|||
|
|
begin
|
|||
|
|
dsContrato.AutoEdit := False;
|
|||
|
|
dsDetallesContrato.AutoEdit := False;
|
|||
|
|
dsPropiedadesContrato.AutoEdit := False;
|
|||
|
|
|
|||
|
|
Codigo.Properties.Buttons[0].Visible := True;
|
|||
|
|
CodCliente.Properties.Buttons[0].Visible := False;
|
|||
|
|
Poblacion.Properties.Buttons[0].Visible := False;
|
|||
|
|
Provincia.Properties.Buttons[0].Visible := False;
|
|||
|
|
|
|||
|
|
try
|
|||
|
|
with TablaContratos do
|
|||
|
|
begin
|
|||
|
|
if RecordCount = 0 then
|
|||
|
|
begin
|
|||
|
|
VerMensajeFmt(msgCliNoExisteCon, [CodigoContrato]);
|
|||
|
|
CloseFrame;
|
|||
|
|
Exit;
|
|||
|
|
end;
|
|||
|
|
Cancel;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
dmTablaContratos.InicializarTablaContratos(@TablaContratos);
|
|||
|
|
dmTablaContratos.InicializarTablaDetalles(@TablaDetallesMem);
|
|||
|
|
DesactivarEdicionGridDetalles(gridDetalles);
|
|||
|
|
Entidad := dmTablaDocumentos.DarEntidadDocumento(entContratoCliente,cbxDocumento.DataBinding.Field.AsString);
|
|||
|
|
|
|||
|
|
with TablaDetallesMem do
|
|||
|
|
begin
|
|||
|
|
if not (Entidad in [entContratoCliente, entContratoVarios, entContratoElectro]) then
|
|||
|
|
begin
|
|||
|
|
OnFilterRecord := TablaMemDetallesFilterRecord;
|
|||
|
|
Filtered := True;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
with TablaPropiedadesMem do
|
|||
|
|
begin
|
|||
|
|
if (Entidad = entContratoArmarios) then
|
|||
|
|
begin
|
|||
|
|
OnFilterRecord := TablaMemPropiedadesFilterRecord;
|
|||
|
|
Filtered := True;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
ConfigurarPantallaDocumento;
|
|||
|
|
Visible := True;
|
|||
|
|
|
|||
|
|
//Documentos asociados al presupuesto
|
|||
|
|
if Entidad = entContratoCocina then
|
|||
|
|
begin
|
|||
|
|
if DirectoryExists(darRutaPlanosContrato) then
|
|||
|
|
HabilitarPlanos
|
|||
|
|
else
|
|||
|
|
DeshabilitarPlanos;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
FechaContrato.SetFocus;
|
|||
|
|
except
|
|||
|
|
on E : EIBError do
|
|||
|
|
TratarExcepcion(E);
|
|||
|
|
on E : Exception do
|
|||
|
|
TratarExcepcion(E);
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrContratoCliente.ActivarModoEliminar;
|
|||
|
|
begin
|
|||
|
|
dsContrato.AutoEdit := False;
|
|||
|
|
dsDetallesContrato.AutoEdit := False;
|
|||
|
|
dsPropiedadesContrato.AutoEdit := False;
|
|||
|
|
|
|||
|
|
Codigo.Properties.Buttons[0].Visible := True;
|
|||
|
|
CodCliente.Properties.Buttons[0].Visible := False;
|
|||
|
|
Poblacion.Properties.Buttons[0].Visible := False;
|
|||
|
|
Provincia.Properties.Buttons[0].Visible := False;
|
|||
|
|
|
|||
|
|
try
|
|||
|
|
with TablaContratos do
|
|||
|
|
begin
|
|||
|
|
if RecordCount = 0 then
|
|||
|
|
begin
|
|||
|
|
VerMensajeFmt(msgCliNoExisteCon, [CodigoContrato]);
|
|||
|
|
CancelarEliminar;
|
|||
|
|
CloseFrame;
|
|||
|
|
Exit;
|
|||
|
|
end;
|
|||
|
|
Cancel;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
dmTablaContratos.InicializarTablaContratos(@TablaContratos);
|
|||
|
|
dmTablaContratos.InicializarTablaDetalles(@TablaDetallesMem);
|
|||
|
|
Entidad := dmTablaDocumentos.darEntidadDocumento(entContratoCliente, cbxDocumento.DataBinding.Field.AsString);
|
|||
|
|
|
|||
|
|
with TablaDetallesMem do
|
|||
|
|
begin
|
|||
|
|
if not (Entidad in [entContratoCliente, entContratoVarios, entContratoElectro]) then
|
|||
|
|
begin
|
|||
|
|
OnFilterRecord := TablaMemDetallesFilterRecord;
|
|||
|
|
Filtered := True;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
with TablaPropiedadesMem do
|
|||
|
|
begin
|
|||
|
|
if (Entidad = entContratoArmarios) then
|
|||
|
|
begin
|
|||
|
|
OnFilterRecord := TablaMemPropiedadesFilterRecord;
|
|||
|
|
Filtered := True;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
ConfigurarPantallaDocumento;
|
|||
|
|
DesactivarEdicionGridDetalles(gridDetalles);
|
|||
|
|
|
|||
|
|
//Documentos asociados al presupuesto
|
|||
|
|
if Entidad = entContratoCocina then
|
|||
|
|
begin
|
|||
|
|
if DirectoryExists(darRutaPlanosContrato) then
|
|||
|
|
HabilitarPlanos
|
|||
|
|
else
|
|||
|
|
DeshabilitarPlanos;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
Visible := True;
|
|||
|
|
except
|
|||
|
|
on E : EIBError do
|
|||
|
|
TratarExcepcion(E);
|
|||
|
|
on E : Exception do
|
|||
|
|
TratarExcepcion(E);
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrContratoCliente.ActivarModoModificar;
|
|||
|
|
begin
|
|||
|
|
dsContrato.AutoEdit := True;
|
|||
|
|
dsDetallesContrato.AutoEdit := True;
|
|||
|
|
dsPropiedadesContrato.AutoEdit := True;
|
|||
|
|
|
|||
|
|
Codigo.Properties.Buttons[0].Visible := True;
|
|||
|
|
Codigo.Properties.ReadOnly := True;
|
|||
|
|
CodCliente.Properties.Buttons[0].Visible := True;
|
|||
|
|
Poblacion.Properties.Buttons[0].Visible := True;
|
|||
|
|
Provincia.Properties.Buttons[0].Visible := True;
|
|||
|
|
|
|||
|
|
try
|
|||
|
|
with TablaContratos do
|
|||
|
|
begin
|
|||
|
|
if RecordCount = 0 then
|
|||
|
|
begin
|
|||
|
|
VerMensajeFmt(msgCliNoExisteCon, [CodigoContrato]);
|
|||
|
|
CancelarModificar;
|
|||
|
|
CloseFrame;
|
|||
|
|
Exit;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
Edit;
|
|||
|
|
Post;
|
|||
|
|
Edit;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
dmTablaContratos.InicializarTablaContratos(@TablaContratos);
|
|||
|
|
dmTablaContratos.InicializarTablaDetalles(@TablaDetallesMem);
|
|||
|
|
|
|||
|
|
ActivarEdicionGridDetalles(VistaDetalles);
|
|||
|
|
|
|||
|
|
FCodigoProvincia := dmTablaProvincias.DarCodigoProvincia(Provincia.Text);
|
|||
|
|
Entidad := dmTablaDocumentos.darEntidadDocumento(entContratoCliente, cbxDocumento.DataBinding.Field.AsString);
|
|||
|
|
|
|||
|
|
with TablaDetallesMem do
|
|||
|
|
begin
|
|||
|
|
if not (Entidad in [entContratoCliente, entContratoVarios, entContratoElectro]) then
|
|||
|
|
begin
|
|||
|
|
OnFilterRecord := TablaMemDetallesFilterRecord;
|
|||
|
|
Filtered := True;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
with TablaPropiedadesMem do
|
|||
|
|
begin
|
|||
|
|
if (Entidad = entContratoArmarios) then
|
|||
|
|
begin
|
|||
|
|
OnFilterRecord := TablaMemPropiedadesFilterRecord;
|
|||
|
|
Filtered := True;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
ActivarEventosCampos;
|
|||
|
|
ConfigurarPantallaDocumento;
|
|||
|
|
Visible := True;
|
|||
|
|
|
|||
|
|
//Documentos asociados al contrato
|
|||
|
|
if Entidad = entContratoCocina then
|
|||
|
|
CrearDirPlanos;
|
|||
|
|
|
|||
|
|
FechaContrato.SetFocus;
|
|||
|
|
except
|
|||
|
|
on E : EIBError do
|
|||
|
|
begin
|
|||
|
|
case E.IBErrorCode of
|
|||
|
|
isc_lock_conflict : begin
|
|||
|
|
VerMensajeFmt(msgCliConBloqueado, [CodigoContrato]);
|
|||
|
|
CancelarModificar;
|
|||
|
|
CloseFrame;
|
|||
|
|
Exit;
|
|||
|
|
end
|
|||
|
|
else
|
|||
|
|
TratarExcepcion(E);
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
on E : Exception do
|
|||
|
|
TratarExcepcion(E);
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
function TfrContratoCliente.AnadirDatos: Boolean;
|
|||
|
|
var
|
|||
|
|
CodAux : String;
|
|||
|
|
begin
|
|||
|
|
try
|
|||
|
|
CalcularTotalContrato;
|
|||
|
|
TablaContratos.Post;
|
|||
|
|
|
|||
|
|
BorrarTabla(TablaDetallesContratos);
|
|||
|
|
SalvarDetalles;
|
|||
|
|
BorrarTabla(TablaPropiedadesContratos);
|
|||
|
|
SalvarPropiedades;
|
|||
|
|
|
|||
|
|
dmTablaContratos.IncrementarCodigo;
|
|||
|
|
Commit;
|
|||
|
|
FCodigoContrato := TablaContratos.FieldByName('CODIGO').AsString;
|
|||
|
|
|
|||
|
|
ComprobarEstadoDirPlanos;
|
|||
|
|
|
|||
|
|
Result := True;
|
|||
|
|
except
|
|||
|
|
on E : EIBError do begin
|
|||
|
|
if E.IBErrorCode = isc_unique_key_violation then
|
|||
|
|
begin
|
|||
|
|
// El c<>digo ya se ha utilizado
|
|||
|
|
TablaContratos.Edit;
|
|||
|
|
CodAux := dmTablaContratos.DarNuevoCodigo;
|
|||
|
|
VerMensajeFmt(msgCliCodConRepetido, [Codigo.DataBinding.Field.AsString, CodAux]);
|
|||
|
|
Codigo.DataBinding.Field.AsString := CodAux;
|
|||
|
|
end
|
|||
|
|
else
|
|||
|
|
TratarExcepcion(E);
|
|||
|
|
end;
|
|||
|
|
on E : Exception do
|
|||
|
|
TratarExcepcion(E);
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrContratoCliente.BuscarContrato;
|
|||
|
|
begin
|
|||
|
|
if Transaccion = NIL then
|
|||
|
|
Exit;
|
|||
|
|
|
|||
|
|
try
|
|||
|
|
TablaContratos.DisableControls;
|
|||
|
|
TablaDetallesContratos.DisableControls;
|
|||
|
|
TablaDetallesMem.DisableControls;
|
|||
|
|
TablaPropiedadesContratos.DisableControls;
|
|||
|
|
TablaPropiedadesMem.DisableControls;
|
|||
|
|
|
|||
|
|
DesactivarEventosCampos;
|
|||
|
|
|
|||
|
|
TablaContratos.Close;
|
|||
|
|
TablaDetallesContratos.Close;
|
|||
|
|
TablaPropiedadesMem.Close;
|
|||
|
|
|
|||
|
|
with TablaDetallesMem do
|
|||
|
|
begin
|
|||
|
|
Close;
|
|||
|
|
Filtered := False;
|
|||
|
|
OnFilterRecord := NIL;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
with TablaPropiedadesContratos do
|
|||
|
|
begin
|
|||
|
|
Close;
|
|||
|
|
Filtered := False;
|
|||
|
|
OnFilterRecord := NIL;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
// Buscar la fila a tratar si es necesario
|
|||
|
|
if not EsCadenaVacia(FCodigoContrato) then
|
|||
|
|
begin
|
|||
|
|
TablaContratos.Params.ByName('CODIGO').AsString := FCodigoContrato;
|
|||
|
|
TablaDetallesContratos.Params.ByName('CODIGOCONTRATO').AsString := FCodigoContrato;
|
|||
|
|
TablaPropiedadesContratos.Params.ByName('CODIGOCONTRATO').AsString := FCodigoContrato;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
TablaContratos.Prepare;
|
|||
|
|
TablaContratos.Open;
|
|||
|
|
|
|||
|
|
Entidad := dmTablaDocumentos.DarEntidadDocumento(entContratoCliente,TablaContratos.FieldByName('CODIGODOCUMENTO').AsString);
|
|||
|
|
|
|||
|
|
TablaDetallesContratos.Prepare;
|
|||
|
|
TablaDetallesContratos.Open;
|
|||
|
|
|
|||
|
|
TablaPropiedadesContratos.Prepare;
|
|||
|
|
TablaPropiedadesContratos.Open;
|
|||
|
|
|
|||
|
|
TablaDetallesMem.Open;
|
|||
|
|
CargarDetalles;
|
|||
|
|
if not (Entidad in [entContratoCliente, entContratoVarios, entContratoElectro]) then
|
|||
|
|
begin
|
|||
|
|
with TablaDetallesMem do
|
|||
|
|
begin
|
|||
|
|
First;
|
|||
|
|
FObservaciones1 := FieldByName('OBSERVACIONES').AsString;
|
|||
|
|
Observaciones.Lines.Clear;
|
|||
|
|
Observaciones.Lines.Text := FObservaciones1;
|
|||
|
|
if Entidad = entContratoArmarios then
|
|||
|
|
begin
|
|||
|
|
Next;
|
|||
|
|
FObservaciones2 := FieldByName('OBSERVACIONES').AsString;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
TablaDetallesMem.OnFilterRecord := TablaMemDetallesFilterRecord;
|
|||
|
|
TablaDetallesMem.Filtered := True;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
TablaPropiedadesMem.Open;
|
|||
|
|
CargarPropiedades;
|
|||
|
|
if Entidad = entContratoArmarios then
|
|||
|
|
begin
|
|||
|
|
TablaDetallesMem.OnFilterRecord := TablaMemPropiedadesFilterRecord;
|
|||
|
|
TablaDetallesMem.Filtered := True;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
if not TablaDocumentos.Active then
|
|||
|
|
TablaDocumentos.Open;
|
|||
|
|
|
|||
|
|
dmTablaContratos.InicializarTablaContratos(@TablaContratos);
|
|||
|
|
dmTablaContratos.InicializarTablaDetalles(@TablaDetallesMem);
|
|||
|
|
|
|||
|
|
ActivarEventosCampos;
|
|||
|
|
|
|||
|
|
TablaContratos.EnableControls;
|
|||
|
|
TablaDetallesContratos.EnableControls;
|
|||
|
|
TablaDetallesMem.EnableControls;
|
|||
|
|
TablaPropiedadesContratos.EnableControls;
|
|||
|
|
TablaPropiedadesMem.EnableControls;
|
|||
|
|
except
|
|||
|
|
on E : EIBError do
|
|||
|
|
TratarExcepcion(E);
|
|||
|
|
on E : Exception do
|
|||
|
|
TratarExcepcion(E);
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrContratoCliente.CalcularTotalDetalle;
|
|||
|
|
var
|
|||
|
|
auxCantidad,
|
|||
|
|
auxPrecio,
|
|||
|
|
auxTotal : double;
|
|||
|
|
begin
|
|||
|
|
with TablaDetallesMem do
|
|||
|
|
begin
|
|||
|
|
Edit;
|
|||
|
|
auxCantidad := FieldByName('CANTIDAD').AsFloat;
|
|||
|
|
auxPrecio := FieldByName('IMPORTEUNIDAD').AsFloat;
|
|||
|
|
auxTotal := (auxCantidad * auxPrecio);
|
|||
|
|
FieldByName('IMPORTETOTAL').AsFloat := auxTotal;
|
|||
|
|
end;
|
|||
|
|
CalcularTotalContrato;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrContratoCliente.CalcularTotalContrato;
|
|||
|
|
var
|
|||
|
|
BaseImponible,
|
|||
|
|
ImporteIVA,
|
|||
|
|
ImporteDto,
|
|||
|
|
ImporteTotal : Double;
|
|||
|
|
FDetallesBookmark : string;
|
|||
|
|
begin
|
|||
|
|
BaseImponible := 0;
|
|||
|
|
ImporteTotal := 0;
|
|||
|
|
with TablaDetallesMem do
|
|||
|
|
begin
|
|||
|
|
DisableControls;
|
|||
|
|
FDetallesBookmark := Bookmark;
|
|||
|
|
try
|
|||
|
|
First;
|
|||
|
|
while not EOF do begin
|
|||
|
|
BaseImponible := BaseImponible + FieldByName('IMPORTETOTAL').AsFloat;
|
|||
|
|
Next;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
ImporteDto := BaseImponible * (TablaContratos.FieldByName('DESCUENTO').AsFloat/100);
|
|||
|
|
ImporteTotal := BaseImponible - ImporteDto;
|
|||
|
|
ImporteIVA := ImporteTotal * (TablaContratos.FieldByName('IVA').AsFloat/100);
|
|||
|
|
ImporteTotal := ImporteTotal + ImporteIVA;
|
|||
|
|
|
|||
|
|
TablaContratos.Edit;
|
|||
|
|
TablaContratos.FieldByName('BASEIMPONIBLE').AsFloat := BaseImponible;
|
|||
|
|
TablaContratos.FieldByName('IMPORTEDESCUENTO').AsFloat := ImporteDto;
|
|||
|
|
TablaContratos.FieldByName('IMPORTEIVA').AsFloat := ImporteIVA;
|
|||
|
|
TablaContratos.FieldByName('IMPORTETOTAL').AsFloat := ImporteTotal;
|
|||
|
|
finally
|
|||
|
|
Bookmark := FDetallesBookmark;
|
|||
|
|
EnableControls;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
function TfrContratoCliente.CancelarAnadir: Boolean;
|
|||
|
|
begin
|
|||
|
|
Result := False;
|
|||
|
|
try
|
|||
|
|
TablaContratos.Cancel;
|
|||
|
|
TablaDetallesMem.Cancel;
|
|||
|
|
TablaPropiedadesMem.Cancel;
|
|||
|
|
RollBack;
|
|||
|
|
|
|||
|
|
if Entidad = entContratoCocina then
|
|||
|
|
EliminarDirPlanos;
|
|||
|
|
|
|||
|
|
Result := True;
|
|||
|
|
except
|
|||
|
|
on E : EIBError do
|
|||
|
|
TratarExcepcion(E);
|
|||
|
|
on E : Exception do
|
|||
|
|
TratarExcepcion(E);
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
function TfrContratoCliente.CancelarEliminar: Boolean;
|
|||
|
|
begin
|
|||
|
|
Result := False;
|
|||
|
|
try
|
|||
|
|
RollBack;
|
|||
|
|
Result := True;
|
|||
|
|
except
|
|||
|
|
on E : EIBError do
|
|||
|
|
TratarExcepcion(E);
|
|||
|
|
on E : Exception do
|
|||
|
|
TratarExcepcion(E);
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
function TfrContratoCliente.CancelarModificar: Boolean;
|
|||
|
|
begin
|
|||
|
|
Result := False;
|
|||
|
|
try
|
|||
|
|
TablaContratos.Cancel;
|
|||
|
|
TablaDetallesMem.Cancel;
|
|||
|
|
TablaPropiedadesMem.Cancel;
|
|||
|
|
RollBack;
|
|||
|
|
ComprobarEstadoDirPlanos;
|
|||
|
|
Result := True;
|
|||
|
|
except
|
|||
|
|
on E : EIBError do
|
|||
|
|
TratarExcepcion(E);
|
|||
|
|
on E : Exception do
|
|||
|
|
TratarExcepcion(E);
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
function TfrContratoCliente.ComprobarDatos: Boolean;
|
|||
|
|
var
|
|||
|
|
AuxNumDetalles : integer;
|
|||
|
|
begin
|
|||
|
|
Result := False;
|
|||
|
|
|
|||
|
|
if not (Modo in [Anadir, Modificar]) then
|
|||
|
|
begin
|
|||
|
|
Result := True;
|
|||
|
|
exit;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
if EsCadenaVacia(FechaContrato.DataBinding.Field.AsString) then
|
|||
|
|
begin
|
|||
|
|
VerMensaje(msgCliFaltaFechaAltaCon);
|
|||
|
|
FechaContrato.SetFocus;
|
|||
|
|
Exit;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
if Modo = Anadir then
|
|||
|
|
begin
|
|||
|
|
if EsCadenaVacia(CodCliente.DataBinding.Field.AsString) then
|
|||
|
|
begin
|
|||
|
|
VerMensaje(msgCliFaltaCodCli);
|
|||
|
|
Paginas.ActivePageIndex := 0;
|
|||
|
|
CodCliente.SetFocus;
|
|||
|
|
Exit;
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
else
|
|||
|
|
begin
|
|||
|
|
if EsCadenaVacia(Nombre.DataBinding.Field.AsString) then
|
|||
|
|
begin
|
|||
|
|
VerMensaje(msgCliFaltaNombreCli);
|
|||
|
|
Paginas.ActivePageIndex := 0;
|
|||
|
|
Nombre.SetFocus;
|
|||
|
|
Exit;
|
|||
|
|
end
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
if TablaDetallesMem.IsEmpty then
|
|||
|
|
begin
|
|||
|
|
VerMensaje(msgCliFaltaArticulosCon);
|
|||
|
|
Paginas.ActivePageIndex := 1;
|
|||
|
|
gridDetalles.SetFocus;
|
|||
|
|
Exit
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
Result := True;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
constructor TfrContratoCliente.Create(AOwner: TComponent);
|
|||
|
|
begin
|
|||
|
|
inherited Create(AOwner);
|
|||
|
|
Entidad := entContratoCliente;
|
|||
|
|
|
|||
|
|
FCodigoProvincia := NULL;
|
|||
|
|
FCodigoPoblacion := NULL;
|
|||
|
|
FCodigoCliente := NULL;
|
|||
|
|
FCodigoArticulo := NULL;
|
|||
|
|
|
|||
|
|
BaseDatos := dmBaseDatos.BD;
|
|||
|
|
Transaccion := dmBaseDatos.Transaccion;
|
|||
|
|
|
|||
|
|
TablaContratos := TIBDataSet.Create(Self);
|
|||
|
|
TablaDetallesContratos := TIBDataSet.Create(Self);
|
|||
|
|
TablaPropiedadesContratos := TIBDataSet.Create(Self);
|
|||
|
|
|
|||
|
|
TablaDetallesMem := TRxMemoryData.Create(Self);
|
|||
|
|
TablaPropiedadesMem := TRxMemoryData.Create(Self);
|
|||
|
|
|
|||
|
|
dsContrato.DataSet := TablaContratos;
|
|||
|
|
dsDetallesContrato.DataSet := TablaDetallesMem;
|
|||
|
|
dsPropiedadesContrato.DataSet := TablaPropiedadesMem;
|
|||
|
|
|
|||
|
|
FRootPlanos := dmBaseDatos.DarValorConfiguracion(CTE_PLANOS);
|
|||
|
|
FDirectorio := '';
|
|||
|
|
|
|||
|
|
with TablaDocumentos do
|
|||
|
|
begin
|
|||
|
|
Database := BaseDatos;
|
|||
|
|
Transaction := Transaccion;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
with TablaContratos do
|
|||
|
|
begin
|
|||
|
|
Database := BaseDatos;
|
|||
|
|
Transaction := Transaccion;
|
|||
|
|
SelectSQL.Assign(dmTablaContratos.sqlConsultarContrato);
|
|||
|
|
InsertSQL.Assign(dmTablaContratos.sqlInsertarContrato);
|
|||
|
|
ModifySQL.Assign(dmTablaContratos.sqlModificarContrato);
|
|||
|
|
DeleteSQL.Assign(dmTablaContratos.sqlEliminarContrato);
|
|||
|
|
RefreshSQL.Assign(dmTablaContratos.sqlConsultarContrato);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
with TablaDetallesContratos do
|
|||
|
|
begin
|
|||
|
|
Database := BaseDatos;
|
|||
|
|
Transaction := Transaccion;
|
|||
|
|
SelectSQL.Assign(dmTablaContratos.sqlConsultarGridDetalles);
|
|||
|
|
InsertSQL.Assign(dmTablaContratos.sqlInsertarDetalles);
|
|||
|
|
ModifySQL.Assign(dmTablaContratos.sqlModificarDetalles);
|
|||
|
|
DeleteSQL.Assign(dmTablaContratos.sqlEliminarDetalles);
|
|||
|
|
RefreshSQL.Assign(dmTablaContratos.sqlConsultarDetalles);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
with TablaPropiedadesContratos do
|
|||
|
|
begin
|
|||
|
|
Database := BaseDatos;
|
|||
|
|
Transaction := Transaccion;
|
|||
|
|
SelectSQL.Assign(dmTablaContratos.sqlConsultarGridPropiedades);
|
|||
|
|
InsertSQL.Assign(dmTablaContratos.sqlInsertarPropiedades);
|
|||
|
|
ModifySQL.Assign(dmTablaContratos.sqlModificarPropiedades);
|
|||
|
|
DeleteSQL.Assign(dmTablaContratos.sqlEliminarPropiedades);
|
|||
|
|
RefreshSQL.Assign(dmTablaContratos.sqlConsultarPropiedades);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
with TablaPropiedades do
|
|||
|
|
begin
|
|||
|
|
Database := BaseDatos;
|
|||
|
|
Transaction := Transaccion;
|
|||
|
|
Open;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
with TablaValores do
|
|||
|
|
begin
|
|||
|
|
Database := BaseDatos;
|
|||
|
|
Transaction := Transaccion;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
with TablaDetallesMem do
|
|||
|
|
begin
|
|||
|
|
CopyStructure(TablaDetallesContratos);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
with TablaPropiedadesMem do
|
|||
|
|
begin
|
|||
|
|
CopyStructure(TablaPropiedadesContratos);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
dmTablaContratos.InicializarGridPropiedades(VistaPropiedades);
|
|||
|
|
with TcxLookupComboBoxProperties(VistaPropiedades.GetRowByFieldName('CODIGOPROPIEDAD').Properties) do
|
|||
|
|
begin
|
|||
|
|
ListSource := dsPropiedades;
|
|||
|
|
end;
|
|||
|
|
VistaPropiedades.GetRowByFieldName('VALOR').OnGetProperties := VALORGetProperties;
|
|||
|
|
|
|||
|
|
dmTablaContratos.InicializarGridDetalles(VistaDetalles);
|
|||
|
|
cbxSituacion.Properties.Items := dmTablaContratos.DarSituaciones;
|
|||
|
|
dmTablaArticulos.ArtModelo := entArticulo;
|
|||
|
|
Paginas.ActivePage := pagCliente;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
destructor TfrContratoCliente.Destroy;
|
|||
|
|
begin
|
|||
|
|
TablaDocumentos.Close;
|
|||
|
|
TablaPropiedades.Close;
|
|||
|
|
TablaValores.Close;
|
|||
|
|
|
|||
|
|
TablaDetallesMem.Close;
|
|||
|
|
TablaDetallesMem.Free;
|
|||
|
|
|
|||
|
|
TablaPropiedadesMem.Close;
|
|||
|
|
TablaPropiedadesMem.Free;
|
|||
|
|
|
|||
|
|
TablaContratos.Close;
|
|||
|
|
TablaContratos.UnPrepare;
|
|||
|
|
TablaContratos.Free;
|
|||
|
|
|
|||
|
|
TablaDetallesContratos.Close;
|
|||
|
|
TablaDetallesContratos.Unprepare;
|
|||
|
|
TablaDetallesContratos.Free;
|
|||
|
|
|
|||
|
|
TablaPropiedadesContratos.Close;
|
|||
|
|
TablaPropiedadesContratos.UnPrepare;
|
|||
|
|
TablaPropiedadesContratos.Free;
|
|||
|
|
|
|||
|
|
inherited;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
function TfrContratoCliente.EliminarDatos: Boolean;
|
|||
|
|
var
|
|||
|
|
Cadena : String;
|
|||
|
|
begin
|
|||
|
|
Result := False;
|
|||
|
|
try
|
|||
|
|
if Entidad = entContratoCocina then
|
|||
|
|
begin
|
|||
|
|
Cadena := PathDelim + StringReplace(CodigoContrato,'/','',[rfReplaceAll]);
|
|||
|
|
// No elimino si el contrato viene de un presupuesto para que los planos
|
|||
|
|
// sigan apareciendo en el presupuesto.
|
|||
|
|
if Cadena = dmTablaContratos.DarRutaPlanos(CodigoContrato) then
|
|||
|
|
EliminarDirPlanos;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
TablaContratos.Delete;
|
|||
|
|
BorrarTabla(TablaDetallesMem);
|
|||
|
|
BorrarTabla(TablaPropiedadesMem);
|
|||
|
|
Commit;
|
|||
|
|
|
|||
|
|
Result := True;
|
|||
|
|
except
|
|||
|
|
on E : EIBError do
|
|||
|
|
begin
|
|||
|
|
case E.IBErrorCode of
|
|||
|
|
isc_lock_conflict : VerMensajeFmt(msgCliConBloqueado, [Codigo.DataBinding.Field.AsString]);
|
|||
|
|
else
|
|||
|
|
TratarExcepcion(E);
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
on E : Exception do
|
|||
|
|
TratarExcepcion(E);
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrContratoCliente.FreeContenido;
|
|||
|
|
var
|
|||
|
|
Contador : integer;
|
|||
|
|
AListaCodigos : TStringList;
|
|||
|
|
begin
|
|||
|
|
if (ContenidoModal is TRdxFrameContratos) then
|
|||
|
|
begin
|
|||
|
|
CodigoContrato := (ContenidoModal as TRdxFrameContratos).CodigoContrato;
|
|||
|
|
ActivarModo;
|
|||
|
|
end;
|
|||
|
|
if (ContenidoModal is TRdxFrameClientes) then
|
|||
|
|
CodigoCliente := (ContenidoModal as TRdxFrameClientes).CodigoCliente;
|
|||
|
|
if (ContenidoModal is TRdxFrameProvincias) then
|
|||
|
|
CodigoProvincia := (ContenidoModal as TRdxFrameProvincias).CodigoProvincia;
|
|||
|
|
|
|||
|
|
if (ContenidoModal is TfrArticulos) then
|
|||
|
|
begin
|
|||
|
|
//CodigoArticulo := (ContenidoModal as TRdxFrameArticulos).CodigoArticulo;
|
|||
|
|
|
|||
|
|
AListaCodigos := (ContenidoModal as TfrArticulos).ListaArticulos;
|
|||
|
|
for Contador := AListaCodigos.Count - 1 downto 0 do
|
|||
|
|
begin
|
|||
|
|
CodigoArticulo := AListaCodigos.Strings[Contador];
|
|||
|
|
actAnadirDetalle.Execute;
|
|||
|
|
end;
|
|||
|
|
TablaDetallesMem.Delete;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
if (ContenidoModal is TRdxFramePoblaciones) then
|
|||
|
|
begin
|
|||
|
|
CodigoProvincia := (ContenidoModal as TRdxFramePoblaciones).CodigoProvincia;
|
|||
|
|
CodigoPoblacion := (ContenidoModal as TRdxFramePoblaciones).CodigoPoblacion;
|
|||
|
|
end;
|
|||
|
|
inherited FreeContenido;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
function TfrContratoCliente.ModificarDatos: Boolean;
|
|||
|
|
begin
|
|||
|
|
Result := False;
|
|||
|
|
try
|
|||
|
|
CalcularTotalContrato;
|
|||
|
|
TablaContratos.Post;
|
|||
|
|
|
|||
|
|
BorrarTabla(TablaDetallesContratos);
|
|||
|
|
SalvarDetalles;
|
|||
|
|
|
|||
|
|
BorrarTabla(TablaPropiedadesContratos);
|
|||
|
|
SalvarPropiedades;
|
|||
|
|
|
|||
|
|
Commit;
|
|||
|
|
ComprobarEstadoDirPlanos;
|
|||
|
|
Result := True;
|
|||
|
|
except
|
|||
|
|
on E : EIBError do
|
|||
|
|
TratarExcepcion(E);
|
|||
|
|
on E : Exception do
|
|||
|
|
TratarExcepcion(E);
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrContratoCliente.SetCodigoArticulo(Value: Variant);
|
|||
|
|
var
|
|||
|
|
CodigoAux : String;
|
|||
|
|
DatosArticulo : TDatosArticulo;
|
|||
|
|
begin
|
|||
|
|
if (EsCadenaVacia(Value)) then
|
|||
|
|
begin
|
|||
|
|
FCodigoArticulo := CodigoAux;
|
|||
|
|
Exit;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
CodigoAux := Trim(Value);
|
|||
|
|
if (dmTablaArticulos.ValidarCodigo(CodigoAux)) then
|
|||
|
|
begin
|
|||
|
|
CodigoAux := dmTablaArticulos.FormatearCodigo(CodigoAux);
|
|||
|
|
if (dmTablaArticulos.ExisteCodigo(CodigoAux)) then
|
|||
|
|
FCodigoArticulo := CodigoAux
|
|||
|
|
else begin
|
|||
|
|
raise Exception.CreateFmt(msgDatosCodArtNoExiste, [CodigoAux]);
|
|||
|
|
end;
|
|||
|
|
end
|
|||
|
|
else begin
|
|||
|
|
raise Exception.CreateFmt(msgDatosCodArtIncorrecto, [CodigoAux]);
|
|||
|
|
Exit;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
DatosArticulo := TDatosArticulo.Create(CodigoAux);
|
|||
|
|
try
|
|||
|
|
with TablaDetallesMem do
|
|||
|
|
begin
|
|||
|
|
Edit;
|
|||
|
|
FieldByName('CODIGOCONTRATO').AsString := Codigo.DataBinding.Field.AsString;
|
|||
|
|
FieldByName('NUMCONCEPTO').AsInteger := RecNo;
|
|||
|
|
FieldByName('CODIGOARTICULO').AsString := DatosArticulo.Codigo;
|
|||
|
|
FieldByName('REFERENCIA').AsString := DatosArticulo.Referencia;
|
|||
|
|
FieldByName('DESCRIPCION').AsString := DatosArticulo.Descripcion;
|
|||
|
|
FieldByName('TIPOCONCEPTO').AsVariant := '';
|
|||
|
|
FieldByName('IMPORTEUNIDAD').AsFloat := DatosArticulo.Precio;
|
|||
|
|
if EsCadenaVacia(FieldByName('CANTIDAD').AsString) then
|
|||
|
|
FieldByName('CANTIDAD').AsString := '1';
|
|||
|
|
Post;
|
|||
|
|
InsertarPropiedades(FieldByName('NUMCONCEPTO').AsInteger);
|
|||
|
|
gridDetalles.Refresh;
|
|||
|
|
CalcularTotalDetalle;
|
|||
|
|
end;
|
|||
|
|
FCodigoArticulo := Value;
|
|||
|
|
finally
|
|||
|
|
DatosArticulo.Free;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrContratoCliente.SetCodigoCliente(Value: Variant);
|
|||
|
|
var
|
|||
|
|
DatosCliente : TDatosCliente;
|
|||
|
|
CodAux : Variant;
|
|||
|
|
DireccionElegida : TDireccionElegida;
|
|||
|
|
NumSucursal : Integer;
|
|||
|
|
begin
|
|||
|
|
if EsCadenaVacia(Value) then
|
|||
|
|
exit;
|
|||
|
|
|
|||
|
|
CodAux := Trim(Value);
|
|||
|
|
if (dmTablaClientes.ValidarCodigo(CodAux)) then begin
|
|||
|
|
CodAux := dmTablaClientes.FormatearCodigo(CodAux);
|
|||
|
|
if (dmTablaClientes.ExisteCodigo(CodAux)) then
|
|||
|
|
FCodigoCliente := CodAux
|
|||
|
|
else begin
|
|||
|
|
raise Exception.CreateFmt(msgCliCodCliNoExiste, [CodAux]);
|
|||
|
|
end;
|
|||
|
|
end
|
|||
|
|
else begin
|
|||
|
|
raise Exception.CreateFmt(msgCliCodCliIncorrecto, [CodAux]);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
DatosCliente := TDatosCliente.Create(FCodigoCliente);
|
|||
|
|
try
|
|||
|
|
CodCliente.DataBinding.Field.AsString := DatosCliente.Codigo;
|
|||
|
|
if DatosCliente.Sucursales.Count > 0 then
|
|||
|
|
begin
|
|||
|
|
frElegirDireccionCliente := TfrElegirDireccionCliente.Create(Self);
|
|||
|
|
try
|
|||
|
|
frElegirDireccionCliente.Cliente := DatosCliente;
|
|||
|
|
frElegirDireccionCliente.ShowModal;
|
|||
|
|
DireccionElegida := frElegirDireccionCliente.DireccionSeleccionada;
|
|||
|
|
NumSucursal := frElegirDireccionCliente.NumSucursal;
|
|||
|
|
finally
|
|||
|
|
frElegirDireccionCliente.Free;
|
|||
|
|
end;
|
|||
|
|
end
|
|||
|
|
else
|
|||
|
|
DireccionElegida := dePrincipal;
|
|||
|
|
|
|||
|
|
if DireccionElegida = dePrincipal then
|
|||
|
|
begin
|
|||
|
|
NIFCIF.DataBinding.Field.AsString := DatosCliente.Nifcif;
|
|||
|
|
Nombre.DataBinding.Field.AsString := DatosCliente.Nombre;
|
|||
|
|
Calle.DataBinding.Field.AsString := DatosCliente.Calle;
|
|||
|
|
Numero.DataBinding.Field.AsString := DatosCliente.Numero;
|
|||
|
|
Piso.DataBinding.Field.AsString := DatosCliente.Piso;
|
|||
|
|
Provincia.DataBinding.Field.AsString := DatosCliente.Provincia;
|
|||
|
|
FCodigoProvincia := dmTablaProvincias.DarCodigoProvincia(DatosCliente.Provincia);
|
|||
|
|
Poblacion.DataBinding.Field.AsString := DatosCliente.Poblacion;
|
|||
|
|
CodigoPostal.DataBinding.Field.AsString := DatosCliente.CodigoPostal;
|
|||
|
|
Telefono1.DataBinding.Field.AsString := DatosCliente.Telefono1;
|
|||
|
|
Telefono2.DataBinding.Field.AsString := DatosCliente.Telefono2;
|
|||
|
|
Movil1.DataBinding.Field.AsString := DatosCliente.Movil1;
|
|||
|
|
Movil2.DataBinding.Field.AsString := DatosCliente.Movil2;
|
|||
|
|
Fax.DataBinding.Field.AsString := DatosCliente.Fax;
|
|||
|
|
PersonaContacto.DataBinding.Field.AsString := DatosCliente.PersonaContacto;
|
|||
|
|
end
|
|||
|
|
else begin
|
|||
|
|
with DatosCliente.Sucursales do
|
|||
|
|
begin
|
|||
|
|
NIFCIF.DataBinding.Field.AsString := Sucursal[NumSucursal].Nifcif;
|
|||
|
|
Nombre.DataBinding.Field.AsString := Sucursal[NumSucursal].Nombre;
|
|||
|
|
Calle.DataBinding.Field.AsString := Sucursal[NumSucursal].Calle;
|
|||
|
|
Numero.DataBinding.Field.AsString := Sucursal[NumSucursal].Numero;
|
|||
|
|
Piso.DataBinding.Field.AsString := Sucursal[NumSucursal].Piso;
|
|||
|
|
Provincia.DataBinding.Field.AsString := Sucursal[NumSucursal].Provincia;
|
|||
|
|
FCodigoProvincia := dmTablaProvincias.DarCodigoProvincia(Sucursal[NumSucursal].Provincia);
|
|||
|
|
Poblacion.DataBinding.Field.AsString := Sucursal[NumSucursal].Poblacion;
|
|||
|
|
CodigoPostal.DataBinding.Field.AsString := Sucursal[NumSucursal].CodigoPostal;
|
|||
|
|
Telefono1.DataBinding.Field.AsString := Sucursal[NumSucursal].Telefono1;
|
|||
|
|
Telefono2.DataBinding.Field.AsString := Sucursal[NumSucursal].Telefono2;
|
|||
|
|
Movil1.DataBinding.Field.AsString := Sucursal[NumSucursal].Movil1;
|
|||
|
|
Movil2.DataBinding.Field.AsString := Sucursal[NumSucursal].Movil2;
|
|||
|
|
Fax.DataBinding.Field.AsString := Sucursal[NumSucursal].Fax;
|
|||
|
|
PersonaContacto.DataBinding.Field.AsString := Sucursal[NumSucursal].PersonaContacto;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
finally
|
|||
|
|
DatosCliente.Free;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrContratoCliente.SetCodigoPoblacion(Value: Variant);
|
|||
|
|
begin
|
|||
|
|
if (not EsCadenaVacia(Value)) then
|
|||
|
|
begin
|
|||
|
|
FCodigoPoblacion := Value;
|
|||
|
|
Poblacion.DataBinding.Field.AsString := dmTablaPoblaciones.darNombrePoblacion(FCodigoProvincia, FCodigoPoblacion);
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrContratoCliente.SetCodigoProvincia(Value: Variant);
|
|||
|
|
begin
|
|||
|
|
if (not EsCadenaVacia(Value)) then
|
|||
|
|
begin
|
|||
|
|
FCodigoProvincia := Value;
|
|||
|
|
Provincia.DataBinding.Field.AsString := dmTablaProvincias.DarNombreProvincia(FCodigoProvincia);
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrContratoCliente.VerModal;
|
|||
|
|
var
|
|||
|
|
DatosFamilia : TDatosFamilia;
|
|||
|
|
begin
|
|||
|
|
if (ContenidoModal is TRdxFramePoblaciones) then
|
|||
|
|
(ContenidoModal as TRdxFramePoblaciones).CodigoProvincia := CodigoProvincia;
|
|||
|
|
|
|||
|
|
if (ContenidoModal is TRdxFrameClientes) then
|
|||
|
|
(ContenidoModal as TRdxFrameClientes).CodigoCliente := CodigoCliente;
|
|||
|
|
|
|||
|
|
if (ContenidoModal is TfrArticulos) then
|
|||
|
|
begin
|
|||
|
|
FCodigoArticulo := TablaDetallesMem.FieldByName('CODIGOARTICULO').AsString;
|
|||
|
|
if EsCadenaVacia(FCodigoArticulo) then
|
|||
|
|
(ContenidoModal as TfrArticulos).Familia := TablaDocumentos.FieldByName('DESCFAMILIA').AsString
|
|||
|
|
else begin
|
|||
|
|
//DatosFamilia := TDatosFamilia.Create(TablaDetallesMem.FieldByName('FAMILIA').AsInteger);
|
|||
|
|
try
|
|||
|
|
//(ContenidoModal as TfrArticulos).Familia := DatosFamilia.Descripcion;
|
|||
|
|
(ContenidoModal as TfrArticulos).CodigoArticulo := FCodigoArticulo;
|
|||
|
|
finally
|
|||
|
|
//DatosFamilia.Free;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
inherited;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrContratoCliente.bSalirClick(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
try
|
|||
|
|
Rollback;
|
|||
|
|
CloseFrame;
|
|||
|
|
except
|
|||
|
|
on E : EIBError do
|
|||
|
|
TratarExcepcion(E);
|
|||
|
|
on E : Exception do
|
|||
|
|
TratarExcepcion(E);
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrContratoCliente.bGuardarClick(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
if (RealizarOperacion) then
|
|||
|
|
CloseFrame;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrContratoCliente.bCancelarClick(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
if (TratarCambios = IDOK) then
|
|||
|
|
CloseFrame;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrContratoCliente.CodClienteButtonClick(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
ContenidoModal := TfrClientes.Create(Self);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrContratoCliente.CodigoArticuloDetalleSetText(
|
|||
|
|
Sender: TField; const Text: String);
|
|||
|
|
begin
|
|||
|
|
Sender.AsString := Text;
|
|||
|
|
CodigoArticulo := Text;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrContratoCliente.CantidadDetalleSetText(Sender: TField;
|
|||
|
|
const Text: String);
|
|||
|
|
begin
|
|||
|
|
if EsCadenaVacia(Text) then
|
|||
|
|
Sender.AsString := '1'
|
|||
|
|
else
|
|||
|
|
Sender.AsString := Text;
|
|||
|
|
CalcularTotalDetalle;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrContratoCliente.PrecioDetalleSetText(Sender: TField;
|
|||
|
|
const Text: String);
|
|||
|
|
begin
|
|||
|
|
if EsCadenaVacia(Text) then
|
|||
|
|
Sender.AsString := '0'
|
|||
|
|
else
|
|||
|
|
Sender.AsString := Text;
|
|||
|
|
CalcularTotalDetalle;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrContratoCliente.ProvinciaButtonClick(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
CaptionModal := msgListaProvincias;
|
|||
|
|
WidthModal := 280;
|
|||
|
|
HeightModal := 460;
|
|||
|
|
ContenidoModal := TfrProvincias.Create(Self);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrContratoCliente.PoblacionButtonClick(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
if (EsCadenaVacia(CodigoProvincia)) then begin
|
|||
|
|
VerMensaje(msgSinProvincia);
|
|||
|
|
Paginas.ActivePageIndex := 0;
|
|||
|
|
Provincia.SetFocus;
|
|||
|
|
Exit;
|
|||
|
|
end;
|
|||
|
|
CaptionModal := Format(msgListaPoblaciones, [dmTablaProvincias.darNombreProvincia(CodigoProvincia)]);
|
|||
|
|
WidthModal := 280;
|
|||
|
|
HeightModal := 460;
|
|||
|
|
ContenidoModal := TfrPoblaciones.Create(Self);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrContratoCliente.ActivarEventosCampos;
|
|||
|
|
begin
|
|||
|
|
with TablaContratos do
|
|||
|
|
begin
|
|||
|
|
FieldByName('CODIGOCLIENTE').OnSetText := CodCliSetText;
|
|||
|
|
FieldByName('IVA').OnSetText := IVASetText;
|
|||
|
|
FieldByName('DESCUENTO').OnSetText := DtoSetText;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
with TablaDetallesMem do
|
|||
|
|
begin
|
|||
|
|
FieldByName('CODIGOARTICULO').OnSetText := CodigoArticuloDetalleSetText;
|
|||
|
|
FieldByName('REFERENCIA').OnSetText := ReferenciaArticuloDetalleSetText;
|
|||
|
|
FieldByName('CANTIDAD').OnSetText := CantidadDetalleSetText;
|
|||
|
|
FieldByName('IMPORTEUNIDAD').OnSetText := PrecioDetalleSetText;
|
|||
|
|
AfterDelete := DetalleAfterDelete;
|
|||
|
|
AfterInsert := DetallesAfterInsert;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
with TablaPropiedadesMem do
|
|||
|
|
begin
|
|||
|
|
AfterInsert := PropiedadesAfterInsert;
|
|||
|
|
AfterDelete := PropiedadesAfterDelete;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
with VistaDetalles do
|
|||
|
|
begin
|
|||
|
|
TcxButtonEditProperties(GetColumnByFieldName('CODIGOARTICULO').Properties).OnButtonClick := GridBotonCodigoArticuloClick;
|
|||
|
|
TcxButtonEditProperties(GetColumnByFieldName('REFERENCIA').Properties).OnButtonClick := GridBotonReferenciaArticuloClick;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrContratoCliente.SalvarDetalles;
|
|||
|
|
var
|
|||
|
|
NumeroCampo : Integer;
|
|||
|
|
begin
|
|||
|
|
try
|
|||
|
|
with TablaDetallesMem do
|
|||
|
|
begin
|
|||
|
|
DisableControls;
|
|||
|
|
Filtered := False;
|
|||
|
|
First;
|
|||
|
|
while not EOF do
|
|||
|
|
begin
|
|||
|
|
TablaDetallesContratos.Append;
|
|||
|
|
for NumeroCampo := 0 to FieldCount-1 do
|
|||
|
|
begin
|
|||
|
|
if Fields[NumeroCampo].FieldName = 'CODIGOCONTRATO' then
|
|||
|
|
TablaDetallesContratos.Fields[NumeroCampo].AsString := Codigo.DataBinding.Field.AsString
|
|||
|
|
else
|
|||
|
|
if Fields[NumeroCampo].FieldName = 'NUMCONCEPTO' then
|
|||
|
|
TablaDetallesContratos.Fields[NumeroCampo].AsInteger := RecNo - 1
|
|||
|
|
else
|
|||
|
|
TablaDetallesContratos.Fields[NumeroCampo].AsVariant := Fields[NumeroCampo].AsVariant;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
if (RecNo-1 = 0) and (not (Entidad in [entContratoCliente, entContratoVarios, entContratoElectro])) then
|
|||
|
|
TablaDetallesContratos.FieldByName('OBSERVACIONES').AsString := FObservaciones1;
|
|||
|
|
|
|||
|
|
if (RecNo-1 = 1) and (Entidad = entContratoArmarios) then
|
|||
|
|
TablaDetallesContratos.FieldByName('OBSERVACIONES').AsString := FObservaciones2;
|
|||
|
|
|
|||
|
|
TablaDetallesContratos.Post;
|
|||
|
|
Next;
|
|||
|
|
end;
|
|||
|
|
EnableControls;
|
|||
|
|
end
|
|||
|
|
except
|
|||
|
|
on E : EIBError do begin
|
|||
|
|
if E.IBErrorCode = isc_unique_key_violation then
|
|||
|
|
begin
|
|||
|
|
TablaDetallesContratos.Delete;
|
|||
|
|
TablaDetallesMem.EnableControls;
|
|||
|
|
end;
|
|||
|
|
raise EIBError.Create(E.SQLCode, E.IBErrorCode, E.Message);
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrContratoCliente.CargarDetalles;
|
|||
|
|
var
|
|||
|
|
NumeroCampo : Integer;
|
|||
|
|
begin
|
|||
|
|
with TablaDetallesMem do
|
|||
|
|
begin
|
|||
|
|
if TablaDetallesContratos.IsEmpty then
|
|||
|
|
Exit;
|
|||
|
|
DisableControls;
|
|||
|
|
TablaDetallesContratos.First;
|
|||
|
|
while not TablaDetallesContratos.EOF do
|
|||
|
|
begin
|
|||
|
|
Append;
|
|||
|
|
for NumeroCampo := 0 to TablaDetallesContratos.FieldCount-1 do
|
|||
|
|
Fields[NumeroCampo].AsString := TablaDetallesContratos.Fields[NumeroCampo].AsString;
|
|||
|
|
Post;
|
|||
|
|
TablaDetallesContratos.Next;
|
|||
|
|
end;
|
|||
|
|
First;
|
|||
|
|
EnableControls;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrContratoCliente.CargarPropiedades;
|
|||
|
|
var
|
|||
|
|
NumeroCampo : Integer;
|
|||
|
|
begin
|
|||
|
|
with TablaPropiedadesMem do
|
|||
|
|
begin
|
|||
|
|
if TablaPropiedadesContratos.IsEmpty then
|
|||
|
|
Exit;
|
|||
|
|
DisableControls;
|
|||
|
|
TablaPropiedadesContratos.First;
|
|||
|
|
while not TablaPropiedadesContratos.EOF do
|
|||
|
|
begin
|
|||
|
|
Append;
|
|||
|
|
for NumeroCampo := 0 to TablaPropiedadesContratos.FieldCount-1 do
|
|||
|
|
Fields[NumeroCampo].AsString := TablaPropiedadesContratos.Fields[NumeroCampo].AsString;
|
|||
|
|
Post;
|
|||
|
|
TablaPropiedadesContratos.Next;
|
|||
|
|
end;
|
|||
|
|
First;
|
|||
|
|
EnableControls;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrContratoCliente.DetalleAfterDelete(DataSet: TDataSet);
|
|||
|
|
begin
|
|||
|
|
AsignarNumConceptoDetalles;
|
|||
|
|
CalcularTotalContrato;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrContratoCliente.actAnadirDetalleExecute(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
try
|
|||
|
|
with TablaDetallesMem do
|
|||
|
|
begin
|
|||
|
|
Next;
|
|||
|
|
if EOF then
|
|||
|
|
Append
|
|||
|
|
else begin
|
|||
|
|
Prior;
|
|||
|
|
Insert;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
except
|
|||
|
|
on E : EIBError do
|
|||
|
|
TratarExcepcion(E);
|
|||
|
|
on E : Exception do
|
|||
|
|
TratarExcepcion(E);
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrContratoCliente.actEliminarDetalleExecute(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
if (VerMensajePregunta(msgDeseaBorrar) <> IDYES) then
|
|||
|
|
Exit;
|
|||
|
|
if TablaDetallesMem.RecordCount = 0 then begin
|
|||
|
|
{ Hacemos un cancel de la tabla por si el registro actual estuviera
|
|||
|
|
recien creado }
|
|||
|
|
TablaDetallesMem.Cancel;
|
|||
|
|
Exit
|
|||
|
|
end;
|
|||
|
|
try
|
|||
|
|
BorrarPropiedadesConcepto(TablaDetallesMem.FieldByName('NUMCONCEPTO').AsVariant);
|
|||
|
|
TablaDetallesMem.Delete;
|
|||
|
|
except
|
|||
|
|
on E : EIBError do
|
|||
|
|
TratarExcepcion(E);
|
|||
|
|
on E : Exception do
|
|||
|
|
TratarExcepcion(E);
|
|||
|
|
end;
|
|||
|
|
CalcularTotalContrato;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrContratoCliente.ProvinciaSetText(Sender: TField;
|
|||
|
|
const Text: String);
|
|||
|
|
begin
|
|||
|
|
FCodigoProvincia := dmTablaProvincias.DarCodigoProvincia(Text);
|
|||
|
|
Sender.AsString := Text;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrContratoCliente.actEliminarTodoDetalleExecute(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
if (VerMensajePregunta(msgDeseaBorrarTodo) <> IDYES) then
|
|||
|
|
Exit;
|
|||
|
|
BorrarTabla(TablaDetallesMem);
|
|||
|
|
BorrarTabla(TablaPropiedadesMem);
|
|||
|
|
CalcularTotalContrato;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrContratoCliente.DtoSetText(Sender: TField;
|
|||
|
|
const Text: String);
|
|||
|
|
begin
|
|||
|
|
if EsCadenaVacia(Text) then
|
|||
|
|
Sender.AsString := '0'
|
|||
|
|
else begin
|
|||
|
|
ValidarDto(Text);
|
|||
|
|
Sender.AsString := Text;
|
|||
|
|
end;
|
|||
|
|
CalcularTotalContrato;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrContratoCliente.IVASetText(Sender: TField;
|
|||
|
|
const Text: String);
|
|||
|
|
begin
|
|||
|
|
if EsCadenaVacia(Text) then
|
|||
|
|
Sender.AsString := '0'
|
|||
|
|
else begin
|
|||
|
|
ValidarIVA(Text);
|
|||
|
|
Sender.AsString := Text;
|
|||
|
|
end;
|
|||
|
|
CalcularTotalContrato;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrContratoCliente.DetallesAfterInsert(DataSet: TDataSet);
|
|||
|
|
begin
|
|||
|
|
with DataSet do
|
|||
|
|
begin
|
|||
|
|
Edit;
|
|||
|
|
FieldByName('CODIGOCONTRATO').AsString := Codigo.DataBinding.Field.AsString;
|
|||
|
|
FieldByName('NUMCONCEPTO').AsInteger := RecNo;
|
|||
|
|
FieldByName('DESCRIPCION').AsString := '';
|
|||
|
|
if EsCadenaVacia(FieldByName('CANTIDAD').AsString) then
|
|||
|
|
FieldByName('CANTIDAD').AsString := '1';
|
|||
|
|
if (Entidad in [entContratoCliente, entContratoVarios, entContratoElectro]) then
|
|||
|
|
FieldByName('TIPOCONCEPTO').AsVariant := ''
|
|||
|
|
else
|
|||
|
|
FieldByName('TIPOCONCEPTO').AsVariant := 'PRECIO';
|
|||
|
|
Post;
|
|||
|
|
AsignarNumConceptoDetalles;
|
|||
|
|
Edit;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrContratoCliente.CodClientePropertiesButtonClick(
|
|||
|
|
Sender: TObject; AButtonIndex: Integer);
|
|||
|
|
begin
|
|||
|
|
ContenidoModal := TfrClientes.Create(Self);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrContratoCliente.ProvinciaPropertiesButtonClick(
|
|||
|
|
Sender: TObject; AButtonIndex: Integer);
|
|||
|
|
begin
|
|||
|
|
CaptionModal := msgListaProvincias;
|
|||
|
|
WidthModal := 280;
|
|||
|
|
HeightModal := 460;
|
|||
|
|
ContenidoModal := TfrProvincias.Create(Self);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrContratoCliente.PoblacionPropertiesButtonClick(
|
|||
|
|
Sender: TObject; AButtonIndex: Integer);
|
|||
|
|
begin
|
|||
|
|
if EsCadenaVacia(CodigoProvincia) then
|
|||
|
|
begin
|
|||
|
|
VerMensaje(msgSinProvincia);
|
|||
|
|
Paginas.ActivePageIndex := 0;
|
|||
|
|
Provincia.SetFocus;
|
|||
|
|
Exit;
|
|||
|
|
end;
|
|||
|
|
CaptionModal := Format(msgListaPoblaciones, [dmTablaProvincias.darNombreProvincia(CodigoProvincia)]);
|
|||
|
|
WidthModal := 280;
|
|||
|
|
HeightModal := 460;
|
|||
|
|
ContenidoModal := TfrPoblaciones.Create(Self);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrContratoCliente.GridBotonCodigoArticuloClick(
|
|||
|
|
Sender: TObject; AButtonIndex: Integer);
|
|||
|
|
begin
|
|||
|
|
TablaDetallesMem.Edit;
|
|||
|
|
ContenidoModal := TfrArticulos.Create(Self);
|
|||
|
|
gridDetalles.SetFocus;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrContratoCliente.InsertarPropiedades(NumConcepto : Integer; Seccion : String);
|
|||
|
|
var
|
|||
|
|
DatosDocumento : TDocumento;
|
|||
|
|
Contador : Integer;
|
|||
|
|
FPropiedad : TDatosPropiedad;
|
|||
|
|
FNumPropiedad : Integer;
|
|||
|
|
begin
|
|||
|
|
with TablaPropiedadesMem do
|
|||
|
|
begin
|
|||
|
|
DisableControls;
|
|||
|
|
DatosDocumento := TDocumento.Create(TablaContratos.FieldByName('CODIGODOCUMENTO').AsString);
|
|||
|
|
try
|
|||
|
|
BorrarPropiedadesConcepto(NumConcepto);
|
|||
|
|
FNumPropiedad := 0;
|
|||
|
|
First;
|
|||
|
|
for Contador := 0 to (DatosDocumento.ListaPropiedades.Count - 1) do
|
|||
|
|
begin
|
|||
|
|
FPropiedad := DatosDocumento.ListaPropiedades.Items[Contador];
|
|||
|
|
if (not EsCadenaVacia(Seccion)) and (FPropiedad.Seccion <> Seccion) then
|
|||
|
|
Continue
|
|||
|
|
else begin
|
|||
|
|
Append;
|
|||
|
|
FieldByName('CODIGOCONTRATO').AsString := CodigoContrato;
|
|||
|
|
FieldByName('NUMCONCEPTO').AsInteger := NumConcepto;
|
|||
|
|
FieldByName('NUMPROPIEDAD').AsInteger := FNumPropiedad;
|
|||
|
|
FieldByName('CODIGOPROPIEDAD').AsInteger := FPropiedad.CodigoPropiedad;
|
|||
|
|
FieldByName('VALOR').AsString := FPropiedad.Valor;
|
|||
|
|
Post;
|
|||
|
|
FNumPropiedad := FNumPropiedad + 1;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
First;
|
|||
|
|
finally
|
|||
|
|
DatosDocumento.Free;
|
|||
|
|
EnableControls;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrContratoCliente.SalvarPropiedades;
|
|||
|
|
var
|
|||
|
|
NumeroCampo : Integer;
|
|||
|
|
begin
|
|||
|
|
try
|
|||
|
|
with TablaPropiedadesMem do
|
|||
|
|
begin
|
|||
|
|
DisableControls;
|
|||
|
|
Filtered := False;
|
|||
|
|
First;
|
|||
|
|
while not EOF do
|
|||
|
|
begin
|
|||
|
|
if not EsCadenaVacia(FieldByName('CODIGOPROPIEDAD').AsVariant) then
|
|||
|
|
begin
|
|||
|
|
TablaPropiedadesContratos.Append;
|
|||
|
|
for NumeroCampo := 0 to FieldCount-1 do
|
|||
|
|
begin
|
|||
|
|
if Fields[NumeroCampo].FieldName = 'CODIGOCONTRATO' then
|
|||
|
|
TablaPropiedadesContratos.Fields[NumeroCampo].AsString := Codigo.DataBinding.Field.AsString
|
|||
|
|
else
|
|||
|
|
TablaPropiedadesContratos.Fields[NumeroCampo].AsVariant := Fields[NumeroCampo].AsVariant;
|
|||
|
|
end;
|
|||
|
|
TablaPropiedadesContratos.Post;
|
|||
|
|
end;
|
|||
|
|
Next;
|
|||
|
|
end;
|
|||
|
|
EnableControls;
|
|||
|
|
end
|
|||
|
|
except
|
|||
|
|
on E : EIBError do begin
|
|||
|
|
if E.IBErrorCode = isc_unique_key_violation then
|
|||
|
|
begin
|
|||
|
|
TablaPropiedadesContratos.Delete;
|
|||
|
|
TablaPropiedadesMem.EnableControls;
|
|||
|
|
end;
|
|||
|
|
raise EIBError.Create(E.SQLCode, E.IBErrorCode, E.Message);
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrContratoCliente.BorrarPropiedadesConcepto(
|
|||
|
|
NumConcepto: Integer);
|
|||
|
|
begin
|
|||
|
|
with TablaPropiedadesMem do
|
|||
|
|
begin
|
|||
|
|
if IsEmpty then
|
|||
|
|
Exit;
|
|||
|
|
DisableControls;
|
|||
|
|
try
|
|||
|
|
Last;
|
|||
|
|
while not BOF do begin
|
|||
|
|
if FieldByName('NUMCONCEPTO').AsInteger = NumConcepto then
|
|||
|
|
Delete;
|
|||
|
|
Prior;
|
|||
|
|
end;
|
|||
|
|
if FieldByName('NUMCONCEPTO').AsInteger = NumConcepto then
|
|||
|
|
Delete;
|
|||
|
|
finally
|
|||
|
|
EnableControls;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrContratoCliente.AsignarNumConceptoDetalles;
|
|||
|
|
var
|
|||
|
|
FDetallesBookmark : string;
|
|||
|
|
NumConAnt,
|
|||
|
|
NumConNue : Integer;
|
|||
|
|
begin
|
|||
|
|
with TablaDetallesMem do
|
|||
|
|
begin
|
|||
|
|
DisableControls;
|
|||
|
|
FDetallesBookmark := Bookmark;
|
|||
|
|
try
|
|||
|
|
Last;
|
|||
|
|
while not BOF do
|
|||
|
|
begin
|
|||
|
|
Edit;
|
|||
|
|
NumConAnt := FieldByName('NUMCONCEPTO').AsInteger;
|
|||
|
|
NumConNue := RecNo;
|
|||
|
|
FieldByName('NUMCONCEPTO').AsInteger := NumConNue;
|
|||
|
|
Post;
|
|||
|
|
ReasignarNumConceptoPropiedades(NumConAnt, NumConNue);
|
|||
|
|
Prior;
|
|||
|
|
end;
|
|||
|
|
finally
|
|||
|
|
EnableControls;
|
|||
|
|
Bookmark := FDetallesBookmark;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrContratoCliente.ReasignarNumConceptoPropiedades(NumConAnt,
|
|||
|
|
NumConNue: Integer);
|
|||
|
|
begin
|
|||
|
|
if NumConAnt = NumConNue then
|
|||
|
|
exit;
|
|||
|
|
with TablaPropiedadesMem do
|
|||
|
|
begin
|
|||
|
|
DisableControls;
|
|||
|
|
try
|
|||
|
|
First;
|
|||
|
|
while not EOF do begin
|
|||
|
|
if FieldByName('NUMCONCEPTO').AsInteger = NumConAnt then
|
|||
|
|
begin
|
|||
|
|
Edit;
|
|||
|
|
FieldByName('NUMCONCEPTO').AsInteger := NumConNue;
|
|||
|
|
Post;
|
|||
|
|
end;
|
|||
|
|
Next;
|
|||
|
|
end;
|
|||
|
|
finally
|
|||
|
|
EnableControls;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrContratoCliente.PropiedadesAfterInsert(DataSet: TDataSet);
|
|||
|
|
begin
|
|||
|
|
with DataSet do
|
|||
|
|
begin
|
|||
|
|
FieldByName('CODIGOCONTRATO').AsString := TablaDetallesMem.FieldByName('CODIGOCONTRATO').AsString;
|
|||
|
|
|
|||
|
|
if Entidad in [entContratoCocina, entContratoBano] then
|
|||
|
|
FieldByName('NUMCONCEPTO').AsInteger := 0
|
|||
|
|
else begin
|
|||
|
|
if Entidad = entContratoArmarios then
|
|||
|
|
FieldByName('NUMCONCEPTO').AsInteger := Seccion.ItemIndex
|
|||
|
|
else
|
|||
|
|
FieldByName('NUMCONCEPTO').AsInteger := TablaDetallesMem.FieldByName('NUMCONCEPTO').AsInteger;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
Post;
|
|||
|
|
AsignarNumPropiedad;
|
|||
|
|
Edit;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrContratoCliente.CodigoPropertiesButtonClick(
|
|||
|
|
Sender: TObject; AButtonIndex: Integer);
|
|||
|
|
begin
|
|||
|
|
if (TratarCambios = IDCANCEL) then
|
|||
|
|
exit;
|
|||
|
|
{ Esto es porque en modo 'Modificar' hacemos un cambio y pulsamos
|
|||
|
|
este bot<EFBFBD>n se cierra la tabla y si en el frame hijo (el del grid) damos
|
|||
|
|
a cancelar, FCodigoCliente es NULL y da error al activar modo porque
|
|||
|
|
no se inicializa los par<EFBFBD>metros de la sql. Lo hace BuscarCliente. }
|
|||
|
|
{ if not TablaContratos.Active then
|
|||
|
|
BuscarContrato;}
|
|||
|
|
ContenidoModal := TfrContratosClientes.Create(Self);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrContratoCliente.DesactivarEventosCampos;
|
|||
|
|
begin
|
|||
|
|
with TablaContratos do
|
|||
|
|
begin
|
|||
|
|
if FindField('CODIGOCLIENTE') <> NIL then
|
|||
|
|
FieldByName('CODIGOCLIENTE').OnSetText := NIL;
|
|||
|
|
if FindField('IVA') <> NIL then
|
|||
|
|
FieldByName('IVA').OnSetText := NIL;
|
|||
|
|
if FindField('DESCUENTO') <> NIL then
|
|||
|
|
FieldByName('DESCUENTO').OnSetText := NIL;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
with TablaDetallesMem do
|
|||
|
|
begin
|
|||
|
|
if FindField('CODIGOARTICULO') <> NIL then
|
|||
|
|
FieldByName('CODIGOARTICULO').OnSetText := NIL;
|
|||
|
|
if FindField('REFERENCIA') <> NIL then
|
|||
|
|
FieldByName('REFERENCIA').OnSetText := NIL;
|
|||
|
|
if FindField('CANTIDAD') <> NIL then
|
|||
|
|
FieldByName('CANTIDAD').OnSetText := NIL;
|
|||
|
|
if FindField('IMPORTEUNIDAD') <> NIL then
|
|||
|
|
FieldByName('IMPORTEUNIDAD').OnSetText := NIL;
|
|||
|
|
AfterDelete := NIL;
|
|||
|
|
AfterInsert := NIL;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
with TablaPropiedadesMem do
|
|||
|
|
begin
|
|||
|
|
AfterInsert := NIL;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
with VistaDetalles do
|
|||
|
|
begin
|
|||
|
|
if GetColumnByFieldName('CODIGOARTICULO') <> NIL then
|
|||
|
|
TcxButtonEditProperties(GetColumnByFieldName('CODIGOARTICULO').Properties).OnButtonClick := NIL;
|
|||
|
|
if GetColumnByFieldName('REFERENCIA') <> NIL then
|
|||
|
|
TcxButtonEditProperties(GetColumnByFieldName('REFERENCIA').Properties).OnButtonClick := NIL;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
cbxSituacion.Properties.OnChange := NIL;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrContratoCliente.CodCliSetText(Sender: TField;
|
|||
|
|
const Text: String);
|
|||
|
|
begin
|
|||
|
|
Sender.AsString := Text;
|
|||
|
|
CodigoCliente := Text;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrContratoCliente.actEliminarDetalleUpdate(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
if not (Modo in [Anadir, Modificar]) then
|
|||
|
|
(Sender as TAction).Enabled := False
|
|||
|
|
else
|
|||
|
|
(Sender as TAction).Enabled := not (TablaDetallesMem.RecordCount = 0);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrContratoCliente.actEliminarTodoDetalleUpdate(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
if not (Modo in [Anadir, Modificar]) then
|
|||
|
|
(Sender as TAction).Enabled := False
|
|||
|
|
else
|
|||
|
|
(Sender as TAction).Enabled := not (TablaDetallesMem.RecordCount = 0);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrContratoCliente.CargarPropiedadesArticulo(
|
|||
|
|
NumConcepto: Integer; DatosArticulo: TDatosArticulo);
|
|||
|
|
var
|
|||
|
|
FPropiedad : TDatosPropiedad;
|
|||
|
|
FBookmark : string;
|
|||
|
|
begin
|
|||
|
|
with TablaPropiedadesMem do
|
|||
|
|
begin
|
|||
|
|
FBookmark := Bookmark;
|
|||
|
|
DisableControls;
|
|||
|
|
try
|
|||
|
|
First;
|
|||
|
|
while not EOF do
|
|||
|
|
begin
|
|||
|
|
if FieldByName('NUMCONCEPTO').AsInteger = NumConcepto then
|
|||
|
|
begin
|
|||
|
|
FPropiedad := TDatosPropiedad.Create;
|
|||
|
|
FPropiedad.CodigoPropiedad := FieldByName('CODIGOPROPIEDAD').AsInteger;
|
|||
|
|
FPropiedad.Valor := FieldByName('VALOR').AsString;
|
|||
|
|
DatosArticulo.ListaPropiedades.Add(FPropiedad);
|
|||
|
|
end;
|
|||
|
|
Next;
|
|||
|
|
end;
|
|||
|
|
finally
|
|||
|
|
Bookmark := FBookmark;
|
|||
|
|
EnableControls;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrContratoCliente.cbXDocumentoPropertiesValidate(
|
|||
|
|
Sender: TObject; var DisplayValue: Variant; var ErrorText: TCaption;
|
|||
|
|
var Error: Boolean);
|
|||
|
|
begin
|
|||
|
|
if VerMensajePreguntaFmt(msgCliCambiarTipoPre, [cbxDocumento.Text]) = mrYES then
|
|||
|
|
CargarDatosDocumento(TablaDocumentos.FieldByName('CODIGO').AsString)
|
|||
|
|
else begin
|
|||
|
|
ErrorText := '';
|
|||
|
|
Error := True;
|
|||
|
|
cbxDocumento.Undo; // Restaurar el valor anterior
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrContratoCliente.actEditarPropiedadesUpdate(
|
|||
|
|
Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
if not (Modo in [Anadir, Modificar]) then
|
|||
|
|
(Sender as TAction).Enabled := False
|
|||
|
|
else
|
|||
|
|
(Sender as TAction).Enabled := not (TablaDetallesMem.RecordCount = 0);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrContratoCliente.actAnadirDetalleUpdate(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
if not (Modo in [Anadir, Modificar]) then
|
|||
|
|
(Sender as TAction).Enabled := False
|
|||
|
|
else
|
|||
|
|
(Sender as TAction).Enabled := True;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
function TfrContratoCliente.ArticuloConPropiedades(
|
|||
|
|
NumConcepto: Integer): Boolean;
|
|||
|
|
begin
|
|||
|
|
Result := False;
|
|||
|
|
with TablaPropiedadesMem do
|
|||
|
|
begin
|
|||
|
|
DisableControls;
|
|||
|
|
try
|
|||
|
|
First;
|
|||
|
|
while not EOF do
|
|||
|
|
begin
|
|||
|
|
if FieldByName('NUMCONCEPTO').AsInteger = NumConcepto then
|
|||
|
|
begin
|
|||
|
|
Result := True;
|
|||
|
|
Break;
|
|||
|
|
end;
|
|||
|
|
Next;
|
|||
|
|
end;
|
|||
|
|
finally
|
|||
|
|
EnableControls;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrContratoCliente.TablaDetallesNewRecord(DataSet: TDataSet);
|
|||
|
|
begin
|
|||
|
|
//
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrContratoCliente.CargarDatosDocumento(CodigoDocumento : String);
|
|||
|
|
var
|
|||
|
|
DocAux : TDocumento;
|
|||
|
|
begin
|
|||
|
|
DocAux := TDocumento.Create(CodigoDocumento);
|
|||
|
|
Entidad := dmTablaDocumentos.DarEntidadDocumento(entContratoCliente, DocAux.Codigo);
|
|||
|
|
try
|
|||
|
|
Nota.EditingText := DocAux.Notas;
|
|||
|
|
TablaContratos.FieldByName('OBSERVACIONES').AsString := DocAux.Notas;
|
|||
|
|
FormasPago.EditingText := DocAux.FormaPago;
|
|||
|
|
TablaContratos.FieldByName('FORMAPAGO').AsString := DocAux.FormaPago;
|
|||
|
|
PlazosEntrega.EditingText := DocAux.PlazoEntrega;
|
|||
|
|
TablaContratos.FieldByName('PLAZOENTREGA').AsString := DocAux.PlazoEntrega;
|
|||
|
|
finally
|
|||
|
|
DocAux.Free;
|
|||
|
|
DocAux := NIL;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrContratoCliente.VALORGetProperties(
|
|||
|
|
Sender: TcxCustomGridTableItem; ARecord: TcxCustomGridRecord;
|
|||
|
|
var AProperties: TcxCustomEditProperties);
|
|||
|
|
begin
|
|||
|
|
if not ARecord.Focused then
|
|||
|
|
Exit
|
|||
|
|
else begin
|
|||
|
|
with TablaValores do
|
|||
|
|
begin
|
|||
|
|
try
|
|||
|
|
DisableControls;
|
|||
|
|
Close;
|
|||
|
|
// <20>Tiene 'copia'?
|
|||
|
|
if TablaPropiedades.FieldByName('COPIA').AsVariant <> NULL then
|
|||
|
|
ParamByName('CODIGOPROPIEDAD').AsInteger := TablaPropiedades.FieldByName('COPIA').AsInteger
|
|||
|
|
else // No tiene 'copia'
|
|||
|
|
ParamByName('CODIGOPROPIEDAD').AsInteger := TablaPropiedadesMem.FieldByName('CODIGOPROPIEDAD').AsInteger;
|
|||
|
|
Prepare;
|
|||
|
|
Open;
|
|||
|
|
|
|||
|
|
if RecordCount = 0 then
|
|||
|
|
AProperties := dmConfiguracion.cxEditRepository1TextItem1.Properties
|
|||
|
|
else begin
|
|||
|
|
AProperties := dmConfiguracion.cxEditRepository1LookupComboBoxItem1.Properties;
|
|||
|
|
with TcxLookupComboBoxProperties(AProperties) do
|
|||
|
|
begin
|
|||
|
|
DropDownListStyle := lsEditList;
|
|||
|
|
ImmediatePost := True;
|
|||
|
|
KeyFieldNames := 'DESCRIPCION';
|
|||
|
|
ListColumns.Clear;
|
|||
|
|
ListColumns.Add.FieldName := 'DESCRIPCION';
|
|||
|
|
ListOptions.AnsiSort := True;
|
|||
|
|
ListOptions.GridLines := glNone;
|
|||
|
|
ListOptions.ShowHeader := False;
|
|||
|
|
ListSource := dsValores;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
finally
|
|||
|
|
EnableControls;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrContratoCliente.ConfigurarPantallaDocumento;
|
|||
|
|
begin
|
|||
|
|
if (Entidad = entContratoCocina) then
|
|||
|
|
pagPlanos.TabVisible := True
|
|||
|
|
else
|
|||
|
|
pagPlanos.TabVisible := False;
|
|||
|
|
|
|||
|
|
case Entidad of
|
|||
|
|
entContratoCocina,
|
|||
|
|
entContratoBano,
|
|||
|
|
entContratoArmarios : begin
|
|||
|
|
pagPrecios.TabVisible := True;
|
|||
|
|
gridDetallesLevel1.GridView := VistaPropiedades;
|
|||
|
|
pnlObservaciones.Visible := True;
|
|||
|
|
if Modo in [Anadir, Modificar] then
|
|||
|
|
begin
|
|||
|
|
pnlBarraContenido.Visible := False;
|
|||
|
|
pnlBarraPropiedades.Visible := True;
|
|||
|
|
pnlBarraPrecio.Visible := True;
|
|||
|
|
Observaciones.Properties.ReadOnly := False;
|
|||
|
|
end
|
|||
|
|
else begin
|
|||
|
|
pnlBarraContenido.Visible := False;
|
|||
|
|
pnlBarraPropiedades.Visible := True;
|
|||
|
|
pnlBarraPrecio.Visible := False;
|
|||
|
|
Observaciones.Properties.ReadOnly := True;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
if Entidad = entContratoArmarios then
|
|||
|
|
begin
|
|||
|
|
eSeccion.Visible := True;
|
|||
|
|
Seccion.Visible := True;
|
|||
|
|
Seccion.ItemIndex := 0;
|
|||
|
|
end
|
|||
|
|
else begin
|
|||
|
|
eSeccion.Visible := False;
|
|||
|
|
Seccion.Visible := False;
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
else begin
|
|||
|
|
pagPrecios.TabVisible := False;
|
|||
|
|
gridDetallesLevel1.GridView := VistaDetalles;
|
|||
|
|
pnlObservaciones.Visible := False;
|
|||
|
|
if Modo in [Anadir, Modificar] then
|
|||
|
|
begin
|
|||
|
|
pnlBarraContenido.Visible := True;
|
|||
|
|
pnlBarraPropiedades.Visible := False;
|
|||
|
|
pnlBarraPrecio.Visible := False;
|
|||
|
|
end
|
|||
|
|
else begin
|
|||
|
|
pnlBarraContenido.Visible := False;
|
|||
|
|
pnlBarraPropiedades.Visible := False;
|
|||
|
|
pnlBarraPrecio.Visible := False;
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrContratoCliente.InsertarDetallesDefecto;
|
|||
|
|
begin
|
|||
|
|
case Entidad of
|
|||
|
|
entContratoCocina,
|
|||
|
|
entContratoBano :
|
|||
|
|
begin
|
|||
|
|
with TablaDetallesMem do
|
|||
|
|
begin
|
|||
|
|
Append;
|
|||
|
|
FieldByName('NUMCONCEPTO').AsInteger := 0;
|
|||
|
|
FieldByName('TIPOCONCEPTO').AsString := dmTablaDocumentos.DarCodigoDocumento(Entidad);
|
|||
|
|
FieldByName('CANTIDAD').AsInteger := 1;
|
|||
|
|
Post;
|
|||
|
|
InsertarPropiedades(FieldByName('NUMCONCEPTO').AsInteger);
|
|||
|
|
CargarPreciosDocumento(cbxDocumento.DataBinding.Field.AsString, 1);
|
|||
|
|
First;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
entContratoArmarios:
|
|||
|
|
begin
|
|||
|
|
with TablaDetallesMem do
|
|||
|
|
begin
|
|||
|
|
Append;
|
|||
|
|
FieldByName('NUMCONCEPTO').AsInteger := 0;
|
|||
|
|
FieldByName('TIPOCONCEPTO').AsString := 'FRENTE';
|
|||
|
|
FieldByName('CANTIDAD').AsInteger := 1;
|
|||
|
|
Post;
|
|||
|
|
InsertarPropiedades(FieldByName('NUMCONCEPTO').AsInteger, FieldByName('TIPOCONCEPTO').AsString);
|
|||
|
|
|
|||
|
|
Append;
|
|||
|
|
FieldByName('NUMCONCEPTO').AsInteger := 1;
|
|||
|
|
FieldByName('TIPOCONCEPTO').AsString := 'INTERIOR';
|
|||
|
|
FieldByName('CANTIDAD').AsInteger := 1;
|
|||
|
|
Post;
|
|||
|
|
InsertarPropiedades(FieldByName('NUMCONCEPTO').AsInteger, FieldByName('TIPOCONCEPTO').AsString);
|
|||
|
|
CargarPreciosDocumento(cbxDocumento.DataBinding.Field.AsString, 2);
|
|||
|
|
First;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrContratoCliente.CargarPreciosDocumento(
|
|||
|
|
CodigoDocumento: String; NumConcepto: Integer);
|
|||
|
|
var
|
|||
|
|
DocAux : TDocumento;
|
|||
|
|
Contador : Integer;
|
|||
|
|
begin
|
|||
|
|
DocAux := TDocumento.Create(CodigoDocumento);
|
|||
|
|
try
|
|||
|
|
with TablaDetallesMem do
|
|||
|
|
begin
|
|||
|
|
if State in dsEditModes then
|
|||
|
|
Cancel;
|
|||
|
|
for Contador := 0 to DocAux.ListaPrecios.Count-1 do
|
|||
|
|
begin
|
|||
|
|
Append;
|
|||
|
|
FieldByName('NUMCONCEPTO').AsInteger := NumConcepto + Contador;
|
|||
|
|
FieldByName('TIPOCONCEPTO').AsString := 'PRECIO';
|
|||
|
|
FieldByName('DESCRIPCION').AsString := DocAux.ListaPrecios.Strings[Contador];
|
|||
|
|
FieldByName('CANTIDAD').AsInteger := 1;
|
|||
|
|
Post;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
finally
|
|||
|
|
DocAux.Free;
|
|||
|
|
DocAux := NIL;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrContratoCliente.TablaMemDetallesFilterRecord(DataSet: TDataSet;
|
|||
|
|
var Accept: Boolean);
|
|||
|
|
begin
|
|||
|
|
Accept := (DataSet.FieldByName('TIPOCONCEPTO').AsString = 'PRECIO');
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrContratoCliente.actAnadirPropiedadExecute(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
with TablaPropiedadesMem do
|
|||
|
|
begin
|
|||
|
|
Next;
|
|||
|
|
if EOF then
|
|||
|
|
Append
|
|||
|
|
else begin
|
|||
|
|
Prior;
|
|||
|
|
Insert;
|
|||
|
|
end;
|
|||
|
|
gridDetalles.SetFocus;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrContratoCliente.actAnadirPropiedadUpdate(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
(Sender as TAction).Enabled := (Modo in [Anadir, Modificar]);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrContratoCliente.actEliminarPropiedadExecute(
|
|||
|
|
Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
if TablaPropiedadesMem.RecordCount = 0 then begin
|
|||
|
|
{ Hacemos un cancel de la tabla por si el registro actual estuviera
|
|||
|
|
recien creado }
|
|||
|
|
TablaPropiedadesMem.Cancel;
|
|||
|
|
Exit;
|
|||
|
|
end;
|
|||
|
|
if (VerMensajePregunta(msgDatosBorrarPropiedad) <> IDYES) then
|
|||
|
|
Exit;
|
|||
|
|
TablaPropiedadesMem.Delete;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrContratoCliente.actEliminarPropiedadUpdate(
|
|||
|
|
Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
(Sender as TAction).Enabled := (Modo in [Anadir, Modificar]);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrContratoCliente.AsignarNumPropiedad;
|
|||
|
|
var
|
|||
|
|
FDetallesBookmark : string;
|
|||
|
|
Contador : Integer;
|
|||
|
|
begin
|
|||
|
|
with TablaPropiedadesMem do
|
|||
|
|
begin
|
|||
|
|
DisableControls;
|
|||
|
|
FDetallesBookmark := Bookmark;
|
|||
|
|
try
|
|||
|
|
Contador := 0;
|
|||
|
|
First;
|
|||
|
|
while not EOF do
|
|||
|
|
begin
|
|||
|
|
Edit;
|
|||
|
|
FieldByName('NUMPROPIEDAD').AsInteger := Contador;
|
|||
|
|
Post;
|
|||
|
|
Contador := Contador + 1;
|
|||
|
|
Next;
|
|||
|
|
end;
|
|||
|
|
finally
|
|||
|
|
//FUltimaPropiedad := Contador - 1;
|
|||
|
|
EnableControls;
|
|||
|
|
Bookmark := FDetallesBookmark;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrContratoCliente.PropiedadesAfterDelete(DataSet: TDataSet);
|
|||
|
|
begin
|
|||
|
|
AsignarNumPropiedad;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrContratoCliente.actSubirExecute(Sender: TObject);
|
|||
|
|
var
|
|||
|
|
NumPropiedad : Integer;
|
|||
|
|
begin
|
|||
|
|
NumPropiedad := TablaPropiedadesMem.FieldByName('NUMPROPIEDAD').AsInteger;
|
|||
|
|
IntercambiarPropiedades(@TablaPropiedadesMem, NumPropiedad, NumPropiedad - 1);
|
|||
|
|
VistaPropiedades.DataController.RefreshExternalData;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrContratoCliente.actSubirUpdate(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
with TablaPropiedadesMem do
|
|||
|
|
(Sender as TAction).Enabled := (Modo in [Anadir, Modificar]) and
|
|||
|
|
(FieldByName('NUMPROPIEDAD').AsInteger > 0);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrContratoCliente.actBajarExecute(Sender: TObject);
|
|||
|
|
var
|
|||
|
|
NumPropiedad : Integer;
|
|||
|
|
begin
|
|||
|
|
NumPropiedad := TablaPropiedadesMem.FieldByName('NUMPROPIEDAD').AsInteger;
|
|||
|
|
IntercambiarPropiedades(@TablaPropiedadesMem, NumPropiedad, NumPropiedad + 1);
|
|||
|
|
VistaPropiedades.DataController.RefreshExternalData;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrContratoCliente.actBajarUpdate(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
with TablaPropiedadesMem do
|
|||
|
|
(Sender as TAction).Enabled := (Modo in [Anadir, Modificar]) and
|
|||
|
|
(FieldByName('NUMPROPIEDAD').AsInteger < (VistaPropiedades.ViewData.CardCount - 1));
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrContratoCliente.gridDetallesResize(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
if gridDetalles.ActiveView = VistaPropiedades then
|
|||
|
|
VistaPropiedades.OptionsView.CardWidth := (gridDetalles.Width - 40) div 2;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrContratoCliente.pnlPreciosResize(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
with gridPrecios do
|
|||
|
|
begin
|
|||
|
|
RowCount := pnlGrid.Height div 18;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrContratoCliente.TablaMemPropiedadesFilterRecord(
|
|||
|
|
DataSet: TDataSet; var Accept: Boolean);
|
|||
|
|
begin
|
|||
|
|
Accept := (DataSet.FieldByName('NUMCONCEPTO').AsInteger = Seccion.ItemIndex);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrContratoCliente.SeccionPropertiesChange(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
if TablaPropiedadesMem.Active then
|
|||
|
|
TablaPropiedadesMem.First;
|
|||
|
|
|
|||
|
|
Observaciones.Lines.Clear;
|
|||
|
|
case Seccion.ItemIndex of
|
|||
|
|
0 : Observaciones.Lines.Text := FObservaciones1;
|
|||
|
|
1 : Observaciones.Lines.Text := FObservaciones2;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrContratoCliente.ObservacionesExit(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
case Seccion.ItemIndex of
|
|||
|
|
0 : FObservaciones1 := Observaciones.Lines.Text;
|
|||
|
|
1 : FObservaciones2 := Observaciones.Lines.Text;
|
|||
|
|
else
|
|||
|
|
FObservaciones1 := Observaciones.Lines.Text;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrContratoCliente.VistaPropiedadesDBCardViewRow3CustomDrawCell(
|
|||
|
|
Sender: TcxCustomGridTableView; ACanvas: TcxCanvas;
|
|||
|
|
AViewInfo: TcxGridTableDataCellViewInfo; var ADone: Boolean);
|
|||
|
|
begin
|
|||
|
|
if Length(AViewInfo.DisplayValue) > 32 then
|
|||
|
|
ACanvas.Font.Color := clRed;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrContratoCliente.pagNotasVariasResize(Sender: TObject);
|
|||
|
|
var
|
|||
|
|
Aux : Integer;
|
|||
|
|
begin
|
|||
|
|
Aux := pagNotasVarias.Height div 3;
|
|||
|
|
pnlFormasPago.Height := Aux;
|
|||
|
|
pnlPlazosEntrega.Height := Aux;
|
|||
|
|
pnlNota.Height := Aux;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrContratoCliente.actAnadirPlanoExecute(Sender: TObject);
|
|||
|
|
var
|
|||
|
|
FicheroOrigen : String;
|
|||
|
|
i : Integer;
|
|||
|
|
begin
|
|||
|
|
OpenDialog1.Filter := tvPlanos.Filter;
|
|||
|
|
try
|
|||
|
|
if OpenDialog1.Execute then
|
|||
|
|
begin
|
|||
|
|
for i:=0 to OpenDialog1.Files.Count - 1 do
|
|||
|
|
begin
|
|||
|
|
FicheroOrigen := OpenDialog1.Files.Strings[i];
|
|||
|
|
if not esCadenaVacia(FicheroOrigen) then
|
|||
|
|
begin
|
|||
|
|
if not AnadirPlano(FicheroOrigen) then
|
|||
|
|
VerMensaje(msgCliPreErrAnadirDoc);
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
finally
|
|||
|
|
OpenDialog1.Filter := '';
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrContratoCliente.actEliminarPlanoExecute(Sender: TObject);
|
|||
|
|
var
|
|||
|
|
cadena : String;
|
|||
|
|
i : Integer;
|
|||
|
|
begin
|
|||
|
|
cadena := '<27>Desea borrar este plano?';
|
|||
|
|
|
|||
|
|
if (VerMensajePregunta(cadena) <> IDYES) then
|
|||
|
|
Exit;
|
|||
|
|
|
|||
|
|
if not SysUtils.DeleteFile(tvPlanos.SelectedFile) then
|
|||
|
|
VerMensaje(msgCliPreErrEliminarDoc);
|
|||
|
|
tvPlanos.Delete(tvPlanos.Selected);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrContratoCliente.actEliminarPlanoUpdate(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
(Sender as TAction).Enabled := (Modo in [Anadir, Modificar]) and
|
|||
|
|
(Length(tvPlanos.SelectedFile) > 0);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrContratoCliente.actRefrescarPlanoExecute(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
tvPlanos.Refresh;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
function TfrContratoCliente.AnadirPlano(RutaPlano: String): Boolean;
|
|||
|
|
var
|
|||
|
|
DireccionDestino: String;
|
|||
|
|
begin
|
|||
|
|
try
|
|||
|
|
Result := False;
|
|||
|
|
DireccionDestino := darRutaPlanosContrato + PathDelim + ExtractFileName(RutaPlano);
|
|||
|
|
CopiarFichero(RutaPlano, DireccionDestino);
|
|||
|
|
tvPlanos.AddFromFile(DireccionDestino);
|
|||
|
|
Result := True;
|
|||
|
|
finally
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
function TfrContratoCliente.darRutaPlanosContrato: Variant;
|
|||
|
|
begin
|
|||
|
|
if (Modo = Anadir) then
|
|||
|
|
begin
|
|||
|
|
if (Length(FDirectorio) = 0) then
|
|||
|
|
FDirectorio := '\' + ExtractFileName(darFicheroTemporal)
|
|||
|
|
end
|
|||
|
|
else
|
|||
|
|
FDirectorio := dmTablaContratos.DarRutaPlanos(CodigoContrato);
|
|||
|
|
Result := FRootPlanos + FDirectorio;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrContratoCliente.ComprobarEstadoDirPlanos;
|
|||
|
|
var
|
|||
|
|
RutaTemp, RutaFinal: String;
|
|||
|
|
begin
|
|||
|
|
if Entidad = entContratoCocina then
|
|||
|
|
begin
|
|||
|
|
DeshabilitarPlanos;
|
|||
|
|
Application.ProcessMessages;
|
|||
|
|
if Modo = Anadir then
|
|||
|
|
begin
|
|||
|
|
//Intentamos renombrar el directorio temporal por el real (si existiera)
|
|||
|
|
RutaTemp := darRutaPlanosContrato;
|
|||
|
|
FDirectorio := PathDelim + StringReplace(CodigoContrato,'/','',[rfReplaceAll]);
|
|||
|
|
RutaFinal:= darRutaPlanosContrato;
|
|||
|
|
RenameFile(RutaTemp, RutaFinal);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
{ Intentamos borrar el directorio de los documentos. Si est<EFBFBD> vacio se
|
|||
|
|
borrar y si no se queda }
|
|||
|
|
RemoveDir(darRutaPlanosContrato);
|
|||
|
|
Application.ProcessMessages;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
function TfrContratoCliente.CrearDirPlanos: Boolean;
|
|||
|
|
var
|
|||
|
|
DireccionDestino: String;
|
|||
|
|
begin
|
|||
|
|
Result := False;
|
|||
|
|
DeshabilitarPlanos;
|
|||
|
|
DireccionDestino := darRutaPlanosContrato;
|
|||
|
|
if not DirectoryExists(DireccionDestino) then
|
|||
|
|
CreateDir(DireccionDestino);
|
|||
|
|
HabilitarPlanos;
|
|||
|
|
Result := True;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrContratoCliente.DeshabilitarPlanos;
|
|||
|
|
begin
|
|||
|
|
//
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
function TfrContratoCliente.EliminarDirPlanos: Boolean;
|
|||
|
|
begin
|
|||
|
|
Result := False;
|
|||
|
|
DeshabilitarPlanos;
|
|||
|
|
Application.ProcessMessages;
|
|||
|
|
if DirectoryExists(darRutaPlanosContrato) then
|
|||
|
|
begin
|
|||
|
|
SysFunc.Deltree(darRutaPlanosContrato, True);
|
|||
|
|
Application.ProcessMessages;
|
|||
|
|
Result := DirectoryExists(darRutaPlanosContrato);
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrContratoCliente.HabilitarPlanos;
|
|||
|
|
begin
|
|||
|
|
tvPlanos.Directory := darRutaPlanosContrato;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrContratoCliente.actAnadirPlanoUpdate(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
(Sender as TAction).Enabled := (Modo in [Anadir, Modificar]);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrContratoCliente.tvPlanosDblClick(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
if ShellExecute(Handle, nil, pchar(tvPlanos.SelectedFile),
|
|||
|
|
nil, nil, SW_SHOWNORMAL) <= 32 then
|
|||
|
|
Application.MessageBox('No se pudo visualizar el fichero',
|
|||
|
|
'Error', MB_ICONEXCLAMATION);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrContratoCliente.JvTrackBar1Change(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
tvPlanos.Size := JvTrackBar1.Position;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrContratoCliente.ReferenciaArticuloDetalleSetText(
|
|||
|
|
Sender: TField; const Text: String);
|
|||
|
|
var
|
|||
|
|
ReferenciaAux : String;
|
|||
|
|
CodigoArtAux : String;
|
|||
|
|
begin
|
|||
|
|
Sender.AsString := Text;
|
|||
|
|
ReferenciaAux := Text;
|
|||
|
|
|
|||
|
|
if (dmTablaArticulos.DarCodigoArt(ReferenciaAux, CodigoArtAux)) then
|
|||
|
|
CodigoArticulo := CodigoArtAux
|
|||
|
|
else begin
|
|||
|
|
raise Exception.CreateFmt(msgDatosRefArtNoExiste, [ReferenciaAux]);
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrContratoCliente.GridBotonReferenciaArticuloClick(
|
|||
|
|
Sender: TObject; AButtonIndex: Integer);
|
|||
|
|
begin
|
|||
|
|
TablaDetallesMem.Edit;
|
|||
|
|
ContenidoModal := TfrArticulos.Create(Self);
|
|||
|
|
gridDetalles.SetFocus;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
end.
|
|||
|
|
|