1070 lines
34 KiB
C#
1070 lines
34 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using static bdGrupoSanchoToro.tscGrupoSanchoToro;
|
|
using static bdGrupoSanchoToro.db.productos;
|
|
using Microsoft.VisualBasic.CompilerServices;
|
|
using static tsUtilidades.Extensiones.StringExtensions;
|
|
using System.Collections.Specialized;
|
|
using System.ComponentModel;
|
|
using System.Runtime.CompilerServices;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using System.ComponentModel.DataAnnotations;
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
|
|
|
namespace bdGrupoSanchoToro.db
|
|
{
|
|
|
|
[NotMapped]
|
|
public partial class presupuestos:INotifyPropertyChanged
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
[NotMapped]
|
|
public virtual List<detallepresupuesto> DetalleHijos
|
|
{
|
|
get
|
|
{
|
|
return detallepresupuesto.Where(x=> !x.idDetallePresupuestoPadre.HasValue).ToList();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public obras? Obras
|
|
{
|
|
get
|
|
{
|
|
return this.idObraNavigation;
|
|
}
|
|
}
|
|
|
|
[NotMapped]
|
|
public virtual List<DetalleProductoFinal> DetalleProductosFinales
|
|
{
|
|
get
|
|
{
|
|
var dpf = this.detallepresupuesto.Where(x => x.productos.Tipo == (int)TipoProductoEnum.ELEMENTO_GRUA || x.productos.Tipo <= (int)TipoProductoEnum.OTROS_PRODUCTOS).ToList();
|
|
var ld = new List<DetalleProductoFinal>();
|
|
foreach (var d in dpf)
|
|
this.AñadeProductoFinal(d, ld);
|
|
return ld;
|
|
}
|
|
}
|
|
|
|
[NotMapped]
|
|
public virtual List<DetalleProductoFinal> DetalleServicios
|
|
{
|
|
get
|
|
{
|
|
var dpf = this.detallepresupuesto.Where(x => x.productos.Tipo >= (int)TipoProductoEnum.SERVICIO).ToList();
|
|
|
|
var ld = new List<DetalleProductoFinal>();
|
|
foreach (var d in dpf)
|
|
this.AñadeProductoFinal(d, ld);
|
|
return ld;
|
|
}
|
|
}
|
|
// Private Sub AñadeProductoFinales(d As detallepresupuesto, ld As List(Of DetalleProductoFinal))
|
|
// Dim dp = ld.FirstOrDefault(Function(x) x.idProducto = d.idProducto)
|
|
// If dp Is Nothing Then
|
|
// dp = New DetalleProductoFinal
|
|
// dp.idProducto = d.idProducto
|
|
// dp.Cantidad = d.Cantidad
|
|
// dp.Importe = d.Importe
|
|
// dp.Descripcion = d.productos.Descripcion
|
|
// ld.Add(dp)
|
|
// Else
|
|
// dp.Cantidad += d.Cantidad
|
|
// dp.Importe += d.Importe
|
|
// End If
|
|
// End Sub
|
|
|
|
private void AñadeProductoFinal(detallepresupuesto d, List<DetalleProductoFinal> ld)
|
|
{
|
|
var dp = ld.FirstOrDefault(x => x.idProducto == d.idProductoNavigation.idProducto);
|
|
if (dp is null)
|
|
{
|
|
dp = new DetalleProductoFinal();
|
|
dp.idProducto = d.idProductoNavigation.idProducto;
|
|
dp.Tipo = d.idProductoNavigation.DescripcionTipo;
|
|
dp.Cantidad = (int)Math.Round(d.Cantidad);
|
|
dp.Descripcion = d.productos.Descripcion;
|
|
if (d.productos.Tipo != (int)TipoProductoEnum.HERRAMIENTAS)
|
|
{
|
|
var padre = d.idDetallePresupuestoPadreNavigation;
|
|
while (!(padre is null))
|
|
{
|
|
dp.Cantidad = (int)Math.Round((double)dp.Cantidad * padre.Cantidad);
|
|
dp.Importe = dp.Importe * padre.Cantidad;
|
|
padre = padre.idDetallePresupuestoPadreNavigation;
|
|
}
|
|
}
|
|
ld.Add(dp);
|
|
}
|
|
else if (d.idProductoNavigation.Tipo != (int)TipoProductoEnum.HERRAMIENTAS)
|
|
{
|
|
double cant = d.Cantidad;
|
|
double imp = 0; // d.ImporteGastos;
|
|
var padre = d.idDetallePresupuestoPadreNavigation;
|
|
while (!(padre is null))
|
|
{
|
|
cant = cant * padre.Cantidad;
|
|
imp = imp * padre.Cantidad;
|
|
padre = padre.idDetallePresupuestoPadreNavigation;
|
|
}
|
|
dp.Cantidad = (int)Math.Round(dp.Cantidad + cant);
|
|
dp.Importe += imp;
|
|
}
|
|
else
|
|
{
|
|
dp.Cantidad = (int)Math.Round(Math.Max((double)dp.Cantidad, d.Cantidad));
|
|
}
|
|
}
|
|
|
|
|
|
[NotMapped]
|
|
public virtual string DescripcionTipo
|
|
{
|
|
get
|
|
{
|
|
if (this.idPresupuesto == 0)
|
|
{
|
|
return "";
|
|
}
|
|
else if (this.FechaAceptacion.HasValue)
|
|
{
|
|
return "CONTRATO";
|
|
}
|
|
else
|
|
{
|
|
return "PRESUPUESTO";
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
[NotMapped]
|
|
public virtual string NumeroPresupuesto
|
|
{
|
|
get
|
|
{
|
|
if (this.idPresupuesto == 0)
|
|
{
|
|
return "";
|
|
}
|
|
else if (this.FechaAceptacion.HasValue)
|
|
{
|
|
return "CT" + (this.FechaPresupuesto.Year % 100).ToString() + "-" + this.idPresupuesto.ToString().PadLeft(6, '0');
|
|
}
|
|
else
|
|
{
|
|
return "PR" + (this.FechaPresupuesto.Year % 100).ToString() + "-" + this.idPresupuesto.ToString().PadLeft(6, '0');
|
|
}
|
|
}
|
|
}
|
|
|
|
[NotMapped]
|
|
public virtual List<facturas> FacturasEmitidas
|
|
{
|
|
get
|
|
{
|
|
var df = this.detallepresupuesto.SelectMany(x => x.detallesfacturas).GroupBy(x => x.idFactura);
|
|
return df.Select(x => x.FirstOrDefault().idFacturaNavigation).ToList();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
public void RefrescaCamposTemporales()
|
|
{
|
|
this.OnPropertyChanged("DiasAlquiler");
|
|
this.OnPropertyChanged("BaseImponible");
|
|
this.OnPropertyChanged("NumeroPresupuesto");
|
|
this.OnPropertyChanged("DetalleProductosFinales");
|
|
this.OnPropertyChanged("DetalleServicios");
|
|
}
|
|
|
|
|
|
protected void OnPropertyChanged([CallerMemberName] string name = null)
|
|
{
|
|
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
|
|
}
|
|
|
|
#region Cliente
|
|
|
|
private int? _TipoImpresionAlbaranEntregaTmp;
|
|
[NotMapped]
|
|
public virtual int? TipoImpresionAlbaranEntregaTmp
|
|
{
|
|
get
|
|
{
|
|
if (_TipoImpresionAlbaranEntregaTmp.HasValue == false)
|
|
{
|
|
if (this.idClienteNavigation is not null)
|
|
{
|
|
int rs;
|
|
rs = this.idClienteNavigation.TipoImpresionAlbaranEntrega;
|
|
_TipoImpresionAlbaranEntregaTmp = rs;
|
|
return rs;
|
|
}
|
|
else
|
|
{
|
|
return Conversions.ToInteger(false);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
return _TipoImpresionAlbaranEntregaTmp;
|
|
}
|
|
}
|
|
set
|
|
{
|
|
_TipoImpresionAlbaranEntregaTmp = value;
|
|
if (this.idClienteNavigation is not null && value.HasValue)
|
|
{
|
|
this.idClienteNavigation.TipoImpresionAlbaranEntrega = (int)value;
|
|
}
|
|
this.OnPropertyChanged("TipoImpresionAlbaranEntregaTmp");
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private bool _NIFClienteTmpEsNulo = true;
|
|
private string _NIFClienteTmp;
|
|
[NotMapped]
|
|
public string NIFClienteTmp
|
|
{
|
|
get
|
|
{
|
|
if (_NIFClienteTmpEsNulo)
|
|
{
|
|
if (this.idClienteNavigation is null)
|
|
{
|
|
return "";
|
|
}
|
|
else
|
|
{
|
|
_NIFClienteTmp = this.idClienteNavigation.NIF;
|
|
_NIFClienteTmpEsNulo = false;
|
|
return this.idClienteNavigation.NIF;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
return _NIFClienteTmp;
|
|
}
|
|
// If Me.entidades Is Nothing Then
|
|
// If _NIFClienteTmpEsNulo Then
|
|
// Return ""
|
|
// Else
|
|
// Return _NIFClienteTmp
|
|
// End If
|
|
// Else
|
|
// Return Me.entidades.NIF
|
|
// End If
|
|
}
|
|
set
|
|
{
|
|
_NIFClienteTmp = value;
|
|
_NIFClienteTmpEsNulo = false;
|
|
if (this.idClienteNavigation is not null)
|
|
{
|
|
if (string.IsNullOrEmpty(value.NothingAVacio()))
|
|
{
|
|
this.idClienteNavigation.NIF = (string)null;
|
|
}
|
|
else
|
|
{
|
|
this.idClienteNavigation.NIF = value;
|
|
}
|
|
RefrescaCamposSoloLectura();
|
|
}
|
|
}
|
|
}
|
|
public void RefrescaCamposSoloLectura()
|
|
{
|
|
|
|
this.OnPropertyChanged("NIFClienteTmp");
|
|
this.OnPropertyChanged("RazonSocialClienteTmp");
|
|
this.OnPropertyChanged("CodigoPostalClienteTmp");
|
|
this.OnPropertyChanged("DomicilioClienteTmp");
|
|
this.OnPropertyChanged("CodigoPoblacionClienteTmp");
|
|
this.OnPropertyChanged("PoblacionClienteTmp");
|
|
this.OnPropertyChanged("ProvinciaClienteTmp");
|
|
this.OnPropertyChanged("TelefonoCliente1Tmp");
|
|
this.OnPropertyChanged("TelefonoCliente2Tmp");
|
|
this.OnPropertyChanged("EmailClienteTmp");
|
|
this.OnPropertyChanged("TipoImpresionAlbaranEntregaTmp");
|
|
this.OnPropertyChanged("Advertencias");
|
|
this.OnPropertyChanged("PendientePago");
|
|
this.OnPropertyChanged("NumeroPresupuesto");
|
|
|
|
}
|
|
|
|
private bool _RazonSocialClienteTmpEsNulo = true;
|
|
private string _RazonSocialClienteTmp;
|
|
[NotMapped]
|
|
public virtual string RazonSocialClienteTmp
|
|
{
|
|
get
|
|
{
|
|
if (_RazonSocialClienteTmpEsNulo)
|
|
{
|
|
if (this.idClienteNavigation is not null)
|
|
{
|
|
string rs;
|
|
rs = this.idClienteNavigation.RazonSocial;
|
|
_RazonSocialClienteTmpEsNulo = false;
|
|
_RazonSocialClienteTmp = rs;
|
|
return rs;
|
|
}
|
|
else
|
|
{
|
|
return "";
|
|
}
|
|
}
|
|
|
|
else
|
|
{
|
|
return _RazonSocialClienteTmp;
|
|
}
|
|
}
|
|
set
|
|
{
|
|
_RazonSocialClienteTmp = value;
|
|
_RazonSocialClienteTmpEsNulo = false;
|
|
if (this.idClienteNavigation is not null)
|
|
{
|
|
this.idClienteNavigation.RazonSocial = value;
|
|
}
|
|
this.OnPropertyChanged("RazonSocialClienteTmp");
|
|
}
|
|
}
|
|
private bool _CodigoPostalClienteTmpEsNulo = true;
|
|
private string _CodigoPostalClienteTmp;
|
|
[NotMapped]
|
|
public virtual string CodigoPostalClienteTmp
|
|
{
|
|
get
|
|
{
|
|
if (_CodigoPostalClienteTmpEsNulo)
|
|
{
|
|
if (this.idClienteNavigation is not null)
|
|
{
|
|
_CodigoPostalClienteTmp = this.idClienteNavigation.CodigoPostal;
|
|
_CodigoPostalClienteTmpEsNulo = false;
|
|
return this.idClienteNavigation.CodigoPostal;
|
|
}
|
|
else
|
|
{
|
|
return "";
|
|
}
|
|
}
|
|
else
|
|
{
|
|
return _CodigoPostalClienteTmp;
|
|
}
|
|
|
|
}
|
|
set
|
|
{
|
|
_CodigoPostalClienteTmp = value;
|
|
_CodigoPostalClienteTmpEsNulo = false;
|
|
if (this.idClienteNavigation is not null)
|
|
{
|
|
this.idClienteNavigation.CodigoPostal = value;
|
|
}
|
|
this.OnPropertyChanged("CodigoPostalClienteTmp");
|
|
}
|
|
}
|
|
|
|
private bool _DomicilioClienteTmpEsNulo = true;
|
|
private string _DomicilioClienteTmp;
|
|
[NotMapped]
|
|
public virtual string DomicilioClienteTmp
|
|
{
|
|
get
|
|
{
|
|
if (_DomicilioClienteTmpEsNulo)
|
|
{
|
|
if (this.idClienteNavigation is not null)
|
|
{
|
|
_DomicilioClienteTmp = this.idClienteNavigation.Direccion.NothingAVacio();
|
|
_DomicilioClienteTmpEsNulo = false;
|
|
return this.idClienteNavigation.Direccion;
|
|
}
|
|
else
|
|
{
|
|
return "";
|
|
}
|
|
}
|
|
else
|
|
{
|
|
return _DomicilioClienteTmp;
|
|
}
|
|
}
|
|
set
|
|
{
|
|
_DomicilioClienteTmp = value;
|
|
_DomicilioClienteTmpEsNulo = false;
|
|
if (this.idClienteNavigation is not null)
|
|
{
|
|
this.idClienteNavigation.Direccion = value;
|
|
}
|
|
this.OnPropertyChanged("DomicilioClienteTmp");
|
|
}
|
|
}
|
|
|
|
|
|
private bool _CodigoPoblacionClienteTmpEsNulo = true;
|
|
private string _CodigoPoblacionClienteTmp;
|
|
|
|
[NotMapped]
|
|
public virtual string CodigoPoblacionClienteTmp
|
|
{
|
|
get
|
|
{
|
|
if (_CodigoPoblacionClienteTmpEsNulo)
|
|
{
|
|
if (this.idClienteNavigation is null)
|
|
{
|
|
if (this.idClienteNavigation is not null && this.idClienteNavigation.CodigoMunicipioNavigation is null)
|
|
{
|
|
if (!string.IsNullOrEmpty(this.idClienteNavigation.CodigoPostal.NothingAVacio()))
|
|
{
|
|
tscGrupoSanchoToro bd = tscGrupoSanchoToro.NuevoContexto();
|
|
var pob = bd.codigospostales.First(x => (x.CodigoPostal ?? "") == (this.idClienteNavigation.CodigoPostal ?? ""));
|
|
this.idClienteNavigation.CodigoMunicipio = pob.CodigoMunicipio;
|
|
_CodigoPoblacionClienteTmp = pob.CodigoMunicipio;
|
|
_CodigoPoblacionClienteTmpEsNulo = false;
|
|
return _CodigoPoblacionClienteTmp;
|
|
}
|
|
else
|
|
{
|
|
return "";
|
|
}
|
|
}
|
|
else
|
|
{
|
|
return "";
|
|
}
|
|
}
|
|
|
|
else
|
|
{
|
|
_CodigoPoblacionClienteTmp = this.idClienteNavigation.CodigoMunicipio;
|
|
_CodigoPoblacionClienteTmpEsNulo = false;
|
|
return this.idClienteNavigation.CodigoMunicipio;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
return _CodigoPoblacionClienteTmp;
|
|
}
|
|
|
|
}
|
|
set
|
|
{
|
|
_CodigoPoblacionClienteTmp = value;
|
|
_CodigoPoblacionClienteTmpEsNulo = false;
|
|
if (this.idClienteNavigation is not null)
|
|
{
|
|
this.idClienteNavigation.CodigoMunicipio = value;
|
|
}
|
|
this.OnPropertyChanged("CodigoPoblacionClienteTmp");
|
|
this.OnPropertyChanged("PoblacionClienteTmp");
|
|
this.OnPropertyChanged("ProvinciaClienteTmp");
|
|
}
|
|
}
|
|
[NotMapped]
|
|
public string Advertencias
|
|
{
|
|
get
|
|
{
|
|
string sAdvertencias = "";
|
|
if (this.idClienteNavigation is not null)
|
|
{
|
|
foreach (var ad in this.idClienteNavigation.expedientesentidades.Where(x => x.EsAdvertencia).ToList())
|
|
sAdvertencias += " -- " + ad.Descripcion;
|
|
if (!string.IsNullOrEmpty(sAdvertencias))
|
|
sAdvertencias = sAdvertencias.Substring(4);
|
|
}
|
|
return sAdvertencias;
|
|
}
|
|
}
|
|
|
|
[NotMapped]
|
|
public string PoblacionClienteTmp
|
|
{
|
|
get
|
|
{
|
|
return Conversions.ToString(municipios.ObtienePoblacion(CodigoPoblacionClienteTmp));
|
|
}
|
|
}
|
|
|
|
[NotMapped]
|
|
public string ProvinciaClienteTmp
|
|
{
|
|
get
|
|
{
|
|
return Conversions.ToString(municipios.ObtieneProvincia(CodigoPoblacionClienteTmp));
|
|
}
|
|
}
|
|
|
|
private bool _TelefonoCliente1TmpEsNulo = true;
|
|
private string _TelefonoCliente1Tmp;
|
|
[NotMapped]
|
|
public virtual string TelefonoCliente1Tmp
|
|
{
|
|
get
|
|
{
|
|
if (_TelefonoCliente1TmpEsNulo)
|
|
{
|
|
if (this.idClienteNavigation is not null)
|
|
{
|
|
_TelefonoCliente1Tmp = this.idClienteNavigation.Telefono1;
|
|
_TelefonoCliente1TmpEsNulo = false;
|
|
return this.idClienteNavigation.Telefono1;
|
|
}
|
|
else
|
|
{
|
|
return "";
|
|
}
|
|
}
|
|
else
|
|
{
|
|
return _TelefonoCliente1Tmp;
|
|
}
|
|
}
|
|
set
|
|
{
|
|
_TelefonoCliente1Tmp = value;
|
|
_TelefonoCliente1TmpEsNulo = false;
|
|
if (this.idClienteNavigation is not null)
|
|
{
|
|
this.idClienteNavigation.Telefono1 = value;
|
|
}
|
|
this.OnPropertyChanged("TelefonoCliente1Tmp");
|
|
}
|
|
}
|
|
|
|
private bool _TelefonoCliente2TmpEsNulo = true;
|
|
private string _TelefonoCliente2Tmp;
|
|
[NotMapped]
|
|
public virtual string TelefonoCliente2Tmp
|
|
{
|
|
get
|
|
{
|
|
if (_TelefonoCliente2TmpEsNulo)
|
|
{
|
|
if (this.idClienteNavigation is not null)
|
|
{
|
|
_TelefonoCliente2Tmp = this.idClienteNavigation.Telefono2;
|
|
_TelefonoCliente2TmpEsNulo = false;
|
|
return this.idClienteNavigation
|
|
.Telefono2;
|
|
}
|
|
else
|
|
{
|
|
return "";
|
|
}
|
|
}
|
|
else
|
|
{
|
|
return _TelefonoCliente2Tmp;
|
|
}
|
|
}
|
|
set
|
|
{
|
|
_TelefonoCliente2Tmp = value;
|
|
_TelefonoCliente2TmpEsNulo = false;
|
|
if (this.idClienteNavigation is not null)
|
|
{
|
|
this.idClienteNavigation.Telefono2 = value;
|
|
}
|
|
this.OnPropertyChanged("TelefonoCliente2Tmp");
|
|
}
|
|
}
|
|
private bool _EmailClienteTmpEsNulo = true;
|
|
private string _EmailClienteTmp;
|
|
|
|
|
|
[NotMapped]
|
|
public virtual string EmailClienteTmp
|
|
{
|
|
get
|
|
{
|
|
if (_EmailClienteTmpEsNulo)
|
|
{
|
|
if (this.idClienteNavigation is null)
|
|
{
|
|
return "";
|
|
}
|
|
else
|
|
{
|
|
_EmailClienteTmp = this.idClienteNavigation.Email;
|
|
_EmailClienteTmpEsNulo = false;
|
|
return this.idClienteNavigation.Email;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
return _EmailClienteTmp;
|
|
}
|
|
}
|
|
set
|
|
{
|
|
_EmailClienteTmp = value;
|
|
_EmailClienteTmpEsNulo = false;
|
|
if (this.idClienteNavigation is not null)
|
|
{
|
|
this.idClienteNavigation.Email = value;
|
|
}
|
|
this.OnPropertyChanged("EmailClienteTmp");
|
|
}
|
|
}
|
|
public void ReiniciaValoresTMPCliente()
|
|
{
|
|
_NIFClienteTmpEsNulo = true;
|
|
_RazonSocialClienteTmpEsNulo = true;
|
|
_CodigoPoblacionClienteTmpEsNulo = true;
|
|
_CodigoPostalClienteTmpEsNulo = true;
|
|
_DomicilioClienteTmpEsNulo = true;
|
|
_TelefonoCliente1TmpEsNulo = true;
|
|
_TelefonoCliente2TmpEsNulo = true;
|
|
_EmailClienteTmpEsNulo = true;
|
|
_TipoImpresionAlbaranEntregaTmp = default;
|
|
}
|
|
|
|
#endregion
|
|
#region Obras
|
|
|
|
private bool _DescripcionObraTmpEsNulo = true;
|
|
private string _DescripcionObraTmp;
|
|
|
|
[NotMapped]
|
|
public virtual string DescripcionObraTmp
|
|
{
|
|
get
|
|
{
|
|
if (_DescripcionObraTmpEsNulo)
|
|
{
|
|
if (this.Obras is not null)
|
|
{
|
|
_DescripcionObraTmp = this.Obras.Descripcion;
|
|
_DescripcionObraTmpEsNulo = false;
|
|
return this.Obras.Descripcion;
|
|
}
|
|
else
|
|
{
|
|
return "";
|
|
}
|
|
}
|
|
else
|
|
{
|
|
return _DescripcionObraTmp;
|
|
}
|
|
}
|
|
set
|
|
{
|
|
_DescripcionObraTmp = value;
|
|
_DescripcionObraTmpEsNulo = false;
|
|
if (this.Obras is not null)
|
|
{
|
|
this.Obras.Descripcion = value;
|
|
}
|
|
this.OnPropertyChanged("DescripcionObraTmp");
|
|
}
|
|
}
|
|
|
|
private bool _CodigoPostalObraTmpEsNulo = true;
|
|
private string _CodigoPostalObraTmp;
|
|
[NotMapped]
|
|
public virtual string CodigoPostalObraTmp
|
|
{
|
|
get
|
|
{
|
|
if (_CodigoPostalObraTmpEsNulo)
|
|
{
|
|
if (this.Obras is not null)
|
|
{
|
|
_CodigoPostalObraTmp = this.Obras.CodigoPostal;
|
|
_CodigoPostalObraTmpEsNulo = false;
|
|
return this.Obras.CodigoPostal;
|
|
}
|
|
else
|
|
{
|
|
return "";
|
|
}
|
|
}
|
|
else
|
|
{
|
|
return _CodigoPostalObraTmp;
|
|
}
|
|
|
|
}
|
|
set
|
|
{
|
|
_CodigoPostalObraTmp = value;
|
|
_CodigoPostalObraTmpEsNulo = false;
|
|
if (this.Obras is not null)
|
|
{
|
|
this.Obras.CodigoPostal = value;
|
|
}
|
|
this.OnPropertyChanged("CodigoPostalObraTmp");
|
|
}
|
|
}
|
|
|
|
private bool _DomicilioObraTmpEsNulo = true;
|
|
private string _DomicilioObraTmp;
|
|
[NotMapped]
|
|
public virtual string DomicilioObraTmp
|
|
{
|
|
get
|
|
{
|
|
if (_DomicilioObraTmpEsNulo)
|
|
{
|
|
if (this.Obras is not null)
|
|
{
|
|
_DomicilioObraTmp = this.Obras.Direccion.NothingAVacio();
|
|
_DomicilioObraTmpEsNulo = false;
|
|
return this.Obras.Direccion;
|
|
}
|
|
else
|
|
{
|
|
return "";
|
|
}
|
|
}
|
|
else
|
|
{
|
|
return _DomicilioObraTmp;
|
|
}
|
|
}
|
|
set
|
|
{
|
|
_DomicilioObraTmp = value;
|
|
_DomicilioObraTmpEsNulo = false;
|
|
if (this.Obras is not null)
|
|
{
|
|
this.Obras.Direccion = value;
|
|
}
|
|
this.OnPropertyChanged("DomicilioObraTmp");
|
|
}
|
|
}
|
|
|
|
|
|
private bool _CodigoPoblacionObraTmpEsNulo = true;
|
|
private string _CodigoPoblacionObraTmp;
|
|
[NotMapped]
|
|
public virtual string CodigoPoblacionObraTmp
|
|
{
|
|
get
|
|
{
|
|
if (_CodigoPoblacionObraTmpEsNulo)
|
|
{
|
|
if (this.Obras is null)
|
|
{
|
|
if (this.Obras is not null && this.Obras.CodigoMunicipioNavigation is null)
|
|
{
|
|
if (!string.IsNullOrEmpty(this.Obras.CodigoPostal.NothingAVacio()))
|
|
{
|
|
tscGrupoSanchoToro bd = tscGrupoSanchoToro.NuevoContexto(); //tscGrupoSanchoToro.NuevoContexto();
|
|
var pob = bd.codigospostales.First(x => (x.CodigoPostal ?? "") == (this.Obras.CodigoPostal ?? ""));
|
|
this.Obras.CodigoMunicipio = pob.CodigoMunicipio;
|
|
_CodigoPoblacionObraTmp = pob.CodigoMunicipio;
|
|
_CodigoPoblacionObraTmpEsNulo = false;
|
|
return _CodigoPoblacionObraTmp;
|
|
}
|
|
else
|
|
{
|
|
return "";
|
|
}
|
|
}
|
|
else
|
|
{
|
|
return "";
|
|
}
|
|
}
|
|
|
|
else
|
|
{
|
|
_CodigoPoblacionObraTmp = this.Obras.CodigoMunicipio;
|
|
_CodigoPoblacionObraTmpEsNulo = false;
|
|
return this.Obras.CodigoMunicipio;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
return _CodigoPoblacionObraTmp;
|
|
}
|
|
|
|
}
|
|
set
|
|
{
|
|
_CodigoPoblacionObraTmp = value;
|
|
_CodigoPoblacionObraTmpEsNulo = false;
|
|
if (this.Obras is not null)
|
|
{
|
|
this.Obras.CodigoMunicipio = value;
|
|
}
|
|
this.OnPropertyChanged("CodigoPoblacionObraTmp");
|
|
this.OnPropertyChanged("PoblacionObraTmp");
|
|
this.OnPropertyChanged("ProvinciaObraTmp");
|
|
}
|
|
}
|
|
|
|
|
|
[NotMapped]
|
|
public string PoblacionObraTmp
|
|
{
|
|
get
|
|
{
|
|
return Conversions.ToString(municipios.ObtienePoblacion(CodigoPoblacionObraTmp));
|
|
}
|
|
}
|
|
|
|
[NotMapped]
|
|
public string ProvinciaObraTmp
|
|
{
|
|
get
|
|
{
|
|
return Conversions.ToString(municipios.ObtieneProvincia(CodigoPoblacionObraTmp));
|
|
}
|
|
}
|
|
|
|
private bool _TelefonoObra1TmpEsNulo = true;
|
|
private string _TelefonoObra1Tmp;
|
|
[NotMapped]
|
|
public virtual string TelefonoObra1Tmp
|
|
{
|
|
get
|
|
{
|
|
if (_TelefonoObra1TmpEsNulo)
|
|
{
|
|
if (this.Obras is not null)
|
|
{
|
|
_TelefonoObra1Tmp = this.Obras.Telefono1;
|
|
_TelefonoObra1TmpEsNulo = false;
|
|
return this.Obras.Telefono1;
|
|
}
|
|
else
|
|
{
|
|
return "";
|
|
}
|
|
}
|
|
else
|
|
{
|
|
return _TelefonoObra1Tmp;
|
|
}
|
|
}
|
|
set
|
|
{
|
|
_TelefonoObra1Tmp = value;
|
|
_TelefonoObra1TmpEsNulo = false;
|
|
if (this.Obras is not null)
|
|
{
|
|
this.Obras.Telefono1 = value;
|
|
}
|
|
this.OnPropertyChanged("TelefonoObra1Tmp");
|
|
}
|
|
}
|
|
|
|
private bool _TelefonoObra2TmpEsNulo = true;
|
|
private string _TelefonoObra2Tmp;
|
|
[NotMapped]
|
|
public virtual string TelefonoObra2Tmp
|
|
{
|
|
get
|
|
{
|
|
if (_TelefonoObra2TmpEsNulo)
|
|
{
|
|
if (this.Obras is not null)
|
|
{
|
|
_TelefonoObra2Tmp = this.Obras.Telefono2;
|
|
_TelefonoObra2TmpEsNulo = false;
|
|
return this.Obras.Telefono2;
|
|
}
|
|
else
|
|
{
|
|
return "";
|
|
}
|
|
}
|
|
else
|
|
{
|
|
return _TelefonoObra2Tmp;
|
|
}
|
|
}
|
|
set
|
|
{
|
|
_TelefonoObra2Tmp = value;
|
|
_TelefonoObra2TmpEsNulo = false;
|
|
if (this.Obras is not null)
|
|
{
|
|
this.Obras.Telefono2 = value;
|
|
}
|
|
this.OnPropertyChanged("TelefonoObra2Tmp");
|
|
}
|
|
}
|
|
private bool _EmailObraTmpEsNulo = true;
|
|
private string _EmailObraTmp;
|
|
[NotMapped]
|
|
public virtual string EmailObraTmp
|
|
{
|
|
get
|
|
{
|
|
if (_EmailObraTmpEsNulo)
|
|
{
|
|
if (this.Obras is not null)
|
|
{
|
|
_EmailObraTmp = this.Obras.Email;
|
|
_EmailObraTmpEsNulo = false;
|
|
return this.Obras.Email;
|
|
}
|
|
else
|
|
{
|
|
return "";
|
|
}
|
|
}
|
|
else
|
|
{
|
|
return _EmailObraTmp;
|
|
}
|
|
}
|
|
set
|
|
{
|
|
_EmailObraTmp = value;
|
|
_EmailObraTmpEsNulo = false;
|
|
if (this.Obras is not null)
|
|
{
|
|
this.Obras.Email = value;
|
|
}
|
|
this.OnPropertyChanged("EmailObraTmp");
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private bool _ObservacionesObraTmpEsNulo = true;
|
|
private string _ObservacionesObraTmp;
|
|
|
|
|
|
[NotMapped]
|
|
public virtual string ObservacionesObraTmp
|
|
{
|
|
get
|
|
{
|
|
if (_ObservacionesObraTmpEsNulo)
|
|
{
|
|
if (this.Obras is null)
|
|
{
|
|
return "";
|
|
}
|
|
else
|
|
{
|
|
_ObservacionesObraTmp = this.Obras.Observaciones;
|
|
_ObservacionesObraTmpEsNulo = false;
|
|
return this.Obras.Observaciones;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
return _ObservacionesObraTmp;
|
|
}
|
|
}
|
|
set
|
|
{
|
|
_ObservacionesObraTmp = value;
|
|
_ObservacionesObraTmpEsNulo = false;
|
|
if (this.Obras is not null)
|
|
{
|
|
this.Obras.Observaciones = value;
|
|
}
|
|
this.OnPropertyChanged("ObservacionesObraTmp");
|
|
}
|
|
}
|
|
|
|
private bool _PersonaContactoObraTmpEsNulo = true;
|
|
private string _PersonaContactoObraTmp;
|
|
|
|
public event PropertyChangedEventHandler? PropertyChanged;
|
|
|
|
[NotMapped]
|
|
public virtual string PersonaContactoObraTmp
|
|
{
|
|
get
|
|
{
|
|
if (_PersonaContactoObraTmpEsNulo)
|
|
{
|
|
if (this.Obras is null)
|
|
{
|
|
return "";
|
|
}
|
|
else
|
|
{
|
|
_PersonaContactoObraTmp = this.Obras.PersonaContacto;
|
|
_PersonaContactoObraTmpEsNulo = false;
|
|
return this.Obras.PersonaContacto;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
return _PersonaContactoObraTmp;
|
|
}
|
|
}
|
|
set
|
|
{
|
|
_PersonaContactoObraTmp = value;
|
|
_PersonaContactoObraTmpEsNulo = false;
|
|
if (this.Obras is not null)
|
|
{
|
|
this.Obras.PersonaContacto = value;
|
|
}
|
|
this.OnPropertyChanged("PersonaContactoObraTmp");
|
|
}
|
|
}
|
|
public void ReiniciaValoresTMPObra()
|
|
{
|
|
_CodigoPoblacionObraTmpEsNulo = true;
|
|
_CodigoPostalObraTmpEsNulo = true;
|
|
_DomicilioObraTmpEsNulo = true;
|
|
_TelefonoObra1TmpEsNulo = true;
|
|
_TelefonoObra2TmpEsNulo = true;
|
|
_ObservacionesObraTmpEsNulo = true;
|
|
_PersonaContactoObraTmpEsNulo = true;
|
|
}
|
|
public void ActualizaValoresTMPObra()
|
|
{
|
|
this.OnPropertyChanged("CodigoPostalObraTmp");
|
|
this.OnPropertyChanged("DomicilioObraTmp");
|
|
this.OnPropertyChanged("CodigoPoblacionObraTmp");
|
|
this.OnPropertyChanged("PoblacionObraTmp");
|
|
this.OnPropertyChanged("ProvinciaObraTmp");
|
|
this.OnPropertyChanged("TelefonoObra1Tmp");
|
|
this.OnPropertyChanged("TelefonoObra2Tmp");
|
|
this.OnPropertyChanged("ObservacionesObraTmp");
|
|
this.OnPropertyChanged("PersonaContactoObraTmp");
|
|
}
|
|
#endregion
|
|
}
|
|
|
|
|
|
|
|
|
|
public class DetalleProductoFinal
|
|
{
|
|
[Key]
|
|
public int idProducto { get; set; }
|
|
public string Descripcion { get; set; }
|
|
public int Cantidad { get; set; }
|
|
public double Importe { get; set; }
|
|
public string Tipo { get; set; }
|
|
}
|
|
} |