Option Explicit On Option Strict On Imports Extensiones Partial Class Prospectos_ProspectosSIP Inherits ClsPaginas 'Confinguración Private Property DTProspectosValores As Data.DataTable Get Return CType(ViewState("DTProspectosValores"), Data.DataTable) End Get Set(value As Data.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 DdlProspectoClasificacion.DataSource = GlobalDTProspectosClasificaciones(UsuarioActual.CveEmpresa) : DdlProspectoClasificacion.DataBind() : DdlProspectoClasificacion.Items.Insert(0, New ListItem("Seleccione", "-1")) DdlCalificacion.DataSource = GlobalDTProspectosTipos(UsuarioActual.CveEmpresa) : DdlCalificacion.DataBind() : DdlCalificacion.Items.Insert(0, New ListItem("Seleccione", "-1")) DdlVendedor.DataSource = GlobalDTVendedores(UsuarioActual.CveEmpresa) : DdlVendedor.DataBind() : DdlVendedor.Items.Insert(0, New ListItem("Seleccione", "-1")) DdlEstatus.DataSource = GlobalDTProspectosEstatus(UsuarioActual.CveEmpresa) : DdlEstatus.DataBind() ' DdlEscolaridad.DataSource = GlobalDTEscolaridad(UsuarioActual.CveEmpresa) : DdlEscolaridad.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:" ImgAddObs.Attributes.Add("onclick", "javascript:$('#DivEventoBitacora').show(1000); PosicionaObjeto(this.id,'DivEventoBitacora');") ImgVerMapaParticular.Attributes.Add("onclick", "javascript:$('#DivMapaParticular').show(1000); PosicionaObjeto(this.id,'DivMapaParticular');") ImgVerMapaEmpresa.Attributes.Add("onclick", "javascript:$('#DivMapaEmpresa').show(1000); PosicionaObjeto(this.id,'DivMapaEmpresa');") HlEvento.Visible = True HlEvento.NavigateUrl = "/OI/PopUpAgenda.aspx?CveTipoEvento=2&CveProspecto=" & CveProspecto & "&TB_iframe=true&height=370&width=600;" CargaProspectoValoress(CveProspecto) CargaCaracteristicasClasificaciones() CargaImagenesEvento() 'cambiar el vendedor If UsuarioActual.TienePermisoProceso(89) Then DdlVendedor.Enabled = True Else DdlVendedor.Enabled = False End If Else CargaEstados(DdlEstados, 1) DdlEstados.SelectedValue = "26" CargaMunicipios(DdlMunicipios, DdlEstados.SelectedValue.ToEntero) DdlMunicipios.SelectedValue = "1919" CargaEstados(DdlEmpresaEstados, 1) DdlEmpresaEstados.SelectedValue = "26" CargaMunicipios(DdlEmpresaMunicipios, DdlEmpresaEstados.SelectedValue.ToEntero) DdlEmpresaMunicipios.SelectedValue = "1919" ViewState("CveProspecto") = -1 CargaProspectoValoress(CveProspecto) ImgAddObs.Visible = False End If End If End Sub 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 LtlProspectos.Text = "" & ObjProspectos.Nombres & " " & ObjProspectos.ApellidoMaterno & " " & ObjProspectos.ApellidoPaterno TxtCalle.Text = ObjProspectos.Calle TxtNumero.Text = ObjProspectos.Numero TxtEntreCalle1.Text = ObjProspectos.EntreCalle1 TxtColonia.Text = ObjProspectos.Colonia CargaEstados(DdlEstados, 1) DdlEstados.SelectedValue = ObjProspectos.CveEstado.ToString CargaMunicipios(DdlMunicipios, DdlEstados.SelectedValue.ToEntero) DdlMunicipios.SelectedValue = ObjProspectos.CveMunicipio.ToString DdlVendedor.SelectedValue = ObjProspectos.CveVendedor.ToString DdlCalificacion.SelectedValue = ObjProspectos.CveProspectoTipo.ToString DdlProspectoClasificacion.SelectedValue = ObjProspectos.CveProspectoClasificacion.ToString DdlEstatus.SelectedValue = ObjProspectos.CveProspectoEstatus.ToString TxtTelefono.Text = ObjProspectos.Telefono TxtCelular.Text = ObjProspectos.Celular TxtCorreo.Text = ObjProspectos.Correo CargaEstados(DdlEmpresaEstados, 1) DdlEmpresaEstados.SelectedValue = ObjProspectos.CveEmpresaEstado.ToString CargaMunicipios(DdlEmpresaMunicipios, DdlEmpresaEstados.SelectedValue.ToEntero) DdlEmpresaMunicipios.SelectedValue = ObjProspectos.CveEmpresaMunicipio.ToString DdlEstatus.SelectedValue = ObjProspectos.CveProspectoEstatus.ToString TxtEmpresaCalle.Text = ObjProspectos.EmpresaCalle TxtEmpresaNombre.Text = ObjProspectos.EmpresaNombre TxtEmpresaNumero.Text = ObjProspectos.EmpresaNumero TxtEmpresaColonia.Text = ObjProspectos.EmpresaColonia TxtEmpresaPuesto.Text = ObjProspectos.EmpresaPuesto TxtEmpresaTelefono.Text = ObjProspectos.EmpresaTelefono If ObjProspectos.Imagen1 <> "" Then ImgProspecto1.Visible = True : ImgProspecto1.ImageUrl = String.Format("/Empresas/{0}/Prospectos/Imagenes/{1}-1.jpg", ObjProspectos.CveEmpresa, CveProspecto) If ObjProspectos.Imagen2 <> "" Then ImgProspecto2.Visible = True : ImgProspecto2.ImageUrl = String.Format("/Empresas/{0}/Prospectos/Imagenes/{1}-2.jpg", ObjProspectos.CveEmpresa, CveProspecto) If ObjProspectos.Imagen3 <> "" Then ImgProspecto3.Visible = True : ImgProspecto3.ImageUrl = String.Format("/Empresas/{0}/Prospectos/Imagenes/{1}-3.jpg", ObjProspectos.CveEmpresa, CveProspecto) If ObjProspectos.Imagen4 <> "" Then ImgProspecto4.Visible = True : ImgProspecto4.ImageUrl = String.Format("/Empresas/{0}/Prospectos/Imagenes/{1}-4.jpg", ObjProspectos.CveEmpresa, CveProspecto) If ObjProspectos.Imagen5 <> "" Then ImgProspecto5.Visible = True : ImgProspecto5.ImageUrl = String.Format("/Empresas/{0}/Prospectos/Imagenes/{1}-5.jpg", ObjProspectos.CveEmpresa, CveProspecto) 'Permiso Eliminar If UsuarioActual.TienePermisoProceso(78) Then BtnEliminar.Visible = True Else BtnEliminar.Visible = False CargaEventoBitacora() End If End If ObjProspectos.Dispose() End Sub Private Sub CargaEstados(ddl As DropDownList, CvePais As Integer) ddl.DataSource = GlobalDTGralEstados("-1", CvePais) : ddl.DataBind() End Sub Private Sub CargaMunicipios(ddl As DropDownList, CveEstado As Integer) ddl.DataSource = GlobalDTGralMunicipios("-1", CveEstado) : ddl.DataBind() End Sub Private Sub CargaCoordinadores(ddl As DropDownList, CveSupervisor As Integer) ddl.DataSource = GlobalDTProspectosCoordinadores(CveSupervisor, -1) : ddl.DataBind() End Sub Protected Sub BtnGuardar_Click(sender As Object, e As System.EventArgs) Handles BtnGuardar.Click Dim ObjProspectos As New ClsProspectos If CveProspecto = -1 Then If ObjProspectos.AddProspectos(-1, TxtApellidoPaterno.Text.Trim, TxtApellidoMaterno.Text.Trim, TxtNombres.Text.Trim, Now, "", "", "", 0, TxtCalle.Text.Trim, TxtNumero.Text.Trim, "", TxtEntreCalle1.Text.Trim, "", TxtColonia.Text.Trim, -1, DdlMunicipios.SelectedValue.ToEntero, TxtTelefono.Text.Trim, TxtCelular.Text.Trim, "", "", TxtCorreo.Text.Trim, "", "", "", -1, DdlProspectoClasificacion.SelectedValue.ToEntero, -1, TxtEmpresaNombre.Text.Trim, "", "", "", TxtEmpresaCalle.Text.Trim, TxtEmpresaNumero.Text.Trim, TxtEmpresaColonia.Text.Trim, "", DdlEmpresaMunicipios.SelectedValue.ToEntero, TxtEmpresaTelefono.Text.Trim, "", "", TxtEmpresaPuesto.Text.Trim, "", False, "", "", "", "", -1, "", -1, -1, -1, "", -1, 0, -1, "", 0, "", DdlVendedor.SelectedValue.ToEntero, DdlCalificacion.SelectedValue.ToEntero, DdlEstatus.SelectedValue.ToEntero, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) > 0 Then ViewState("CveProspecto") = ObjProspectos.CveProspecto Alert("El Prospecto se guardó correctamente.", TipoMensaje.MsgInformacion, "document.location.href=""/Inicio.aspx"";") End If Else If ObjProspectos.UpdateProspectos(-1, TxtApellidoPaterno.Text.Trim, TxtApellidoMaterno.Text.Trim, TxtNombres.Text.Trim, Now, "", "", "", 0, TxtCalle.Text.Trim, TxtNumero.Text.Trim, "", TxtEntreCalle1.Text.Trim, "", TxtColonia.Text.Trim, -1.ToEntero, DdlMunicipios.SelectedValue.ToEntero, TxtTelefono.Text.Trim, TxtCelular.Text.Trim, "", "", TxtCorreo.Text.Trim, "", "", "", -1, DdlProspectoClasificacion.SelectedValue.ToEntero, -1, TxtEmpresaNombre.Text.Trim, "", "", "", TxtEmpresaCalle.Text.Trim, TxtEmpresaNumero.Text.Trim, TxtEmpresaColonia.Text.Trim, "", DdlEmpresaMunicipios.SelectedValue.ToEntero, TxtEmpresaTelefono.Text.Trim, "", "", TxtEmpresaPuesto.Text.Trim, "", False, "", "", "", "", -1, "", -1, -1, -1, "", -1, 0, 1, "", 0, "", DdlVendedor.SelectedValue.ToEntero, DdlCalificacion.SelectedValue.ToEntero, DdlEstatus.SelectedValue.ToEntero, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveProspecto) Then UpDatos.Update() GuardarCaracteristicas() Alert("Los cambios se guardaron correctamente.", TipoMensaje.MsgInformacion) End If End If ObjProspectos.Dispose() End Sub Protected Sub GuardarCaracteristicas() Dim objProspectosValores As New ClsProspectos For Each DR As GridViewRow In GvCaracteristicaClasificaciones.Rows For Each DR_CaracteristicaTipo As GridViewRow In DR.FCGridView("GvCaracteristicasTipos").Rows For Each DR_Caracteristica As GridViewRow In DR_CaracteristicaTipo.FCGridView("GvCaracteristicas").Rows Dim CveCaracteristicaOpcion As Integer = -1 Dim CveValor As Integer = DR_Caracteristica.FCHiddenField("HdnCveValor").Value.ToEntero Dim Valor As String = DR_Caracteristica.FCTextBox("TxtValor").Text.Trim Dim CveCaracteristica As Integer = DR_Caracteristica.FCHiddenField("HdnCveCaracteristica").Value.ToEntero Select Case DR_Caracteristica.FCHiddenField("HdnEsOpcion").Value Case "1" 'Listado o DropDownList CveCaracteristicaOpcion = DR_Caracteristica.FCDropDownList("DdlOpcion").SelectedValue.ToEntero Case "2" 'Radio o RadioButtonList CveCaracteristicaOpcion = DR_Caracteristica.FCRadioButtonList("RbOpcion").SelectedValue.ToEntero End Select If CveValor = -1 Then objProspectosValores.AddProspectosValores(CveProspecto, CveCaracteristica, CveCaracteristicaOpcion, If(Valor = "", "-1", Valor), UsuarioActual.CveUsuario) Else objProspectosValores.UpdateProspectosValores(CveProspecto, CveCaracteristica, CveCaracteristicaOpcion, If(Valor = "", "-1", Valor), UsuarioActual.CveUsuario, CveValor) End If Next Next Next objProspectosValores.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) End If ObjProspectos.Dispose() 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 DdlEmpresaEstados_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlEmpresaEstados.SelectedIndexChanged CargaMunicipios(DdlEmpresaMunicipios, DdlEmpresaEstados.SelectedValue.ToEntero) UPPEmpresaMunicipios.Update() End Sub #Region "E V E N T O - B I T A C O R A" Protected Sub GVEventoBitacora_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GVEventoBitacora.RowDataBound If e.Row.RowType = DataControlRowType.DataRow Then If e.Row.RowIndex = 0 Then e.Row.Cells(0).Width = Unit.Pixel(200) e.Row.Cells(1).Width = Unit.Pixel(200) e.Row.Cells(2).Width = Unit.Pixel(100) e.Row.Cells(3).Width = Unit.Pixel(500) End If e.Row.Cells(2).HorizontalAlign = HorizontalAlign.Left End If End Sub Protected Sub BtnGuardarEventoBitacora_Click(sender As Object, e As EventArgs) Handles BtnGuardarEventoBitacora.Click Dim ObjEventoBitacora As New ClsOIEventos If ObjEventoBitacora.AddEventoBitacora(TxtEventoDescripcion.Text.Trim, "", -1, -1, CveProspecto, -1, -1, -1, -1, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then GVEventoBitacora.DataSource = ObjEventoBitacora.DtResultados TxtEventoDescripcion.Text = "" Alert("La bitácora/observación se guardó correctamente", TipoMensaje.MsgInformacion) End If ObjEventoBitacora.Dispose() GVEventoBitacora.DataBind() UPEventoBitacora.Update() CargaEventoBitacora() End Sub Private Sub CargaEventoBitacora() Dim ObjEventoBitacora As New ClsOIEventos() If ObjEventoBitacora.GetAgendaBitacora(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveProspecto:=CveProspecto) Then GVEventoBitacora.DataSource = ObjEventoBitacora.DtResultados.FiltraParametros("CveTipoEvento = 6 OR CveTipoEvento = 2") Else GVEventoBitacora.DataSource = Nothing End If GVEventoBitacora.DataBind() End Sub #End Region #Region "D A T O S - T E C N I C O S " Protected Sub CargaCaracteristicasClasificaciones() Dim objClasificaciones As New ClsProspectos If objClasificaciones.GetCaracteristicasClasificaciones(UsuarioActual.CveEmpresa) Then GvCaracteristicaClasificaciones.DataSource = objClasificaciones.DtResultados GvCaracteristicaClasificaciones.DataBind() End If objClasificaciones.Dispose() End Sub Protected Sub CargaProspectoValoress(CveProspecto As Integer) Dim Prosp As New ClsProspectos If Prosp.GetProspectoValores(CveProspecto, UsuarioActual.CveEmpresa) Then DTProspectosValores = Prosp.DtResultados End If Prosp.Dispose() End Sub Protected Sub GvCaracteristicaClasificaciones_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvCaracteristicaClasificaciones.RowDataBound If e.Row.RowType = DataControlRowType.DataRow Then If e.Row.DBCampo("CveCaracteristicaClasificacion").ToEntero > 1 Then e.Row.FCLabel("LblCaracteristicaClasificacion").CssClass = "CaracteristicaClasificacion" End If With e.Row.FCGridView("GvCaracteristicasTipos") .DataSource = DTProspectosValores.FiltraParametros(String.Format("CveCaracteristicaClasificacion = {0}", e.Row.DBCampo("CveCaracteristicaClasificacion")), DistinctColumns:={"CveCaracteristicaTipo", "CaracteristicaTipo"}) .DataBind() End With 'Dim objCaracteristicasTipos As New ClsProspectos 'If objCaracteristicasTipos.GetTiposCaracteristicas(UsuarioActual.CveEmpresa) Then ' With e.Row.FCGridView("GvCaracteristicasTipos") ' .DataSource = objCaracteristicasTipos.DtResultados.FiltraParametros("CveCaracteristicaClasificacion = " + e.Row.DBCampo("CveCaracteristicaClasificacion")) ' .DataBind() ' End With 'End If 'objCaracteristicasTipos.Dispose() End If End Sub Protected Sub GvCaracteristicasTipos_RowDataBound(sender As Object, e As GridViewRowEventArgs) If e.Row.RowType = DataControlRowType.DataRow Then If e.Row.DBCampo("CveCaracteristicaTipo").ToEntero > 1 Then e.Row.FCLabel("LblCaracteristicaTipo").CssClass = "CaracteristicaTipo" End If With e.Row.FCGridView("GvCaracteristicas") .DataSource = DTProspectosValores.FiltraParametros(String.Format("CveCaracteristicaTipo = {0}", e.Row.DBCampo("CveCaracteristicaTipo")), DistinctColumns:={"CveCaracteristica", "Caracteristica", "EsOpcion", "CveValor", "CveOpcion", "Valor"}) .DataBind() End With 'Dim objCaracteristicas As New ClsProspectos 'If objCaracteristicas.GetCaracteristicas(UsuarioActual.CveEmpresa) Then ' With e.Row.FCGridView("GvCaracteristicas") ' .DataSource = objCaracteristicas.DtResultados.FiltraParametros("Estatus = 'Activo' and CveCaracteristicaTipo = " + e.Row.DBCampo("CveCaracteristicaTipo")) ' .DataBind() ' End With 'End If 'objCaracteristicas.Dispose() End If End Sub Protected Sub GvCaracteristicas_RowDataBound(sender As Object, e As GridViewRowEventArgs) If e.Row.RowType = DataControlRowType.DataRow Then Dim EsOpcion As Integer = e.Row.FCHiddenField("HdnEsOpcion").Value.ToEntero Dim CveCaracteristica As Integer = e.Row.DBCampo("CveCaracteristica").ToEntero Dim CveOpcion As Integer = If(e.Row.DBCampo("CveOpcion") <> "", e.Row.DBCampo("CveOpcion").ToEntero, -1) Dim CveValor As Integer = If(e.Row.DBCampo("CveValor") <> "", e.Row.DBCampo("CveValor").ToEntero, -1) Dim Valor As String = If(e.Row.DBCampo("Valor") <> "", e.Row.DBCampo("Valor"), "") e.Row.FCHiddenField("HdnCveValor").Value = CveValor.ToString Select Case EsOpcion Case 0, 4 '---------------------------------------------------------------Texto, Multiline With e.Row.FCTextBox("TxtValor") .Text = Valor .Visible = True If EsOpcion = 4 Then .Rows = 3 .TextMode = TextBoxMode.MultiLine End If End With Case 1, 2 '---------------------------------------------------------------DropDownList, Radios Dim objOpciones As New ClsProspectos If objOpciones.GetCaracteristicasOpciones(CveCaracteristica, UsuarioActual.CveEmpresa) Then If EsOpcion = 1 Then '---------------------DDL With e.Row.FCDropDownList("DdlOpcion") .Visible = True .DataSource = objOpciones.DtResultados.FiltraParametros("Estatus = 'Activo'") .DataBind() .Items.Insert(0, New ListItem("Seleccione uno", "-1")) .SelectedValue = CveOpcion.ToString End With ElseIf EsOpcion = 2 Then '---------------------RB With e.Row.FCRadioButtonList("RbOpcion") .Visible = True .DataSource = objOpciones.DtResultados.FiltraParametros("Estatus = 'Activo'") .DataBind() If CveOpcion > 0 Then .SelectedValue = CveOpcion.ToString End If End With End If End If objOpciones.Dispose() Case 3 '---------------------------------------------------------------F E C H A With e.Row.FCTextBox("TxtValor") If Valor <> "" Then .Text = Valor End If .Visible = True .Width = New Unit(80) End With e.Row.FCImageButton("ImgTxtValor").Visible = True e.Row.FCMaskedEditExtender("MEETxtValor").Enabled = True e.Row.FCCalendarExtender("CETxtValor").Enabled = True End Select End If End Sub #End Region Protected Sub LtlEventoEstatus_Click(sender As Object, e As EventArgs) Dim Lnk As LinkButton = CType(sender, LinkButton) Dim OI As New ClsOIEventos If OI.UpdateEstatusEvento(2, -1, Lnk.CommandArgument.ToString.ToEntero, UsuarioActual.CveUsuario) Then Alert("Agenda Concluida", TipoMensaje.MsgInformacion) End If OI.Dispose() CargaEventoBitacora() End Sub Protected Sub LbEventoEstatusRevisar_Click(sender As Object, e As EventArgs) Dim Lnk As LinkButton = CType(sender, LinkButton) Dim OI As New ClsOIEventos If OI.UpdateEstatusEvento(3, -1, Lnk.CommandArgument.ToString.ToEntero, UsuarioActual.CveUsuario) Then Alert("Agenda Revisada", TipoMensaje.MsgInformacion) End If OI.Dispose() CargaEventoBitacora() End Sub #Region " F O T O G R A F I A S" Protected Sub CargaImagenesEvento() Dim ObjEventosAgenda As New ClsOIEventos If ObjEventosAgenda.GetEventos(-1, -1, -1, "-1", "-1", -1, -1, -1, -1, -1, -1, "-1", -1, -1, CveProspecto, -1, -1, -1, -1, -1, -1, -1, UsuarioActual.CveUsuario, -1, -1, UsuarioActual.CveEmpresa) Then GVEventoAgenda.DataSource = ObjEventosAgenda.DtResultados.FiltraParametros("Imagen1 <> '' OR Imagen2 <> '' OR Imagen3 <> ''") GVEventoAgenda.DataBind() End If ObjEventosAgenda.Dispose() End Sub Protected Sub GvEventoAgenda_RowDataBound(sender As Object, e As GridViewRowEventArgs) If e.Row.RowType = DataControlRowType.DataRow Then If e.Row.RowIndex = 0 Then e.Row.Cells(0).Width = Unit.Pixel(200) End If End If End Sub #End Region End Class