agregado procesos y bd clases
This commit is contained in:
229
guia/Extensiones/agentes.vb
Normal file
229
guia/Extensiones/agentes.vb
Normal file
@@ -0,0 +1,229 @@
|
||||
Imports tsl5.Extensiones
|
||||
|
||||
Partial Public Class agentes
|
||||
|
||||
Public ReadOnly Property NombreYCodigo As String
|
||||
Get
|
||||
Return Nombre & " - " & Codigo
|
||||
End Get
|
||||
End Property
|
||||
Public ReadOnly Property CodigoYNombre As String
|
||||
Get
|
||||
Return Codigo & " - " & Nombre
|
||||
End Get
|
||||
End Property
|
||||
|
||||
|
||||
Public ReadOnly Property Direccion As direcciones
|
||||
Get
|
||||
If Me.idDireccion.HasValue AndAlso Me.idDireccion.Value > 0 Then
|
||||
Return Me.direcciones
|
||||
Else
|
||||
Return Nothing
|
||||
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 Direccion Is Nothing Then
|
||||
Return ""
|
||||
Else
|
||||
_CodigoPostalTmp = Me.Direccion.CodigoPostal
|
||||
_CodigoPostalTmpEsNulo = False
|
||||
Return Me.Direccion.CodigoPostal
|
||||
End If
|
||||
Else
|
||||
Return _CodigoPostalTmp
|
||||
End If
|
||||
End Get
|
||||
Set(value As String)
|
||||
_CodigoPostalTmp = value
|
||||
_CodigoPostalTmpEsNulo = False
|
||||
If Direccion IsNot Nothing Then
|
||||
Direccion.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 Direccion Is Nothing Then
|
||||
Return ""
|
||||
Else
|
||||
_DomicilioTmp = Direccion.Direccion
|
||||
_DomicilioTmpEsNulo = False
|
||||
Return Direccion.Direccion
|
||||
End If
|
||||
Else
|
||||
Return _DomicilioTmp
|
||||
End If
|
||||
End Get
|
||||
Set(value As String)
|
||||
_DomicilioTmp = value
|
||||
_DomicilioTmpEsNulo = False
|
||||
If Direccion IsNot Nothing Then
|
||||
Direccion.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 Direccion Is Nothing OrElse Direccion.municipios Is Nothing Then
|
||||
If Direccion IsNot Nothing AndAlso Direccion.municipios Is Nothing Then
|
||||
If Direccion.CodigoPostal.NothingAVacio <> "" Then
|
||||
Dim bd = bdGestionAsegasa.gestionasegasaEntities.NuevoContexto
|
||||
Dim pob = bd.codigospostales.FirstOrDefault(Function(x) x.CodigoPostal = Direccion.CodigoPostal)
|
||||
If pob Is Nothing Then
|
||||
Return "CP.ERRONEO"
|
||||
Else
|
||||
Direccion.CodigoMunicipio = pob.CodigoMunicipio
|
||||
_CodigoPoblacionTmp = pob.CodigoMunicipio
|
||||
_CodigoPoblacionTmpEsNulo = False
|
||||
Return _CodigoPoblacionTmp
|
||||
End If
|
||||
Else
|
||||
Return ""
|
||||
End If
|
||||
Else
|
||||
Return ""
|
||||
End If
|
||||
Else
|
||||
_CodigoPoblacionTmp = Direccion.CodigoMunicipio
|
||||
_CodigoPoblacionTmpEsNulo = False
|
||||
Return Direccion.CodigoMunicipio
|
||||
End If
|
||||
Else
|
||||
Return _CodigoPoblacionTmp
|
||||
End If
|
||||
End Get
|
||||
Set(value As String)
|
||||
_CodigoPoblacionTmp = value
|
||||
_CodigoPoblacionTmpEsNulo = False
|
||||
If Direccion IsNot Nothing Then
|
||||
Direccion.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 OficinaAgente As String
|
||||
Get
|
||||
' Dim sPrefijoAgentes As String = "|2 |000004|000018|000023|000029|100029|"
|
||||
'Dim sPrefijo = Me.Codigo.PadLeft(6, " ")
|
||||
'If sPrefijoAgentes.Contains("|" & sPrefijo & "|") Then
|
||||
If Me.Codigo <> "000029013008" And (Me.Codigo.StartsWith("2") Or Me.Codigo.StartsWith("000004") Or Me.Codigo.StartsWith("000018") Or Me.Codigo.StartsWith("000023") Or Me.Codigo.StartsWith("000029") Or Me.Codigo.StartsWith("100029")) Then
|
||||
Return "Antequera"
|
||||
Else
|
||||
Return "Sevilla"
|
||||
End If
|
||||
End Get
|
||||
End Property
|
||||
Public ReadOnly Property PolizasConDocumentosPendientes As List(Of polizassg)
|
||||
Get
|
||||
Return Me.polizassg.Where(Function(x) (x.NumeroPoliza IsNot Nothing OrElse x.FechaAceptacionPresupuesto.HasValue) AndAlso (x.FechaDocumentosSuplementoRevisado IsNot Nothing OrElse x.NumeroSuplemento = 0 OrElse x.agentes.Codigo = "1" OrElse x.agentes.Codigo = "2") AndAlso x.documentospolizassg.Any(Function(y) y.Obligatorio AndAlso y.FechaComprobacion Is Nothing AndAlso y.idFichero Is Nothing)).ToList
|
||||
End Get
|
||||
End Property
|
||||
Public ReadOnly Property PolizasConDocumentosPendientes7Dias As List(Of polizassg)
|
||||
Get
|
||||
Dim FechaInicio As Date = Date.Today.AddDays(-7)
|
||||
Return Me.polizassg.Where(Function(x) x.FechaBaja.HasValue = False And (x.NumeroPoliza IsNot Nothing Or x.FechaAceptacionPresupuesto IsNot Nothing) And (x.FechaAlta >= FechaInicio And (x.FechaDocumentosSuplementoRevisado IsNot Nothing OrElse x.NumeroSuplemento = 0 Or x.agentes.Codigo = "1" Or x.agentes.Codigo = "2") And x.documentospolizassg.Any(Function(y) y.FechaComprobacion Is Nothing AndAlso y.idFichero Is Nothing AndAlso y.Obligatorio AndAlso (y.documentosasolicitar Is Nothing OrElse y.documentosasolicitar.SolicitarAAgente)))).ToList
|
||||
'Return Me.polizassg.Where(Function(x) (x.FechaAlta.HasValue = False OrElse x.FechaAlta >= FechaInicio) AndAlso (x.NumeroPoliza IsNot Nothing OrElse x.FechaAceptacionPresupuesto.HasValue)).ToList.Where(Function(x) (x.FechaDocumentosSuplementoRevisado IsNot Nothing OrElse x.NumeroSuplemento = 0 OrElse x.agentes.Codigo = "1" OrElse x.agentes.Codigo = "2") And x.documentospolizassg.Any(Function(y) y.Obligatorio AndAlso y.FechaComprobacion Is Nothing AndAlso y.idFichero Is Nothing)).ToList
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Public Shared Function CambiaCarteraAgente(AgenteAnterior As String, AgenteNuevo As String) As Boolean
|
||||
Dim bd = bdGestionAsegasa.gestionasegasaEntities.NuevoContextoCN()
|
||||
Dim idnueage = bd.agentes.First(Function(x) x.Codigo = AgenteNuevo).idAgente
|
||||
Dim recs = bd.recibos.Where(Function(x) x.liquidacionesagenterecibos.Any = False And x.agentes.Codigo = AgenteAnterior).ToList
|
||||
Dim tge = bdGestionAsegasa.TipoGestionEnum.CAMBIO_CARTERA_AGENTE
|
||||
For Each r In recs
|
||||
r.idAgente = idnueage
|
||||
' r.polizassg.idAgente = idnueage
|
||||
Dim tg As New bdGestionAsegasa.gestionesrecibos
|
||||
With tg
|
||||
.idRecibo = r.idRecibo
|
||||
.FormaComunicacion = 4
|
||||
.Tipo = tge
|
||||
.GestionesRealizadas = tge.ToString.Replace("_", " ")
|
||||
.Fecha = Now
|
||||
.idCorreo = Nothing
|
||||
.Observaciones = "Cambio Cartera Agente del " & AgenteAnterior & " al " & AgenteNuevo
|
||||
End With
|
||||
bd.gestionesrecibos.AddObject(tg)
|
||||
Next
|
||||
bd.SaveChanges()
|
||||
|
||||
|
||||
Dim tgp = bd.enumeraciones.First(Function(x) x.Codigo = "TGP.CAMCARAG")
|
||||
Dim idtgp = tgp.idEnumeracion
|
||||
|
||||
Dim pols = bd.polizassg.Where(Function(x) x.agentes.Codigo = AgenteAnterior And x.FechaBaja.HasValue = False)
|
||||
For Each p In pols
|
||||
p.idAgente = idnueage
|
||||
Dim tg As New bdGestionAsegasa.gestionespolizassg
|
||||
With tg
|
||||
.idPoliza = p.idPoliza
|
||||
.idTipo = idtgp
|
||||
.GestionesRealizadas = tgp.Descripcion
|
||||
.Fecha = Now
|
||||
.Observaciones = "Cambio Cartera Agente del " & AgenteAnterior & " al " & AgenteNuevo
|
||||
End With
|
||||
bd.gestionespolizassg.AddObject(tg)
|
||||
Next
|
||||
bd.SaveChanges()
|
||||
Dim ageant = bd.agentes.First(Function(x) x.Codigo = AgenteAnterior)
|
||||
Dim bbaja As Boolean
|
||||
If ageant.FechaBaja.HasValue = False Then
|
||||
ageant.FechaBaja = Now
|
||||
bbaja = True
|
||||
Else
|
||||
bbaja = False
|
||||
End If
|
||||
bd.SaveChanges()
|
||||
Return bbaja
|
||||
End Function
|
||||
End Class
|
||||
Reference in New Issue
Block a user