Files
SIG/Prospectos/ProspectosEstructuras.aspx.vb
2023-02-11 08:33:59 -07:00

379 lines
18 KiB
VB.net

Option Explicit On
Option Strict On
Imports Extensiones
Imports System.Runtime.InteropServices
Imports System.IO
Imports System.Data
Partial Class Prospectos_ProspectosEstructuras
Inherits ClsPaginas
'Confinguración
Private Property DTProspectosValores As DataTable
Get
Return CType(ViewState("DTProspectosValores"), DataTable)
End Get
Set(value As DataTable)
ViewState("DTProspectosValores") = value
End Set
End Property
Private ReadOnly Property CveProspecto As Integer
Get
Return ViewState("CveProspecto").ToString.ToEntero
End Get
End Property
Private Property EventosTmp As Hashtable
Get
Return CType(ViewState("EventosTmp"), Hashtable)
End Get
Set(value As Hashtable)
ViewState("EventosTmp") = value
End Set
End Property
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
DdlPaises.DataSource = GlobalDTGralPaises : DdlPaises.DataBind()
DdlEmpresaPaises.DataSource = GlobalDTGralPaises : DdlEmpresaPaises.DataBind()
DdlEscolaridad.DataSource = GlobalDTGralEscolaridades : DdlEscolaridad.DataBind() : DdlEscolaridad.Items.Insert(0, New ListItem("Seleccione", "-1"))
DdlClasificacion.DataSource = GlobalDTProspectosClasificaciones(UsuarioActual.CveEmpresa) : DdlClasificacion.DataBind() : DdlClasificacion.Items.Insert(0, New ListItem("Seleccione", "-1"))
EventosTmp = New Hashtable
DdlProspectoEvento.DataSource = GlobalDTProspectosEvento(-1, UsuarioActual.CveEmpresa)
DdlProspectoEvento.DataBind()
CEFechaNacimiento.EndDate = Today
'DdlMunicipios.DataSource = GlobalDTGralMunicipios : DdlMunicipios.DataBind()
If Request("CveProspecto") IsNot Nothing AndAlso IsNumeric(Request("CveProspecto")) AndAlso Request("CveProspecto").ToEntero > 0 Then
ViewState("CveProspecto") = Request("CveProspecto")
CargaDatos()
'Configuración de Modalidad Update
BtnGuardar.Text = "Guardar Cambios"
LtlTitulo.Text = "Consulta del Prospecto:"
Else
CargaEstados(DdlEstados, DdlPaises.SelectedValue.ToEntero)
DdlEstados.SelectedValue = "26"
CargaMunicipios(DdlMunicipios, DdlEstados.SelectedValue.ToEntero)
CargaEstados(DdlEmpresaEstados, DdlEmpresaPaises.SelectedValue.ToEntero)
DdlEmpresaEstados.SelectedValue = "26"
CargaMunicipios(DdlEmpresaMunicipios, DdlEmpresaEstados.SelectedValue.ToEntero)
ViewState("CveProspecto") = -1
PnlBusquedaGral.Visible = True
Me.Form.DefaultButton = BtnBusqueda.UniqueID
TxtBusqueda.Focus()
TxtFechaIngreso.Text = Now.ToShortDateString
End If
End If
End Sub
'<Services.WebMethodAttribute()> <Script.Services.ScriptMethodAttribute()> _
'Public Shared Function wsGetReporta(ByVal prefixText As String, ByVal count As Integer) As String()
' 'Dim dt As DataTable = CType(Session("DtCuentas"), DataTable)
' 'Dim Conta As New ClsContPAQi(UsuarioActual.Empresa)
' 'dt = Conta.getCuentasCheque(Prefijo)
' 'Conta.Dispose()
' Dim items As New List(Of String)(count)
' Dim Prosp As New ClsProspectos
' Dim dt As DataTable = Nothing
' If Prosp.GetProspectos(-1, prefixText.Trim, "-1", -1, -1, -1, -1, -1, -1, 41) Then
' dt = Prosp.DtResultados
' End If
' Prosp.Dispose()
' For i As Integer = 0 To count - 1
' If dt.Rows.Count > i Then
' items.Add(AjaxControlToolkit.AutoCompleteExtender.CreateAutoCompleteItem(dt.Rows(i)("NombreCompleto").ToString, dt.Rows(i)("CveProspecto").ToString))
' Else
' Exit For
' End If
' Next
' Return items.ToArray()
'End Function
Private Sub CargaDatos()
Dim ObjProspectos As New ClsProspectos
If ObjProspectos.GetProspectos(CveProspecto, "-1", "-1", -1, -1, -1, -1, -1, -1, UsuarioActual.CveEmpresa) Then
If ObjProspectos.DtResultados.Rows.Count > 0 Then
TxtCveProspecto.Text = ObjProspectos.CveProspecto.ToString
TxtApellidoPaterno.Text = ObjProspectos.ApellidoPaterno
TxtApellidoMaterno.Text = ObjProspectos.ApellidoMaterno
TxtNombres.Text = ObjProspectos.Nombres
TxtFechaNacimiento.Text = ObjProspectos.FechaNacimiento.ToString
TxtLugarNacimiento.Text = ObjProspectos.LugarNacimiento
TxtRFC.Text = ObjProspectos.RFC
TxtNacionalidad.Text = ObjProspectos.Nacionalidad
TxtCalle.Text = ObjProspectos.Calle
TxtNumero.Text = ObjProspectos.Numero
TxtNumeroInterior.Text = ObjProspectos.NumeroInterior
TxtEntreCalle1.Text = ObjProspectos.EntreCalle1
TxtEntreCalle2.Text = ObjProspectos.EntreCalle2
TxtIFE.Text = ObjProspectos.IFE
DdlClasificacion.SelectedValue = ObjProspectos.CveProspectoClasificacion.ToString
DdlEscolaridad.SelectedValue = ObjProspectos.CveEscolaridad.ToString
DdlSexo.SelectedValue = ObjProspectos.Sexo.ToString
TxtColonia.Text = ObjProspectos.Colonia
TxtCodigoPostal.Text = ObjProspectos.CodigoPostal.ToString
DdlPaises.SelectedValue = ObjProspectos.CvePais.ToString
CargaEstados(DdlEstados, DdlPaises.SelectedValue.ToEntero)
DdlEstados.SelectedValue = ObjProspectos.CveEstado.ToString
CargaMunicipios(DdlMunicipios, DdlEstados.SelectedValue.ToEntero)
DdlMunicipios.SelectedValue = ObjProspectos.CveMunicipio.ToString
TxtFacebook.Text = ObjProspectos.Facebook
TxtTwitter.Text = ObjProspectos.Twitter
TxtTelefono.Text = ObjProspectos.Telefono
TxtCelular.Text = ObjProspectos.Celular
'TxtFax.Text = ObjProspectos.Fax
TxtCorreo.Text = ObjProspectos.Correo
TxtEmpresaNombre.Text = ObjProspectos.EmpresaNombre
TxtEmpresaGiro.Text = ObjProspectos.EmpresaGiro
TxtEmpresaSector.Text = ObjProspectos.EmpresaSector
TxtEmpresaPagina.Text = ObjProspectos.EmpresaPagina
TxtEmpresaCalle.Text = ObjProspectos.EmpresaCalle
TxtEmpresaNumero.Text = ObjProspectos.EmpresaNumero
TxtEmpresaColonia.Text = ObjProspectos.EmpresaColonia
TxtEmpresaCodigoPostal.Text = ObjProspectos.EmpresaCodigoPostal
DdlEmpresaPaises.SelectedValue = ObjProspectos.CveEmpresaPais.ToString
CargaEstados(DdlEmpresaEstados, DdlEmpresaPaises.SelectedValue.ToEntero)
DdlEmpresaEstados.SelectedValue = ObjProspectos.CveEmpresaEstado.ToString
CargaMunicipios(DdlEmpresaMunicipios, DdlEmpresaEstados.SelectedValue.ToEntero)
DdlEmpresaMunicipios.SelectedValue = ObjProspectos.CveEmpresaMunicipio.ToString
'cveEmpresaPais.Text = ObjProspectos.EmpresaPais
'TxtEmpresaMunicipio.Text = ObjProspectos.EmpresaMunicipio
'TxtEmpresaEstado.Text = ObjProspectos.EmpresaEstado
TxtEmpresaTelefono.Text = ObjProspectos.EmpresaTelefono
TxtEmpresaFax.Text = ObjProspectos.EmpresaFax
TxtEmpresaCorreo.Text = ObjProspectos.EmpresaCorreo
TxtEmpresaPuesto.Text = ObjProspectos.EmpresaPuesto
TxtEmpresaEspecialidad.Text = ObjProspectos.EmpresaEspecialidad
TxtFechaIngreso.Text = ObjProspectos.FechaIng.ToShortDateString
TxtFechaIngreso.Enabled = False
ImgFechaIngreso.Visible = False
LstEventos.Visible = False
HdnProspectoTipo.Value = ObjProspectos.CveProspectoTipo.ToString
'TxtCveEstatus.Text = ObjProspectos.CveEstatus
'TxtFechaIng.Text = ObjProspectos.FechaIng
'TxtCveUsuario.Text = ObjProspectos.CveUsuario
'TxtCveEmpresa.Text = ObjProspectos.CveEmpresa
'Cargar los Valores de las Caractertisticas
If ObjProspectos.GetProspectosValores(CveProspecto) Then
ViewState("DTProspectosValores") = ObjProspectos.DtResultados
End If
PnlBusquedaGral.Visible = False
If ObjProspectos.GetProspectosEventosAsistidos(CveProspecto, UsuarioActual.CveEmpresa) Then
GvE.DataSource = ObjProspectos.DtResultados
GvE.DataBind()
End If
'Permiso Eliminar
If UsuarioActual.TienePermisoProceso(78) Then BtnEliminar.Visible = True Else BtnEliminar.Visible = False
End If
End If
ObjProspectos.Dispose()
End Sub
Private Sub CargaEstados(ddl As DropDownList, CvePais As Integer)
ddl.DataSource = GlobalDTGralEstados(CvePais.ToString) : ddl.DataBind()
End Sub
Private Sub CargaMunicipios(ddl As DropDownList, CveEstado As Integer)
ddl.DataSource = GlobalDTGralMunicipios(CveEstado.ToString) : ddl.DataBind()
End Sub
Protected Sub BtnGuardar_Click(sender As Object, e As System.EventArgs) Handles BtnGuardar.Click
If DdlClasificacion.SelectedValue.ToEntero < 0 Then
Alert("Seleccione la clasificación, por favor", TipoMensaje.MsgAdvertencia)
Exit Sub
End If
Dim FechaIngreso As String = TxtFechaIngreso.Text.Trim
If FechaIngreso = "__/__/____" Then FechaIngreso = "-1"
If TxtFechaIngreso.Text.Trim = Now.ToShortDateString Then
FechaIngreso = Now.ToString
End If
Dim ObjProspectos As New ClsProspectos
If CveProspecto = -1 Then
If ObjProspectos.AddProspectos(-1, TxtApellidoPaterno.Text.Trim, TxtApellidoMaterno.Text.Trim,
TxtNombres.Text.Trim, TxtFechaNacimiento.Text.Trim.ToDate, TxtLugarNacimiento.Text.Trim, TxtRFC.Text.Trim, TxtNacionalidad.Text.Trim, DdlSexo.SelectedValue.ToEntero, TxtCalle.Text.Trim,
TxtNumero.Text.Trim, TxtNumeroInterior.Text.Trim, TxtEntreCalle1.Text.Trim, TxtEntreCalle2.Text.Trim, TxtColonia.Text.Trim, TxtCodigoPostal.Text.Trim.ToEntero, DdlMunicipios.SelectedValue.ToEntero,
TxtTelefono.Text.Trim, TxtCelular.Text, "", "", TxtCorreo.Text.Trim, "", TxtFacebook.Text.Trim, TxtTwitter.Text.Trim, -1, DdlClasificacion.SelectedValue.ToEntero, DdlEscolaridad.SelectedValue.ToEntero, TxtEmpresaNombre.Text.Trim, TxtEmpresaGiro.Text.Trim, TxtEmpresaSector.Text.Trim,
TxtEmpresaPagina.Text.Trim, TxtEmpresaCalle.Text.Trim, TxtEmpresaNumero.Text.Trim, TxtEmpresaColonia.Text.Trim, TxtEmpresaCodigoPostal.Text.Trim, DdlEmpresaMunicipios.SelectedValue.ToEntero,
TxtEmpresaTelefono.Text.Trim, TxtEmpresaFax.Text.Trim, TxtEmpresaCorreo.Text.Trim, TxtEmpresaPuesto.Text.Trim,
TxtEmpresaEspecialidad.Text.Trim, False, "", "", "", "", -1, "", -1, -1, -1, TxtIFE.Text.Trim, -1, -1, -1, "", 0, "", -1, 3, 1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, FechaIngreso) > 0 Then
ViewState("CveProspecto") = ObjProspectos.CveProspecto
If EventosTmp.Count > 0 Then
For Each entry As DictionaryEntry In EventosTmp
ObjProspectos.AddProspectosEventos(entry.Key.ToString.ToEntero, CveProspecto, UsuarioActual.CveUsuario)
Next
End If
Alert("El Prospecto se guardó correctamente.", TipoMensaje.MsgInformacion, "document.location.href=""/Prospectos/ProspectosEstructuras.aspx"";")
End If
Else
If ObjProspectos.UpdateProspectos(-1, TxtApellidoPaterno.Text.Trim, TxtApellidoMaterno.Text.Trim,
TxtNombres.Text.Trim, TxtFechaNacimiento.Text.Trim.ToDate, TxtLugarNacimiento.Text.Trim, TxtRFC.Text.Trim, TxtNacionalidad.Text.Trim, DdlSexo.SelectedValue.ToEntero, TxtCalle.Text.Trim,
TxtNumero.Text.Trim, TxtNumeroInterior.Text.Trim, TxtEntreCalle1.Text.Trim, TxtEntreCalle2.Text.Trim, TxtColonia.Text.Trim, TxtCodigoPostal.Text.Trim.ToEntero, DdlMunicipios.SelectedValue.ToEntero,
TxtTelefono.Text.Trim, TxtCelular.Text, "", "", TxtCorreo.Text.Trim, "", TxtFacebook.Text.Trim, TxtTwitter.Text.Trim, -1, DdlClasificacion.SelectedValue.ToEntero, DdlEscolaridad.SelectedValue.ToEntero, TxtEmpresaNombre.Text.Trim, TxtEmpresaGiro.Text.Trim, TxtEmpresaSector.Text.Trim,
TxtEmpresaPagina.Text.Trim, TxtEmpresaCalle.Text.Trim, TxtEmpresaNumero.Text.Trim, TxtEmpresaColonia.Text.Trim, TxtEmpresaCodigoPostal.Text.Trim, DdlEmpresaMunicipios.SelectedValue.ToEntero,
TxtEmpresaTelefono.Text.Trim, TxtEmpresaFax.Text.Trim, TxtEmpresaCorreo.Text.Trim, TxtEmpresaPuesto.Text.Trim,
TxtEmpresaEspecialidad.Text.Trim, False, "", "", "", "", -1, "", -1, -1, -1, TxtIFE.Text.Trim, -2, -1, -1, "", 0, "", -1, HdnProspectoTipo.Value.ToEntero, 1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveProspecto) Then
UpDatos.Update()
Alert("Los cambios se guardaron correctamente.", TipoMensaje.MsgInformacion, "document.location.href=""/Prospectos/ProspectosEstructuras.aspx"";")
End If
End If
ObjProspectos.Dispose()
End Sub
Protected Sub BtnEliminar_Click(sender As Object, e As System.EventArgs) Handles BtnEliminar.Click
Dim ObjProspectos As New ClsProspectos()
If ObjProspectos.RemoveProspectos(CveProspecto) Then
Alert("El Prospecto se Eliminó correctamente.", TipoMensaje.MsgInformacion, "document.location.href=""/Prospectos/CatProspectos.aspx""")
End If
ObjProspectos.Dispose()
End Sub
Protected Sub DdlPaises_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlPaises.SelectedIndexChanged
CargaEstados(DdlEstados, DdlPaises.SelectedValue.ToEntero)
UPPEstados.Update()
CargaMunicipios(DdlMunicipios, DdlEstados.SelectedValue.ToEntero)
UPPMunicipios.Update()
End Sub
Protected Sub DdlEstados_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlEstados.SelectedIndexChanged
CargaMunicipios(DdlMunicipios, DdlEstados.SelectedValue.ToEntero)
UPPMunicipios.Update()
End Sub
Protected Sub DdlEmpresaPaises_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlEmpresaPaises.SelectedIndexChanged
CargaEstados(DdlEmpresaEstados, DdlEmpresaPaises.SelectedValue.ToEntero)
UPPEmpresaEstados.Update()
CargaMunicipios(DdlEmpresaMunicipios, DdlEmpresaEstados.SelectedValue.ToEntero)
UPPEmpresaMunicipios.Update()
End Sub
Protected Sub DdlEmpresaEstados_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlEmpresaEstados.SelectedIndexChanged
CargaMunicipios(DdlEmpresaMunicipios, DdlEmpresaEstados.SelectedValue.ToEntero)
UPPEmpresaMunicipios.Update()
End Sub
Protected Sub BtnBusqueda_Click(sender As Object, e As EventArgs) Handles BtnBusqueda.Click
'Dim Prosp As New ClsProspectos
'Dim Busqueda As String = TxtBusqueda.Text.Trim.ToUpper
'If DdlOpcion.SelectedValue = "NOMBRE" Then Busqueda = String.Format("%{0}%", Busqueda)
'If Prosp.GetProspectosBusqueda("-1", "-1", "-1", Busqueda, "-1", -1, -1, -1, -1) Then
' GvBusq.DataSource = Prosp.DtResultados
'End If
Dim Prosp As New ClsProspectos
Dim Busqueda As String = TxtBusqueda.Text.Trim.ToUpper
Dim FechaNacimiento As String = "-1"
If Busqueda <> "" Then Busqueda = String.Format("%{0}%", Busqueda) Else Busqueda = "-1"
If TxtFechaNacB.Text <> String.Empty AndAlso IsDate(TxtFechaNacB.Text) Then FechaNacimiento = TxtFechaNacB.Text.Trim
If Prosp.GetProspectosBusqueda("-1", "-1", "-1", Busqueda, FechaNacimiento, -1, -1, -1, -1) Then
GvBusq.DataSource = Prosp.DtResultados
End If
Prosp.Dispose()
GvBusq.DataBind()
End Sub
Protected Sub LnkClave_Click(sender As Object, e As EventArgs)
Dim Gvr As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
TxtApellidoPaterno.Text = Gvr.DataKey("APaterno")
TxtApellidoMaterno.Text = Gvr.DataKey("AMaterno")
TxtNombres.Text = Gvr.DataKey("Nombres")
TxtFechaNacimiento.Text = Gvr.DataKey("FechaNacimiento")
TxtCalle.Text = Gvr.DataKey("Calle")
TxtNumero.Text = Gvr.DataKey("NumExterior")
TxtNumeroInterior.Text = Gvr.DataKey("NumInterior")
TxtColonia.Text = Gvr.DataKey("Colonia")
TxtCodigoPostal.Text = Gvr.DataKey("CP")
DdlSexo.SelectedValue = If(Gvr.DataKey("Sexo") = "H", "1", "0")
TxtIFE.Text = Gvr.DataKey("Clave")
DdlMunicipios.SelectedIndex = DdlMunicipios.Items.IndexOf(DdlMunicipios.Items.FindByText(Gvr.DataKey("PadronMunicipio")))
Alert("Información Cargada", TipoMensaje.MsgInformacion)
Me.cpeDesc.Collapsed = True
Me.cpeDesc.ClientState = "true"
UpDatos.Update()
End Sub
Protected Sub LnkApoyoAgregar_Click(sender As Object, e As EventArgs) Handles LnkApoyoAgregar.Click
If CveProspecto > 0 Then
Dim obj As New ClsProspectos
If obj.AddProspectosEventos(DdlProspectoEvento.SelectedValue.ToEntero, CveProspecto, UsuarioActual.CveUsuario) Then
GvE.DataSource = obj.DtResultados
GvE.DataBind()
End If
obj.Dispose()
Else
If Not EventosTmp.ContainsKey(DdlProspectoEvento.SelectedValue) Then
EventosTmp.Add(DdlProspectoEvento.SelectedValue, DdlProspectoEvento.SelectedItem.Text)
End If
LstEventos.DataSource = EventosTmp
LstEventos.DataBind()
End If
End Sub
End Class