client/Reportes/OperPreoAdminDetalle.vb

309 lines
14 KiB
VB.net

Imports System.Text.RegularExpressions
Public Class OperPreoAdminDetalle
Dim _sTransaccion As String
Dim _IdTransaccion As Integer
Dim _IdProducto As Integer
Dim _IdAlarma As Integer
Dim _IdPatron As Integer
Public Sub New(ByVal sTransaccion As String, ByVal IdTransaccion As Integer, ByVal IdProducto As Integer, IdAlarma As Integer, IdPatron As Integer)
' Llamada necesaria para el diseñador.
InitializeComponent()
''Variables de la pantalla anterior, enviadas via parametro.
_sTransaccion = sTransaccion
_IdTransaccion = IdTransaccion
_IdProducto = IdProducto
_IdAlarma = IdAlarma
_IdPatron = IdPatron
End Sub
Private Sub OperPreoAdminDetalle_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
Dim ClassCom As New clsComplejo
Dim sSQL As String
Try
''Llenar combo de estados
sSQL = "SELECT IdEstado clave, Estado as Nombre FROM Cat_Estado WHERE IdEstado BETWEEN 1 AND 33 ORDER BY IdEstado"
ClassCom.sbLlenaCombo(sSQL, cmbEstado)
cmbEstado.SelectedIndex = -1
ClassCom = Nothing
''LLenar combo de Actividades Económicas
ClassCom = New clsComplejo
sSQL = "SELECT IdActividadEconomica Clave,ActividadEconomica as Nombre FROM Cat_ActividadEconomica ORDER BY ActividadEconomica"
ClassCom.sbLlenaCombo(sSQL, cmbActEconom)
cmbActEconom.SelectedIndex = -1
cmbPlaza.Text = "Seleccione primero un estado"
txtTransaccion.Text = _sTransaccion
''Verifica si existe el registro
sSQL = "spConsultarDetFuncionarioReportado " & _IdTransaccion & "," & _IdProducto & "," & _IdAlarma & "," & _IdPatron
ClassCom = New clsComplejo
ClassCom.fdtDataSetTabla(sSQL)
If ClassCom.ds.Tables(0).Rows.Count > 0 Then
txtNombre.Text = ClassCom.ds.Tables(0).Rows(0)("Nombre")
txtApePaterno.Text = ClassCom.ds.Tables(0).Rows(0)("ApePaterno")
txtApeMaterno.Text = ClassCom.ds.Tables(0).Rows(0)("ApeMaterno")
txtRFC.Text = ClassCom.ds.Tables(0).Rows(0)("RFC")
txtCURP.Text = ClassCom.ds.Tables(0).Rows(0)("CURP")
dtpFechaNac.Value = ClassCom.ds.Tables(0).Rows(0)("FechaNacimiento")
txtDomicilio.Text = ClassCom.ds.Tables(0).Rows(0)("Domicilio")
txtColonia.Text = ClassCom.ds.Tables(0).Rows(0)("Colonia")
cmbEstado.SelectedValue = ClassCom.ds.Tables(0).Rows(0)("IdEstado")
cmbPlaza.Text = ClassCom.ds.Tables(0).Rows(0)("PLAZA")
txtTelefono.Text = ClassCom.ds.Tables(0).Rows(0)("Telefono")
cmbActEconom.SelectedValue = ClassCom.ds.Tables(0).Rows(0)("ActividadEcon")
End If
Catch ex As Exception
MessageBox.Show(ex.Message, "Minds", MessageBoxButtons.OK, MessageBoxIcon.Information)
End Try
End Sub
Private Sub BntSalie_Click(sender As System.Object, e As System.EventArgs) Handles BntSalie.Click
Me.Close()
End Sub
Private Sub txtNombre_KeyPress(sender As System.Object, e As System.Windows.Forms.KeyPressEventArgs) Handles txtNombre.KeyPress
If Char.IsDigit(e.KeyChar) Then
e.Handled = True
End If
End Sub
Private Sub txtApePaterno_KeyPress(sender As System.Object, e As System.Windows.Forms.KeyPressEventArgs) Handles txtApePaterno.KeyPress
If Char.IsDigit(e.KeyChar) Then
e.Handled = True
End If
End Sub
Private Sub txtApeMaterno_KeyPress(sender As System.Object, e As System.Windows.Forms.KeyPressEventArgs) Handles txtApeMaterno.KeyPress
If Char.IsDigit(e.KeyChar) Then
e.Handled = True
End If
End Sub
Private Sub txtRFC_Validating(sender As System.Object, e As System.ComponentModel.CancelEventArgs) Handles txtRFC.Validating
'Try
' txtRFC.Text = txtRFC.Text.ToUpper()
' If txtRFC.Text <> String.Empty Then
' If Regex.IsMatch(txtRFC.Text.Trim, "^([A-Z\s]{4})\d{6}$") = True Then
' Return
' End If
' If Regex.IsMatch(txtRFC.Text.Trim, "^([A-Z\s]{4})\d{6}([A-Z\w]{2,3})$") = False Then
' MsgBox("El RFC no es válido. El formato correcto es: LLLL###### ó LLLL######AA ó LLLL######AAA. L=Letra, #=Número, A=Alfanumérico.")
' End If
' End If
'Catch ex As Exception
' MessageBox.Show(ex.Message, "Minds", MessageBoxButtons.OK, MessageBoxIcon.Information)
'End Try
End Sub
Private Sub txtCURP_Validating(sender As System.Object, e As System.ComponentModel.CancelEventArgs) Handles txtCURP.Validating
'Try
' txtCURP.Text = txtCURP.Text.ToUpper()
' If txtCURP.Text <> String.Empty Then
' If Regex.IsMatch(txtCURP.Text.Trim, "[a-zA-Z]{4,4}[0-9]{6}[a-zA-Z]{6,6}[0-9]{2}") = True Then
' Return
' Else
' ''
' MsgBox("La CURP no es válida. El formato correcto es: LLLL######LLLLLL## ")
' End If
' End If
'Catch ex As Exception
' MessageBox.Show(ex.Message, "Minds", MessageBoxButtons.OK, MessageBoxIcon.Information)
'End Try
End Sub
Private Sub cmbEstado_SelectedIndexChanged(sender As System.Object, e As System.EventArgs) Handles cmbEstado.SelectedIndexChanged
Dim ClassCom As New clsComplejo
Dim sSQL As String
Try
If cmbEstado.SelectedValue Is Nothing Then
Return
End If
If cmbEstado.SelectedValue.ToString.ToUpper = "SYSTEM.DATA.DATAROWVIEW" Then
Return
End If
If cmbEstado.SelectedValue > 0 Then
''LLena el combo de ciudad-plaza
'If cmbEstado.SelectedValue = "33" Then
' sSQL = "select Idplaza as Clave, plaza Nombre from cat_plaza where AliasId = '99999999'"
' ClassCom.sbLlenaCombo(sSQL, cmbPlaza)
' cmbPlaza.SelectedIndex = -1
'Else
sSQL = "select Idplaza as Clave, plaza Nombre from cat_plaza where IdEstado =" & cmbEstado.SelectedValue & " ORDER BY plaza"
ClassCom.sbLlenaCombo(sSQL, cmbPlaza)
cmbPlaza.SelectedIndex = -1
'End If
End If
Catch ex As Exception
MessageBox.Show(ex.Message, "Minds", MessageBoxButtons.OK, MessageBoxIcon.Information)
End Try
End Sub
Private Sub CambiaColor()
Label1.ForeColor = Color.MidnightBlue
Label2.ForeColor = Color.MidnightBlue
Label3.ForeColor = Color.MidnightBlue
Label4.ForeColor = Color.MidnightBlue
Label7.ForeColor = Color.MidnightBlue
Label8.ForeColor = Color.MidnightBlue
Label12.ForeColor = Color.MidnightBlue
Label9.ForeColor = Color.MidnightBlue
Label10.ForeColor = Color.MidnightBlue
Label11.ForeColor = Color.MidnightBlue
End Sub
Private Sub BtnAlta_Click(sender As System.Object, e As System.EventArgs) Handles BtnAlta.Click
''Inserta o Actualiza el registro
Dim ClassCom As New clsComplejo
Dim strSQL As String
Dim mensaje As String = ""
CambiaColor()
If txtNombre.Text = "" Then
' MessageBox.Show("Definir el nombre.", "Minds", MessageBoxButtons.OK, MessageBoxIcon.Information)
' Return
mensaje = mensaje + "Nombre " + vbCrLf + " "
Label1.ForeColor = Color.Red
End If
If txtApePaterno.Text = "" Then
' MessageBox.Show("Definir el nombre.", "Minds", MessageBoxButtons.OK, MessageBoxIcon.Information)
' Return
mensaje = mensaje + "Apellido Paterno " + vbCrLf + " "
Label2.ForeColor = Color.Red
End If
If txtApeMaterno.Text = "" Then
' MessageBox.Show("Definir el nombre.", "Minds", MessageBoxButtons.OK, MessageBoxIcon.Information)
' Return
mensaje = mensaje + "Apellido Materno " + vbCrLf + " "
Label3.ForeColor = Color.Red
End If
If txtRFC.Text = "" Then
'MessageBox.Show("Definir el RFC.", "Minds", MessageBoxButtons.OK, MessageBoxIcon.Information)
'Return
mensaje = mensaje + "RFC " + vbCrLf + " "
Label4.ForeColor = Color.Red
End If
'If txtCURP.Text = "" Then
' MessageBox.Show("Definir la CURP.", "Minds", MessageBoxButtons.OK, MessageBoxIcon.Information)
' Return
'End If
If txtDomicilio.Text = "" Then
mensaje = mensaje + "Domicilio " + vbCrLf + " "
Label7.ForeColor = Color.Red
'MessageBox.Show("Definir el domicilio.", "Minds", MessageBoxButtons.OK, MessageBoxIcon.Information)
'Return
End If
If txtColonia.Text = "" Then
mensaje = mensaje + "Colonia " + vbCrLf + " "
Label8.ForeColor = Color.Red
'MessageBox.Show("Definir la colonia.", "Minds", MessageBoxButtons.OK, MessageBoxIcon.Information)
'Return
End If
If cmbEstado.Text = "" Then
mensaje = mensaje + "Estado " + vbCrLf + " "
Label12.ForeColor = Color.Red
'MessageBox.Show("Definir la ciudad.", "Minds", MessageBoxButtons.OK, MessageBoxIcon.Information)
'Return
End If
If cmbPlaza.Text = "" Or cmbPlaza.Text = "Seleccione primero un estado" Then
mensaje = mensaje + "Cliudad " + vbCrLf + " "
Label9.ForeColor = Color.Red
'MessageBox.Show("Definir la ciudad.", "Minds", MessageBoxButtons.OK, MessageBoxIcon.Information)
'Return
End If
If txtTelefono.Text = "" Then
mensaje = mensaje + "Teléfono " + vbCrLf + " "
Label10.ForeColor = Color.Red
'MessageBox.Show("Definir el telefono.", "Minds", MessageBoxButtons.OK, MessageBoxIcon.Information)
'Return
End If
If cmbActEconom.SelectedValue = "" Then
'MessageBox.Show("Definir la actividad económica.", "Minds", MessageBoxButtons.OK, MessageBoxIcon.Information)
'Return
mensaje = mensaje + "Actividad Económica " + vbCrLf + ""
Label11.ForeColor = Color.Red
End If
If mensaje.Length > 0 Then
mensaje = "Campos Obligatorios " + vbCrLf + " " + mensaje
MessageBox.Show(mensaje, "Minds", MessageBoxButtons.OK, MessageBoxIcon.Warning)
Exit Sub
End If
txtNombre.Text = txtNombre.Text.ToUpper()
txtApePaterno.Text = txtApePaterno.Text.ToUpper()
txtApeMaterno.Text = txtApeMaterno.Text.ToUpper()
txtRFC.Text = txtRFC.Text.ToUpper()
txtCURP.Text = txtCURP.Text.ToUpper()
txtDomicilio.Text = txtDomicilio.Text.ToUpper()
txtColonia.Text = txtColonia.Text.ToUpper()
txtTelefono.Text = txtTelefono.Text.ToUpper()
strSQL = "exec spDetFuncionarioReportado " & _IdTransaccion & "," & _IdProducto & "," & _IdAlarma & "," & _IdPatron & ","
strSQL = strSQL & Chr(39) & txtNombre.Text & Chr(39) & ","
If txtApePaterno.Text = "" Then
strSQL = strSQL & Chr(39) & "XXXX" & Chr(39) & ","
Else
strSQL = strSQL & Chr(39) & txtApePaterno.Text & Chr(39) & ","
End If
If txtApeMaterno.Text = "" Then
strSQL = strSQL & Chr(39) & "XXXX" & Chr(39) & ","
Else
strSQL = strSQL & Chr(39) & txtApeMaterno.Text & Chr(39) & ","
End If
strSQL = strSQL & Chr(39) & txtRFC.Text & Chr(39) & ","
strSQL = strSQL & Chr(39) & txtCURP.Text & Chr(39) & ","
strSQL = strSQL & Chr(39) & dtpFechaNac.Value.Year.ToString & dtpFechaNac.Value.Month.ToString("d2") & dtpFechaNac.Value.Day.ToString("d2") & Chr(39) & ","
strSQL = strSQL & Chr(39) & txtDomicilio.Text & Chr(39) & ","
strSQL = strSQL & Chr(39) & txtColonia.Text & Chr(39) & ","
strSQL = strSQL & Chr(39) & cmbPlaza.SelectedValue & Chr(39) & ","
strSQL = strSQL & Chr(39) & txtTelefono.Text & Chr(39) & ","
strSQL = strSQL & Chr(39) & cmbActEconom.SelectedValue & Chr(39)
ClassCom = New clsComplejo
ClassCom.fdtDataSetTabla(strSQL)
If ClassCom.ds.Tables(0).Rows(0)("Resultado") = -1 Then
''Mensaje de error
MessageBox.Show(ClassCom.ds.Tables(0).Rows(0)("MsgError"), "Minds", MessageBoxButtons.OK, MessageBoxIcon.Information)
Else
'AUDITORIA
Dim ClassAud As New ClassMyUtils
Dim varUser As Long
Dim ClassComodin As New clsComplejo
Dim sAuditoria As String
Dim strNota As String
Dim clCmp As clsComplejo = New clsComplejo
strNota = clCmp.BuscaValores("nombreproducto", "producto", "id_producto = " & _IdProducto)
sAuditoria = "Detalle de alarma preocupante con transacción Id Transacción = " & txtTransaccion.Text.Trim() &
"; Nombre = " & txtNombre.Text.Trim() &
"; Apellido Paterno = " & txtApePaterno.Text.Trim() &
"; Apellido Materno = " & txtApeMaterno.Text.Trim() &
"; RFC = " & txtRFC.Text.Trim &
"; CURP = " & txtCURP.Text.Trim &
"; Fecha Nacimiento o Constitución = " & dtpFechaNac.Text &
"; Domicilio = " & txtDomicilio.Text.Trim &
"; Colonia = " & txtColonia.Text.Trim &
"; Estado = " & cmbEstado.Text.Trim &
"; Ciudad = " & cmbPlaza.Text.Trim &
"; Telefono = " & txtTelefono.Text.Trim &
"; Act. Económica = " & cmbActEconom.Text.Trim
ClassAud.RT_Auditoria(VariablesGlobales.gblIdUsuario, 126, My.Computer.Name, "Minds Cliente", sAuditoria)
MessageBox.Show("Registro actualizado correctamente.", "Minds", MessageBoxButtons.OK, MessageBoxIcon.Information)
End If
End Sub
End Class