agregado procesos y bd clases
This commit is contained in:
355
guia/Extensiones/entidades.vb
Normal file
355
guia/Extensiones/entidades.vb
Normal file
@@ -0,0 +1,355 @@
|
||||
Imports System.ComponentModel
|
||||
Imports System.Data.Objects
|
||||
Imports tsl5.Extensiones
|
||||
Imports System.Text.RegularExpressions
|
||||
Partial Public Class entidades
|
||||
Implements INotifyPropertyChanged
|
||||
|
||||
Public Function UltimoReciboDevueltoFaltaPago(CodigoRamo As String) As Boolean
|
||||
If Me.idEntidad <> 0 Then
|
||||
Dim bd As bdGestionAsegasa.gestionasegasaEntities = ObtieneContexto
|
||||
Dim idramo = bd.ramos.First(Function(x) x.Codigo = CodigoRamo).idRamo
|
||||
Dim idfp = bd.enumeraciones.First(Function(x) x.Codigo = "CABA.FP").idEnumeracion
|
||||
Dim recs = bd.entidadespolizas.Where(Function(x) x.idEntidad = Me.idEntidad).Select(Function(x) x.polizassg).Where(Function(x) x.idRamo = idramo).SelectMany(Function(x) x.recibos).ToList
|
||||
Dim rec = recs.OrderByDescending(Function(x) x.FechaEfecto).FirstOrDefault
|
||||
If rec Is Nothing Then
|
||||
Return False
|
||||
Else
|
||||
Return rec.idCausaBaja.HasValue AndAlso rec.idCausaBaja = idfp
|
||||
End If
|
||||
End If
|
||||
Return False
|
||||
End Function
|
||||
|
||||
Public ReadOnly Property Sexo As String
|
||||
Get
|
||||
If Me.idSexo.HasValue Then
|
||||
Return Me.enumeraciones.Descripcion
|
||||
Else
|
||||
Return "* Desconocido *"
|
||||
End If
|
||||
End Get
|
||||
End Property
|
||||
Public ReadOnly Property DireccionPrincipal As direcciones
|
||||
Get
|
||||
If Me.idDireccionPrincipal.HasValue AndAlso Me.idDireccionPrincipal.Value > 0 Then
|
||||
If Me.direcciones1 Is Nothing Then
|
||||
Dim d = Me.direcciones.First(Function(x) x.idDireccion = Me.idDireccionPrincipal)
|
||||
Return d
|
||||
Else
|
||||
Return Me.direcciones1
|
||||
End If
|
||||
Else
|
||||
If Me.direcciones.Any Then
|
||||
If Me.direcciones.Any(Function(x) x.idTipo.HasValue AndAlso x.enumeraciones.Codigo = "TIPDIR.CORREO") Then
|
||||
Dim d = Me.direcciones.First(Function(x) x.idTipo.HasValue AndAlso x.enumeraciones.Codigo = "TIPDIR.CORREO")
|
||||
' Me.idDireccionPrincipal = d.idDireccion
|
||||
'Me.direcciones1 = d
|
||||
Return d
|
||||
Else
|
||||
Dim d = Me.direcciones.First
|
||||
' Me.idDireccionPrincipal = d.idDireccion
|
||||
'Me.direcciones1 = d
|
||||
Return d
|
||||
End If
|
||||
Else
|
||||
Return Nothing
|
||||
End If
|
||||
End If
|
||||
End Get
|
||||
End Property
|
||||
|
||||
|
||||
Private _CodigoPostalTmpEsNulo As Boolean = True
|
||||
Private _CodigoPostalTmp As String
|
||||
Public Property CodigoPostalTmp As String
|
||||
Get
|
||||
If _CodigoPostalTmpEsNulo Then
|
||||
If DireccionPrincipal Is Nothing Then
|
||||
Return ""
|
||||
Else
|
||||
_CodigoPostalTmp = Me.DireccionPrincipal.CodigoPostal
|
||||
_CodigoPostalTmpEsNulo = False
|
||||
Return Me.DireccionPrincipal.CodigoPostal
|
||||
End If
|
||||
Else
|
||||
Return _CodigoPostalTmp
|
||||
End If
|
||||
End Get
|
||||
Set(value As String)
|
||||
_CodigoPostalTmp = value
|
||||
_CodigoPostalTmpEsNulo = False
|
||||
If DireccionPrincipal IsNot Nothing Then
|
||||
DireccionPrincipal.CodigoPostal = value
|
||||
End If
|
||||
Me.OnPropertyChanged("CodigoPostalTmp")
|
||||
End Set
|
||||
End Property
|
||||
|
||||
Private _DomicilioTmpEsNulo As Boolean = True
|
||||
Private _DomicilioTmp As String
|
||||
Public Property DomicilioTmp As String
|
||||
Get
|
||||
If _DomicilioTmpEsNulo Then
|
||||
If DireccionPrincipal Is Nothing Then
|
||||
Return ""
|
||||
Else
|
||||
_DomicilioTmp = DireccionPrincipal.Direccion
|
||||
_DomicilioTmpEsNulo = False
|
||||
Return DireccionPrincipal.Direccion
|
||||
End If
|
||||
Else
|
||||
Return _DomicilioTmp
|
||||
End If
|
||||
End Get
|
||||
Set(value As String)
|
||||
_DomicilioTmp = value
|
||||
_DomicilioTmpEsNulo = False
|
||||
If DireccionPrincipal IsNot Nothing Then
|
||||
DireccionPrincipal.Direccion = value
|
||||
End If
|
||||
Me.OnPropertyChanged("DomicilioTmp")
|
||||
End Set
|
||||
End Property
|
||||
|
||||
|
||||
Private _CodigoPoblacionTmpEsNulo As Boolean = True
|
||||
Private _CodigoPoblacionTmp As String
|
||||
Public Property CodigoPoblacionTmp As String
|
||||
Get
|
||||
If _CodigoPoblacionTmpEsNulo Then
|
||||
|
||||
If DireccionPrincipal Is Nothing OrElse DireccionPrincipal.municipios Is Nothing Then
|
||||
If DireccionPrincipal IsNot Nothing AndAlso DireccionPrincipal.municipios Is Nothing Then
|
||||
If DireccionPrincipal.CodigoPostal.NothingAVacio <> "" Then
|
||||
Dim bd = bdGestionAsegasa.gestionasegasaEntities.NuevoContexto
|
||||
Dim pob = bd.codigospostales.FirstOrDefault(Function(x) x.CodigoPostal = DireccionPrincipal.CodigoPostal)
|
||||
If pob Is Nothing Then
|
||||
Return "CP.ERRONEO"
|
||||
Else
|
||||
DireccionPrincipal.CodigoMunicipio = pob.CodigoMunicipio
|
||||
_CodigoPoblacionTmp = pob.CodigoMunicipio
|
||||
_CodigoPoblacionTmpEsNulo = False
|
||||
Return _CodigoPoblacionTmp
|
||||
End If
|
||||
Else
|
||||
Return ""
|
||||
End If
|
||||
Else
|
||||
Return ""
|
||||
End If
|
||||
Else
|
||||
_CodigoPoblacionTmp = DireccionPrincipal.CodigoMunicipio
|
||||
_CodigoPoblacionTmpEsNulo = False
|
||||
Return DireccionPrincipal.CodigoMunicipio
|
||||
End If
|
||||
Else
|
||||
Return _CodigoPoblacionTmp
|
||||
End If
|
||||
End Get
|
||||
Set(value As String)
|
||||
_CodigoPoblacionTmp = value
|
||||
_CodigoPoblacionTmpEsNulo = False
|
||||
If DireccionPrincipal IsNot Nothing Then
|
||||
DireccionPrincipal.CodigoMunicipio = value
|
||||
End If
|
||||
Me.OnPropertyChanged("CodigoPoblacionTmp")
|
||||
ProvinciaTmp = municipios.ObtieneProvincia(_CodigoPoblacionTmp)
|
||||
PoblacionTmp = municipios.ObtienePoblacion(_CodigoPoblacionTmp)
|
||||
End Set
|
||||
End Property
|
||||
|
||||
Private _PoblacionTmp As String
|
||||
Private _PoblacionTmpEsNulo As Boolean = True
|
||||
Public Property PoblacionTmp As String
|
||||
Get
|
||||
If _PoblacionTmpEsNulo Then _PoblacionTmp = municipios.ObtienePoblacion(CodigoPoblacionTmp)
|
||||
Return _PoblacionTmp
|
||||
End Get
|
||||
Set(value As String)
|
||||
_PoblacionTmp = value
|
||||
Me.OnPropertyChanged("PoblacionTmp")
|
||||
End Set
|
||||
End Property
|
||||
|
||||
Private _ProvinciaTmp As String
|
||||
Private _ProvinciaTmpEsNulo As Boolean = True
|
||||
Public Property ProvinciaTmp As String
|
||||
Get
|
||||
If _ProvinciaTmpEsNulo Then _ProvinciaTmp = municipios.ObtieneProvincia(CodigoPoblacionTmp)
|
||||
Return _ProvinciaTmp
|
||||
End Get
|
||||
Set(value As String)
|
||||
_ProvinciaTmp = value
|
||||
Me.OnPropertyChanged("ProvinciaTmp")
|
||||
End Set
|
||||
End Property
|
||||
Public ReadOnly Property FechaNacimientoSinHora As String
|
||||
Get
|
||||
Return Me.FechaNacimiento.ToString.PadLeft(10, " ").Substring(0, 10)
|
||||
End Get
|
||||
End Property
|
||||
Public ReadOnly Property FechaExpCarnetSinHora As String
|
||||
Get
|
||||
Return Me.FechaExpedicionCarnet.ToString.PadLeft(10, " ").Substring(0, 10)
|
||||
End Get
|
||||
End Property
|
||||
|
||||
'Public Sub ReiniciaValoresTMP()
|
||||
' _CodigoPoblacionTmpEsNulo = True
|
||||
' _CodigoPostalTmpEsNulo = True
|
||||
' _DomicilioTmpEsNulo = True
|
||||
'End Sub
|
||||
|
||||
Friend Shared Sub GuardandoCambios(bd As bdGestionAsegasa.gestionasegasaEntities, Aplicacion As String)
|
||||
|
||||
Dim ents As IEnumerable(Of ObjectStateEntry) = Nothing
|
||||
Dim dirs As IEnumerable(Of ObjectStateEntry) = Nothing
|
||||
ents = bd.ObjectStateManager.GetObjectStateEntries(EntityState.Modified).Where(Function(x) x.EntitySet.Name.ToLower = "entidades")
|
||||
Dim nents = bd.ObjectStateManager.GetObjectStateEntries(EntityState.Modified).Where(Function(x) x.EntitySet.Name.ToLower = "entidades")
|
||||
dirs = bd.ObjectStateManager.GetObjectStateEntries(EntityState.Modified).Where(Function(x) x.EntitySet.Name.ToLower = "direcciones")
|
||||
Try
|
||||
For Each m In ents
|
||||
Dim ra = DirectCast(m.Entity, entidades)
|
||||
ra.CIF = Regex.Replace(ra.CIF.NothingAVacio, "[^a-zA-Z0-9]", "").ToUpper
|
||||
Next
|
||||
Catch ex As Exception
|
||||
|
||||
End Try
|
||||
Try
|
||||
Dim bdtmp = bdGestionAsegasa.gestionasegasaEntities.NuevoContextoCN
|
||||
For Each m In ents
|
||||
Dim ra = DirectCast(m.Entity, entidades)
|
||||
ra.CIF = Regex.Replace(ra.CIF.NothingAVacio, "[^a-zA-Z0-9]", "").ToUpper
|
||||
Dim reant = bdtmp.entidades.First(Function(x) x.idEntidad = ra.idEntidad)
|
||||
Dim su = If(bd.Aplicacion IsNot Nothing, bd.Aplicacion.ModoSuperUsuario, False)
|
||||
Dim lr = bdGestionAsegasa.logs.GeneraLog(bdtmp, "ENTIDADES", reant.idEntidad, Nothing, "REGISTRO_COMPLETO", tsl5.Utilidades.Serializar(reant), su, Aplicacion)
|
||||
Dim lep = reant.direcciones.ToList
|
||||
bdGestionAsegasa.logs.GeneraLog(bdtmp, "DIRECCIONESENTIDADES", reant.idEntidad, lr, "REGISTRO_COMPLETO", tsl5.Utilidades.Serializar(lep), su, Aplicacion)
|
||||
Next
|
||||
|
||||
Catch ex As Exception
|
||||
Dim sListaCambios As String = ""
|
||||
If ents IsNot Nothing Then
|
||||
For Each m In ents
|
||||
Dim ra = DirectCast(m.Entity, entidades)
|
||||
sListaCambios &= "entidades idEntidad:" & ra.idEntidad & "; "
|
||||
Next
|
||||
End If
|
||||
Call Utilidades.AñadeLog(tsl5.Enumeraciones.TipoLog.Fallo, "En GuardandoCambios", ex.Message & vbCrLf & sListaCambios, ex)
|
||||
End Try
|
||||
End Sub
|
||||
Public ReadOnly Property RelacionesEntreEntidades As List(Of EntidadRelacionada)
|
||||
Get
|
||||
Dim entsh = Me.entidadesrelacionadas.Select(Function(x) New EntidadRelacionada With {
|
||||
.RazonSocial = x.entidades1.RazonSocial,
|
||||
.TipoRelacion = EntidadRelacionada.TipoRelacionEntidadEnum.ES_HIJA,
|
||||
.CIF = x.entidades1.CIF,
|
||||
.EntRel = x
|
||||
}).ToList
|
||||
Dim entsp = Me.entidadesrelacionadas1.Select(Function(x) New EntidadRelacionada With {
|
||||
.RazonSocial = x.entidades.RazonSocial,
|
||||
.TipoRelacion = EntidadRelacionada.TipoRelacionEntidadEnum.ES_PADRE,
|
||||
.CIF = x.entidades.CIF,
|
||||
.EntRel = x
|
||||
}).ToList
|
||||
Return entsh.Union(entsp).OrderBy(Function(x) x.RazonSocial).ToList
|
||||
End Get
|
||||
End Property
|
||||
Public Class EntidadRelacionada
|
||||
Public Property idEntidad As Integer
|
||||
Public Property CIF As String
|
||||
Public Property TipoRelacion As TipoRelacionEntidadEnum
|
||||
Public ReadOnly Property DescripcionTipoRelacion As String
|
||||
Get
|
||||
Return TipoRelacion.ToString.Replace("_", " ")
|
||||
End Get
|
||||
End Property
|
||||
Public Property RazonSocial As String
|
||||
Public Enum TipoRelacionEntidadEnum As Integer
|
||||
ES_HIJA = 0
|
||||
ES_PADRE = 1
|
||||
End Enum
|
||||
Public Property EntRel As entidadesrelacionadas
|
||||
End Class
|
||||
End Class
|
||||
Public Class ve_entidades
|
||||
Public Property idEntidad As String
|
||||
Public Property CIF As String
|
||||
Public Property RazonSocial As String
|
||||
Public Property FechaNacimiento As Date?
|
||||
Public Property Direccion As String
|
||||
Public Property Poblacion As String
|
||||
Public Property Provincia As String
|
||||
Public Property Telefono1 As String
|
||||
Public Property email As String
|
||||
Public Property EsTaller As Boolean
|
||||
Public Property EsClienteSG As Boolean
|
||||
Public Property EsClienteSA As Boolean
|
||||
Public Property EsContrarioSiniestro As Boolean
|
||||
Public ReadOnly Property PoblacionYProvincia As String
|
||||
Get
|
||||
If Me.Provincia = Me.Poblacion Then
|
||||
Return Me.Poblacion
|
||||
Else
|
||||
Return Me.Poblacion & " (" & Me.Provincia & ")"
|
||||
End If
|
||||
End Get
|
||||
End Property
|
||||
|
||||
End Class
|
||||
|
||||
Public Class ve_entidades_venta_cruzada
|
||||
Public Property idEntidad As String
|
||||
Public Property CIF As String
|
||||
Public Property RazonSocial As String
|
||||
' Public Property FechaNacimiento As Date?
|
||||
' Public Property Direccion As String
|
||||
' Public Property Poblacion As String
|
||||
' Public Property Provincia As String
|
||||
Public Property Telefono1 As String
|
||||
Public Property Telefono2 As String
|
||||
Public Property FechaNacimientoTomador As Date?
|
||||
Public Property TelefonoMovilValido As String
|
||||
Public Property Email As String
|
||||
' Public Property EsTaller As Boolean
|
||||
' Public Property EsClienteSG As Boolean
|
||||
' Public Property EsClienteSA As Boolean
|
||||
' Public Property EsContrarioSiniestro As Boolean
|
||||
'Public ReadOnly Property PoblacionYProvincia As String
|
||||
' Get
|
||||
' If Me.Provincia = Me.Poblacion Then
|
||||
' Return Me.Poblacion
|
||||
' Else
|
||||
' Return Me.Poblacion & " (" & Me.Provincia & ")"
|
||||
' End If
|
||||
' End Get
|
||||
'End Property
|
||||
|
||||
Public Property NumeroPolizas As Integer
|
||||
Public Property idAgente As Integer
|
||||
Public Property Agente As String
|
||||
Public Property idSubagente As Integer?
|
||||
Public Property SubAgente As String
|
||||
Public Property TlfAgente As String
|
||||
Public Property EmailAgente As String
|
||||
Public Property TlfSubAgente As String
|
||||
Public Property EmailSubAgente As String
|
||||
Public Property NumeroCorreosVentaCruzada As Integer
|
||||
Public Property Compañías As String
|
||||
|
||||
Public ReadOnly Property TelefonoSubAgenteAgente As String
|
||||
Get
|
||||
If TlfSubAgente <> "" Then
|
||||
Return TlfSubAgente
|
||||
Else
|
||||
Return TlfAgente
|
||||
End If
|
||||
End Get
|
||||
End Property
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
End Class
|
||||
Reference in New Issue
Block a user