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

342 lines
18 KiB
VB.net

Option Explicit On
Option Strict On
Imports Extensiones
Imports System.Data
Partial Class Prospectos_ProspectosRedes
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
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"))
DdlCoordinador.DataSource = GlobalDTProspectosCoordinadores(-1, UsuarioActual.CveEmpresa) : DdlCoordinador.DataBind() : DdlCoordinador.Items.Insert(0, New ListItem("Seleccione", "-1"))
'codigo Comentado, por el objeto UsuarioActual
'If UsuarioActual.CveCoordinador > 0 Then
' DdlCoordinador.SelectedValue = UsuarioActual.CveCoordinador.ToString
' DdlCoordinador.Enabled = False
'End If
'HdnCveProspectoPadre.Value = UsuarioActual.CveProspecto.ToString
'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
<Web.Services.WebMethod()> <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
HdnCveProspectoPadre.Value = ObjProspectos.CveProspectoPadre.ToString
TxtReporta.Text = ObjProspectos.ProspectoPadre
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
ImgAddObs.Visible = True
ImgAddAgenda.Visible = True
ImgAddObs.Attributes.Add("onclick", "javascript:$get('divObs').style.display=''; PosicionaObjeto(this.id,'divObs');")
ImgAddAgenda.Attributes.Add("onclick", "javascript:$get('divAgenda').style.display=''; PosicionaObjeto(this.id,'divAgenda');")
DdlCoordinador.SelectedValue = ObjProspectos.CveCoordinador.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
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
'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 HdnCveProspectoPadre.Value.ToEntero > 0 Then
Dim RetValue As Integer = 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, "", HdnCveProspectoPadre.Value.ToEntero, DdlCoordinador.SelectedValue.ToEntero, -1, TxtIFE.Text.Trim, -1, -1, -1, "", 0, "", -1, 1, 1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, FechaIngreso)
If RetValue > 0 Then
ViewState("CveProspecto") = ObjProspectos.CveProspecto
Alert("El Prospecto se guardó correctamente.", TipoMensaje.MsgInformacion, "document.location.href=""/Prospectos/ProspectosRedes.aspx"";")
Else
If RetValue = -2 Then
Alert("No se puede duplicar el campo IFE", TipoMensaje.MsgError)
End If
End If
Else
Alert("Selecione a quién reporta(superior).", TipoMensaje.MsgAdvertencia)
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, "", HdnCveProspectoPadre.Value.ToEntero, DdlCoordinador.SelectedValue.ToEntero, -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/ProspectosRedes.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
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
End Class