Files
SIG/GPS/CatProveedoresComunicacionCuentas.aspx.vb
JORGE LUIS CAUDILLO ESPARZA c35cf91883 Commit inicial Ventas Productivo
2019-08-14 16:40:54 -07:00

321 lines
14 KiB
VB.net

Imports Extensiones
Imports System.Data
Partial Class GPS_CatProveedoresComunicacionCuentas
Inherits ClsPaginas
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
If UsuarioActual.Empresa.Funcionalidad(541) = "1" Then
PnlPlanDatos.Visible = False
PnlNumero.Visible = False
PnlResguardante.Visible = True
Dim ObjGps As New ClsGPS()
ObjGps.GetResGuardantesSim(UsuarioActual.CveEmpresa)
DDlResguardante.DataSource = ObjGps.DtResultados
ObjGps.Dispose()
DDlResguardante.DataBind()
DDlResguardante.Items.Insert(0, New ListItem("Seleccione", "-1"))
Else
PnlPlanDatos.Visible = True
PnlNumero.Visible = True
PnlResguardante.Visible = False
End If
CargaDdlProveedoresComunicacion()
CargaDdlClientes()
CargaDdlCompañia()
CargaDatos()
End If
End Sub
Private Sub CargaDatos()
Dim ObjGps As New ClsGPS()
Dim CveProveedorComunicacionCuenta As Integer = DdlFiltroCompañia.SelectedValue.ToEntero()
Dim CveCliente As Integer = DdlFiltroCliente.SelectedValue.ToEntero()
Dim CvePlanDato As Integer = DdlFiltroPlan.SelectedValue.ToEntero()
If ObjGps.ProveedoresComunicacionCuentasGet(CveProveedorComunicacionCuenta, UsuarioActual.CveEmpresa, CveCliente, CvePlanDato) Then
GvProveedorComunicacionCuenta.DataSource = ObjGps.DtResultados
GvProveedorComunicacionCuenta.DataBind()
End If
ObjGps.Dispose()
UpDatos.Update()
End Sub
#Region "Filtros"
Private Sub CargaDdlClientes()
Dim ObjGps As New ClsClientes()
If ObjGps.GetClientes(-1, "-1", "-1", "-1", "-1", "-1", "-1", -1, UsuarioActual.CveEmpresa, -1, -1, -1) Then
DdlFiltroCliente.DataSource = ObjGps.DtResultados
DdlFiltroCliente.DataBind()
End If
DdlFiltroCliente.Items.Insert(0, New ListItem("Seleccione", "-1"))
ObjGps.Dispose()
UpDatos.Update()
End Sub
Private Sub CargaDdlCompañia()
Dim ObjGps As New ClsGPS()
If ObjGps.DdlProveedoresComunicacionGet() Then
DdlFiltroCompañia.DataSource = ObjGps.DtResultados
DdlFiltroCompañia.DataBind()
End If
DdlFiltroCompañia.Items.Insert(0, New ListItem("Seleccione", "-1"))
ObjGps.Dispose()
UpDatos.Update()
DdlFiltroCompañia.SelectedValue = "-1"
CargaDdlPlan()
End Sub
Protected Sub DdlFiltroCompañia_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlFiltroCompañia.SelectedIndexChanged
CargaDdlPlan()
End Sub
Private Sub CargaDdlPlan()
Dim ObjGps As New ClsGPS()
If ObjGps.DdlPlanDatosGet(UsuarioActual.CveEmpresa, DdlFiltroCompañia.SelectedValue.ToEntero()) Then
DdlFiltroPlan.DataSource = ObjGps.DtResultados
DdlFiltroPlan.DataBind()
End If
DdlFiltroPlan.Items.Insert(0, New ListItem("Seleccione", "-1"))
ObjGps.Dispose()
UpDatos.Update()
End Sub
#End Region
Private Sub CargaDdlProveedoresComunicacion()
Dim ObjGps As New ClsGPS()
If ObjGps.DdlProveedoresComunicacionGet() Then
DdlProveedorComunicacion.DataSource = ObjGps.DtResultados
DdlProveedorComunicacion.DataBind()
End If
DdlProveedorComunicacion.Items.Insert(0, New ListItem("Seleccione", "-1"))
ObjGps.Dispose()
UpDatos.Update()
End Sub
Protected Sub DdlProveedorComunicacion_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlProveedorComunicacion.SelectedIndexChanged
CargaDdlPlanDatos()
End Sub
Private Sub CargaDdlPlanDatos()
If DdlProveedorComunicacion.SelectedValue = "-1" Then
DdlPlanDatos.Items.Clear()
DdlPlanDatos.Items.Insert(0, New ListItem("Seleccione", "-1"))
Else
Dim ObjGps As New ClsGPS()
If ObjGps.DdlPlanDatosGet(UsuarioActual.CveEmpresa, DdlProveedorComunicacion.SelectedValue.ToEntero) Then
DdlPlanDatos.DataSource = ObjGps.DtResultados
DdlPlanDatos.DataBind()
End If
DdlPlanDatos.Items.Insert(0, New ListItem("Seleccione", "-1"))
ObjGps.Dispose()
UpDatos.Update()
End If
End Sub
Private Sub BtnAgregarProveedorComunicacionCuenta_Click(sender As Object, e As EventArgs) Handles BtnAgregarProveedorComunicacionCuenta.Click
Dim ObjGps As New ClsGPS
Dim Estatus = 0
Dim numeroTelefono As String = TxtNumeroTelefono.Text.Replace(" ", "").Replace("(", "").Replace(")", "").Replace("-", "").Replace("_", "")
Dim Imei As String = TxtImei.Text
Dim CveUsuarioResguardante As Integer = DDlResguardante.SelectedValue.ToEntero()
If chkEstatus.Checked Then Estatus = 1
If HdnModalidad.Value = "A" Then
If UsuarioActual.Empresa.Funcionalidad(541) = "1" Then
Estatus = 0
End If
If ObjGps.ProveedoresComunicacionCuentasAdd(DdlProveedorComunicacion.SelectedValue, DdlPlanDatos.SelectedValue, UsuarioActual.CveUsuario, TxtIP.Text, TxtSSID.Text, numeroTelefono, Estatus, UsuarioActual.CveEmpresa, Imei, CveUsuarioResguardante) Then
CargaDatos()
Alert("Agregado Correctamente.", TipoMensaje.MsgInformacion)
End If
ElseIf HdnModalidad.Value = "U" Then
If UsuarioActual.Empresa.Funcionalidad(541) = "1" And Estatus = 0 And Imei.Trim().Length > 0 Then
envirCorreoActivacion()
Estatus = 1
End If
If ObjGps.ProveedoresComunicacionCuentasUpdate(HdnID.Value, DdlProveedorComunicacion.SelectedValue, DdlPlanDatos.SelectedValue, UsuarioActual.CveUsuario, TxtIP.Text, TxtSSID.Text, numeroTelefono, Estatus, UsuarioActual.CveEmpresa, Imei, CveUsuarioResguardante) Then
CargaDatos()
Alert("Actualizado Correctamente.", TipoMensaje.MsgInformacion)
End If
End If
RegistraScript(String.Format("$('#{0}').modal('hide');", "divAddProveedorComunicacionCuenta"))
ObjGps.Dispose()
UpDatos.Update()
End Sub
Public Sub Edit_Click(sender As Object, e As EventArgs)
Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
If UsuarioActual.Empresa.Funcionalidad(541) = "1" Then
PnlNumero.Visible = False
PnlPlanDatos.Visible = False
Else
PnlNumero.Visible = True
End If
TxtSSID.Enabled = True
TxtImei.Enabled = True
DdlProveedorComunicacion.Enabled = True
LnkActivar.Visible = False
LnkReMailActiv.Visible = False
HdnModalidad.Value = "U"
HdnID.Value = GvRow.DataKey("CveProveedorComunicacionCuenta")
UpDatos.Update()
BtnAgregarProveedorComunicacionCuenta.Text = "Actualizar"
myModalLabel.InnerText = "Actualizar Linea de Teléfono"
DdlProveedorComunicacion.SelectedValueExist(GvRow.DataKey("CveProveedorComunicacion"))
CargaDdlPlanDatos()
DdlPlanDatos.SelectedValueExist(GvRow.DataKey("CvePlanDato"))
TxtIP.Text = GvRow.DataKey("IP")
TxtSSID.Text = GvRow.DataKey("SSID")
TxtNumeroTelefono.Text = GvRow.DataKey("NumeroTelefono")
chkEstatus.Checked = CBool(GvRow.DataKey("Estatus"))
UpAddProveedorComunicacionCuenta.Update()
RegistraScript(String.Format("$('#{0}').modal('show');", "divAddProveedorComunicacionCuenta"))
DDlResguardante.Enabled = False
If UsuarioActual.Empresa.Funcionalidad(541) = "1" Then
PnlImei.Visible = True
divEstatus.Visible = False
DDlResguardante.SelectedValueExist(GvRow.DataKey("CveUsuarioResguardante"))
TxtImei.Text = GvRow.DataKey("Imei")
PnlPlanDatos.Visible = True
If chkEstatus.Checked Then
If TxtImei.Text.Length = 0 Then TxtImei.Text = "-"
TxtSSID.Enabled = False
TxtImei.Enabled = False
DdlProveedorComunicacion.Enabled = False
LnkReMailActiv.Visible = True
PnlNumero.Visible = True
Else
LnkActivar.Visible = TxtImei.Text.Length > 0
End If
Else
PnlImei.Visible = False
divEstatus.Visible = True
End If
End Sub
Public Sub Agregar()
HdnModalidad.Value = "A"
LnkActivar.Visible = False
If UsuarioActual.Empresa.Funcionalidad(541) = "1" Then
PnlNumero.Visible = False
PnlPlanDatos.Visible = False
Else
PnlNumero.Visible = True
End If
UpDatos.Update()
DdlProveedorComunicacion.Enabled = True
TxtSSID.Enabled = True
TxtImei.Enabled = True
PnlImei.Visible = False
LnkReMailActiv.Visible = False
BtnAgregarProveedorComunicacionCuenta.Text = "Agregar"
myModalLabel.InnerText = "Agregar Linea de Teléfono"
TxtIP.Text = ""
TxtSSID.Text = ""
TxtNumeroTelefono.Text = ""
CargaDdlProveedoresComunicacion()
DDlResguardante.Enabled = True
CargaDdlPlanDatos()
chkEstatus.Checked = True
divEstatus.Visible = False
UpAddProveedorComunicacionCuenta.Update()
RegistraScript(String.Format("$('#{0}').modal('show');", "divAddProveedorComunicacionCuenta"))
End Sub
Public Sub Delete_Click(sender As Object, e As EventArgs)
Dim ObjGps As New ClsGPS()
Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
HdnID.Value = GvRow.DataKey("CveProveedorComunicacionCuenta")
UpDatos.Update()
If ObjGps.ProveedoresComunicacionCuentasRemove(HdnID.Value) Then
CargaDatos()
End If
Alert("Eliminado Correctamente.", TipoMensaje.MsgInformacion)
ObjGps.Dispose()
UpDatos.Update()
End Sub
Private Sub LnkProveedor1_Click(sender As Object, e As EventArgs) Handles LnkProveedor1.Click
Agregar()
End Sub
Private Sub GvProveedorComunicacionCuenta_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvProveedorComunicacionCuenta.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
If e.Row.DBCampo("Estatus") = True Then
e.Row.FCLabel("LblEstatus").Text = "Activo"
e.Row.FCLabel("LblEstatus").ForeColor = Drawing.Color.Green
Else
e.Row.FCLabel("LblEstatus").Text = "Inactivo"
e.Row.FCLabel("LblEstatus").ForeColor = Drawing.Color.Red
End If
End If
End Sub
Protected Sub LbFiltrar_Click(sender As Object, e As EventArgs)
CargaDatos()
End Sub
Private Sub EnvirCorreoActivacion()
Dim Bodycorreo As New StringBuilder()
Bodycorreo.AppendLine("Hola, buen día. Espero que se encuentren muy bien. <br>")
Bodycorreo.AppendLine("A traves del presente solicitamos la activación del siguiente SIM: <br><br>")
Bodycorreo.AppendLine($"SSID: {TxtSSID.Text } <br>")
Bodycorreo.AppendLine($"IMEI: {TxtImei.Text } <br> ")
Bodycorreo.AppendLine($"Plan de datos: {DdlPlanDatos.SelectedItem.Text } <br> <br>")
Bodycorreo.AppendLine("Espero correo de confirmación. <br> <br>")
Bodycorreo.AppendLine("")
Bodycorreo.AppendLine("")
Bodycorreo.AppendLine("Gracias, <br>")
Bodycorreo.AppendLine("Quedamos a sus ordenes, <br>")
Bodycorreo.AppendLine("Saludos. <br>")
Dim Asunto As String = "Activación SIM"
Dim ObjMail As New ClsSisMail()
',
Dim ObjEmpresa As New ClsSisEmpresas()
Dim oEm As New Empresa
If ObjEmpresa.GetEmpresas(2, "-1", "-1", "-1", "-1") Then
oEm = ObjEmpresa.Empresa
End If
ObjEmpresa.Dispose()
Dim ObjGPS As New ClsGPS()
ObjGPS.ProveedorComunicacion_Get()
Dim DT As DataTable = ObjGPS.DtResultados.FiltraParametros(String.Format("CveProveedorComunicacion= {0}", DdlProveedorComunicacion.SelectedValue))
Dim Correo As String = "julian@adssistemas.mx;paola@adssistemas.mx;julian@localizacionprecisa.com;paola@localizacionprecisa.com;" & UsuarioActual.Usuario
If DT.Rows.Count > 0 Then
Correo &= String.Format(";{0}", DT.Rows(0)("Correo").ToString())
End If
ObjGPS.Dispose()
ObjMail.SendMail(oEm, Correo, Asunto, Bodycorreo.ToString(), "")
End Sub
Protected Sub LnkActivar_Click(sender As Object, e As EventArgs)
envirCorreoActivacion()
Dim ObjGps As New ClsGPS
Dim Estatus = 1
Dim numeroTelefono As String = TxtNumeroTelefono.Text.Replace(" ", "").Replace("(", "").Replace(")", "").Replace("-", "").Replace("_", "")
Dim Imei As String = TxtImei.Text
Dim CveUsuarioResguardante As Integer = DDlResguardante.SelectedValue.ToEntero()
If ObjGps.ProveedoresComunicacionCuentasUpdate(HdnID.Value, DdlProveedorComunicacion.SelectedValue, DdlPlanDatos.SelectedValue, UsuarioActual.CveUsuario, TxtIP.Text, TxtSSID.Text, numeroTelefono, Estatus, UsuarioActual.CveEmpresa, Imei, CveUsuarioResguardante) Then
CargaDatos()
Alert("Actualizado Correctamente.", TipoMensaje.MsgInformacion)
End If
RegistraScript(String.Format("$('#{0}').modal('hide');", "divAddProveedorComunicacionCuenta"))
ObjGps.Dispose()
End Sub
Protected Sub LnkReMailActiv_Click(sender As Object, e As EventArgs)
envirCorreoActivacion()
Alert("Solicitud de reactivacion enviada.")
End Sub
End Class