983 lines
43 KiB
VB.net
983 lines
43 KiB
VB.net
Imports Microsoft.VisualBasic
|
|
Namespace SenteciasSQL
|
|
Public Class ClassSQL
|
|
Public cn2 As ExecConexion.ClassCon = New ExecConexion.ClassCon
|
|
Public cm As New SqlClient.SqlCommand 'declaraciòn de comando SQL
|
|
Public dr As SqlClient.SqlDataReader 'Datareader
|
|
Public ds As New DataSet 'declaracion de dataset
|
|
Public ad As New SqlClient.SqlDataAdapter 'declaraciòn de adaptador
|
|
Public dt As New DataTable 'declaracion de datatable
|
|
|
|
Public Function IngresaArchivoAlarma(ByVal IdProducto As String, ByVal IdPatron As String,
|
|
ByVal IdTransaccion As String, ByVal NombreArchivo As String, ByVal Bytes As Byte()) As Boolean
|
|
Try
|
|
|
|
Dim strSQL As String = "INSERT INTO tbl_Evidencias(IdProducto, IdPatron, IdTransaccion, NombreArchivo, Bytes) VALUES(@IdProducto, @IdPatron, @IdTransaccion, @NombreArchivo, @Bytes)"
|
|
cm = New SqlClient.SqlCommand
|
|
clsVaribles.Conexion.Open()
|
|
cm.Connection = clsVaribles.Conexion
|
|
cm.CommandText = strSQL
|
|
cm.Parameters.Add("@IdProducto", SqlDbType.Int).Value = IdProducto
|
|
cm.Parameters.Add("@IdPatron", SqlDbType.Int).Value = IdPatron
|
|
cm.Parameters.Add("@IdTransaccion", SqlDbType.Int).Value = IdTransaccion
|
|
cm.Parameters.Add("@NombreArchivo", SqlDbType.VarChar).Value = NombreArchivo
|
|
cm.Parameters.Add("@Bytes", SqlDbType.VarBinary).Value = Bytes
|
|
cm.ExecuteNonQuery()
|
|
|
|
Catch ex As Exception
|
|
MessageBox.Show("Error en ClassSQL; IngresaArchivoAlarma: ", "MINDS", MessageBoxButtons.OK, MessageBoxIcon.Error)
|
|
Return False
|
|
End Try
|
|
|
|
clsVaribles.Conexion.Close()
|
|
|
|
Return True
|
|
|
|
End Function
|
|
|
|
Public Function fdtDataSet(ByVal SQL As String) As DataSet
|
|
Try
|
|
'cn2.ConectaBD(VariablesGlobales.gbConexion)
|
|
|
|
cm.Connection = clsVaribles.Conexion
|
|
cm.CommandText = SQL
|
|
ad.SelectCommand = cm
|
|
ad.Fill(ds)
|
|
Return ds
|
|
Catch ex As Exception
|
|
MessageBox.Show("Error en ClsComplejo; fdtDataSet: ", "MINDS", MessageBoxButtons.OK, MessageBoxIcon.Error)
|
|
Exit Function
|
|
End Try
|
|
|
|
cn2.sbCierraCn()
|
|
|
|
End Function
|
|
Public Function BuscaDatos(ByVal SQL As String) As Boolean
|
|
Dim cn2 As ExecConexion.ClassCon = New ExecConexion.ClassCon
|
|
Try
|
|
|
|
BuscaDatos = False
|
|
|
|
'cn2.ConectaBD(VariablesGlobales.gbConexion)
|
|
|
|
cm.Connection = clsVaribles.Conexion
|
|
cm.CommandText = SQL
|
|
ad.SelectCommand = cm
|
|
ad.Fill(ds)
|
|
|
|
If ds.Tables(0).Rows.Count <> 0 Then
|
|
BuscaDatos = True
|
|
End If
|
|
|
|
Catch ex As Exception
|
|
MessageBox.Show("Error en ClsComplejo; fdtDataSet: ", "MINDS", MessageBoxButtons.OK, MessageBoxIcon.Error)
|
|
Exit Function
|
|
End Try
|
|
|
|
cn2.sbCierraCn()
|
|
|
|
End Function
|
|
|
|
Public Function fdtDataSetTabla(ByVal SQL As String) As DataSet
|
|
'cn2.ConectaBD(VariablesGlobales.gbConexion)
|
|
Try
|
|
cm.Connection = clsVaribles.Conexion
|
|
cm.CommandText = SQL
|
|
ad.SelectCommand = cm
|
|
ds.Clear()
|
|
ad.Fill(ds, "Tabla")
|
|
Return ds
|
|
Catch ex As Exception
|
|
MessageBox.Show("error en ClsComplejo; fdtDataSetTabla: " & ex.Message, "MINDS", MessageBoxButtons.OK, MessageBoxIcon.Error)
|
|
Exit Function
|
|
End Try
|
|
cn2.sbCierraCn()
|
|
End Function
|
|
Public Function VerificaLIstas(ByVal Nombre As String) As Boolean
|
|
|
|
Dim SQLListas As String
|
|
Dim Classcom2 As New SenteciasSQL.ClassSQL
|
|
|
|
VerificaLIstas = False
|
|
|
|
SQLListas = "SELECT * FROM ListaRestringida "
|
|
'SQLListas = SQLListas & " WHERE Nombre LIKE '%" & Nombre & "%'"
|
|
SQLListas = SQLListas & " WHERE Nombre LIKE '" & Nombre & "'"
|
|
|
|
Classcom2.fdtDataSet(SQLListas)
|
|
|
|
If Classcom2.ds.Tables(0).Rows.Count <> 0 Then
|
|
VerificaLIstas = True
|
|
End If
|
|
|
|
End Function
|
|
|
|
Public Function ProcesoInsert2(ByRef PrefijoTexto As String, ByVal PrefijoCombo As String, ByVal Kyc_Respuestaopciones As String, ByVal PrefijoDatePicker As String, ByVal Tabla As String, ByVal Panel As Panel, ByVal Exception As String, ByVal Prefijolabel As String) As String
|
|
Dim NomCampo As String
|
|
Dim fila As DataRow
|
|
Dim clcmp As clsComplejo = New clsComplejo
|
|
Dim GRPBOX As GroupBox
|
|
Dim SentenciaInsert As String
|
|
Dim SentenciaValues As String
|
|
Dim Combo As Object
|
|
Dim SQLProcesoInsert As String
|
|
Dim PrefijoComodin As String
|
|
|
|
Dim lcCtrl As Object
|
|
Dim lcCtrlIN As Object
|
|
|
|
'sbConectaBD()
|
|
|
|
Try
|
|
|
|
Dim ARRAY() As String
|
|
Dim ArrValores() As String
|
|
|
|
ARRAY = Nothing
|
|
|
|
SentenciaInsert = ""
|
|
SentenciaValues = ""
|
|
|
|
If Exception <> "" Then
|
|
ARRAY = Split(Exception, "|", -1)
|
|
|
|
If ARRAY.LongLength <> 0 Then
|
|
For i As Integer = 0 To ARRAY.LongLength - 1
|
|
ArrValores = Nothing
|
|
ArrValores = Split(ARRAY(i), "=", -1)
|
|
|
|
If SentenciaInsert = "" Then
|
|
SentenciaInsert = SentenciaInsert & "INSERT INTO " & Tabla
|
|
SentenciaInsert = SentenciaInsert & " (" & ArrValores(0)
|
|
Else
|
|
SentenciaInsert = SentenciaInsert & "," & ArrValores(0)
|
|
End If
|
|
|
|
If SentenciaValues = "" Then
|
|
SentenciaValues = SentenciaValues & " VALUES ( "
|
|
SentenciaValues = SentenciaValues & ArrValores(1)
|
|
Else
|
|
SentenciaValues = SentenciaValues & "," & ArrValores(1)
|
|
End If
|
|
|
|
Next
|
|
End If
|
|
|
|
End If
|
|
|
|
For Each lcCtrl In Panel.Controls
|
|
If (TypeOf lcCtrl Is GroupBox Or TypeOf lcCtrl Is Panel) Then
|
|
|
|
For Each lcCtrlIN In lcCtrl.Controls
|
|
|
|
'Cuando los controles son Textos se arma la Variable sentenciaInsert
|
|
'Deacuerdo al Nombre Del control que debe de ser igual al nombre del campo
|
|
'omitiendo el prefijo ej. "TXT0"
|
|
'Al mismo Tiempo de Arma la SentenciaValues con los Datos de Cada control de Texto
|
|
|
|
If TypeOf lcCtrlIN Is TextBox Then
|
|
|
|
If Mid(Trim(lcCtrlIN.Name), 1, 4) = PrefijoTexto Then
|
|
|
|
If SentenciaInsert = "" Then
|
|
SentenciaInsert = SentenciaInsert & "INSERT INTO " & Tabla
|
|
SentenciaInsert = SentenciaInsert & " (" & Mid(Trim(lcCtrlIN.Name), 5, Len(lcCtrlIN.Name))
|
|
|
|
SentenciaValues = SentenciaValues & " VALUES ( "
|
|
|
|
If IsDate(lcCtrlIN.Text) Then
|
|
SentenciaValues = SentenciaValues & " CONVERT(DATETIME,'" & clcmp.ObtenFecha(lcCtrlIN.Text, "YYYYMMDD") & "',112)"
|
|
ElseIf IsNumeric(lcCtrlIN.Text) Then
|
|
SentenciaValues = SentenciaValues & lcCtrlIN.Text
|
|
ElseIf IsDate(lcCtrlIN.Text) Then
|
|
SentenciaValues = SentenciaValues & " CONVERT(DATETIME,'" & clcmp.ObtenFecha(lcCtrlIN.Text, "YYYYMMDD") & "',112)"
|
|
ElseIf lcCtrlIN.Text = "" Then
|
|
SentenciaValues = SentenciaValues & " NULL"
|
|
Else
|
|
SentenciaValues = SentenciaValues & " '" & Trim(lcCtrlIN.Text) & "'"
|
|
End If 'IsNumeric(lcCtrlIN.Text)
|
|
|
|
Else
|
|
|
|
SentenciaInsert = SentenciaInsert & " ," & Mid(Trim(lcCtrlIN.Name), 5, Len(lcCtrlIN.Name))
|
|
|
|
If IsDate(lcCtrlIN.Text) Then
|
|
SentenciaValues = SentenciaValues & ",CONVERT(DATETIME,'" & clcmp.ObtenFecha(lcCtrlIN.Text, "YYYYMMDD") & "',112)"
|
|
ElseIf IsNumeric(lcCtrlIN.Text) Then
|
|
SentenciaValues = SentenciaValues & "," & lcCtrlIN.Text
|
|
ElseIf lcCtrlIN.Text = "" Then
|
|
SentenciaValues = SentenciaValues & "," & " NULL"
|
|
Else
|
|
SentenciaValues = SentenciaValues & "," & " '" & Trim(lcCtrlIN.Text) & "'"
|
|
End If 'IsNumeric(lcCtrlIN.Text)
|
|
|
|
End If 'SentenciaInsert = ""
|
|
|
|
End If 'Mid(Trim(lcCtrlIN.Name), 1, 4) = Prefijo
|
|
|
|
ElseIf TypeOf lcCtrlIN Is ComboBox Then
|
|
|
|
PrefijoComodin = "Cbo" & Mid(PrefijoCombo, 4, 1)
|
|
|
|
If Mid(Trim(lcCtrlIN.Name), 1, 4) = PrefijoCombo Then
|
|
|
|
If SentenciaInsert = "" Then
|
|
SentenciaInsert = SentenciaInsert & "INSERT INTO " & Tabla
|
|
SentenciaInsert = SentenciaInsert & " (" & Mid(Trim(lcCtrlIN.Name), 5, Len(lcCtrlIN.Name))
|
|
|
|
SentenciaValues = SentenciaValues & " VALUES ( "
|
|
|
|
If lcCtrlIN.Text = "" Then
|
|
SentenciaValues = SentenciaValues & " NULL"
|
|
ElseIf lcCtrlIN.selectedvalue = Nothing Then
|
|
SentenciaValues = SentenciaValues & lcCtrlIN.selectedindex + 1
|
|
Else
|
|
SentenciaValues = SentenciaValues & lcCtrlIN.selectedvalue
|
|
End If
|
|
|
|
Else
|
|
|
|
SentenciaInsert = SentenciaInsert & " ," & Mid(Trim(lcCtrlIN.Name), 5, Len(lcCtrlIN.Name))
|
|
|
|
If lcCtrlIN.Text = "" Then
|
|
SentenciaValues = SentenciaValues & "," & " NULL"
|
|
ElseIf lcCtrlIN.selectedvalue = Nothing Then
|
|
SentenciaValues = SentenciaValues & "," & lcCtrlIN.selectedindex + 1
|
|
Else
|
|
SentenciaValues = SentenciaValues & "," & lcCtrlIN.selectedvalue
|
|
End If
|
|
End If
|
|
ElseIf Mid(Trim(lcCtrlIN.Name), 1, 4) = PrefijoComodin Then
|
|
|
|
If SentenciaInsert = "" Then
|
|
SentenciaInsert = SentenciaInsert & "INSERT INTO " & Tabla
|
|
SentenciaInsert = SentenciaInsert & " (" & Mid(Trim(lcCtrlIN.Name), 5, Len(lcCtrlIN.Name))
|
|
|
|
SentenciaValues = SentenciaValues & " VALUES ( "
|
|
|
|
If lcCtrlIN.Text = "" Then
|
|
SentenciaValues = SentenciaValues & " NULL"
|
|
Else
|
|
SentenciaValues = SentenciaValues & lcCtrlIN.Text
|
|
End If
|
|
Else
|
|
|
|
SentenciaInsert = SentenciaInsert & " ," & Mid(Trim(lcCtrlIN.Name), 5, Len(lcCtrlIN.Name))
|
|
|
|
If lcCtrlIN.Text = "" Then
|
|
SentenciaValues = SentenciaValues & "," & " NULL"
|
|
Else
|
|
SentenciaValues = SentenciaValues & ",'" & lcCtrlIN.text & "'"
|
|
End If
|
|
End If
|
|
|
|
End If 'Mid(Trim(lcCtrlIN.Name), 1, 4) = Prefijo
|
|
|
|
ElseIf TypeOf lcCtrlIN Is CheckBox Then
|
|
|
|
If Mid(Trim(lcCtrlIN.Name), 1, 4) = Prefijolabel Then
|
|
|
|
If SentenciaInsert = "" Then
|
|
SentenciaInsert = SentenciaInsert & "INSERT INTO " & Tabla
|
|
SentenciaInsert = SentenciaInsert & " (" & Mid(Trim(lcCtrlIN.Name), 5, Len(lcCtrlIN.Name))
|
|
|
|
SentenciaValues = SentenciaValues & " VALUES ( "
|
|
|
|
SentenciaValues = SentenciaValues & lcCtrlIN.CheckState
|
|
|
|
Else
|
|
|
|
SentenciaInsert = SentenciaInsert & " ," & Mid(Trim(lcCtrlIN.Name), 5, Len(lcCtrlIN.Name))
|
|
|
|
SentenciaValues = SentenciaValues & "," & lcCtrlIN.CheckState
|
|
|
|
End If 'SentenciaInsert = ""
|
|
|
|
End If 'Mid(Trim(lcCtrlIN.Name), 1, 4) = Prefijo
|
|
|
|
ElseIf TypeOf lcCtrlIN Is RadioButton Then
|
|
|
|
If Mid(Trim(lcCtrlIN.Name), 1, 4) = Prefijolabel Then
|
|
|
|
If SentenciaInsert = "" Then
|
|
SentenciaInsert = SentenciaInsert & "INSERT INTO " & Tabla
|
|
SentenciaInsert = SentenciaInsert & " (" & Mid(Trim(lcCtrlIN.Name), 5, Len(lcCtrlIN.Name))
|
|
|
|
SentenciaValues = SentenciaValues & " VALUES ( "
|
|
|
|
SentenciaValues = SentenciaValues & IIf(lcCtrlIN.Checked = True, 1, 0)
|
|
|
|
|
|
Else
|
|
|
|
SentenciaInsert = SentenciaInsert & " ," & Mid(Trim(lcCtrlIN.Name), 5, Len(lcCtrlIN.Name))
|
|
|
|
SentenciaValues = SentenciaValues & "," & IIf(lcCtrlIN.Checked = True, 1, 0)
|
|
|
|
End If 'SentenciaInsert = ""
|
|
|
|
End If 'Mid(Trim(lcCtrlIN.Name), 1, 4) = Prefijo
|
|
|
|
|
|
'End If ''TypeOf lcCtrlIN Is TextBox or TypeOf lcCtrlIN Is combobox
|
|
ElseIf TypeOf lcCtrlIN Is DateTimePicker Then
|
|
|
|
If Mid(Trim(lcCtrlIN.Name), 1, 4) = PrefijoDatePicker Then
|
|
|
|
If SentenciaInsert = "" Then ' MsgBox(DTP1FechaRegistro.Value.Date)
|
|
SentenciaInsert = SentenciaInsert & "INSERT INTO " & Tabla
|
|
SentenciaInsert = SentenciaInsert & " (" & Mid(Trim(lcCtrlIN.Name), 5, Len(lcCtrlIN.Name))
|
|
|
|
SentenciaValues = SentenciaValues & " VALUES ( "
|
|
|
|
SentenciaValues = SentenciaValues & " CONVERT(DATETIME,'" & clcmp.ObtenFecha(lcCtrlIN.Value.Date, "YYYYMMDD") & "',112)"
|
|
|
|
Else
|
|
|
|
SentenciaInsert = SentenciaInsert & " ," & Mid(Trim(lcCtrlIN.Name), 5, Len(lcCtrlIN.Name))
|
|
|
|
SentenciaValues = SentenciaValues & "," & " CONVERT(DATETIME,'" & clcmp.ObtenFecha(lcCtrlIN.Value.Date, "YYYYMMDD") & "',112)"
|
|
|
|
End If 'SentenciaInsert = ""
|
|
|
|
End If 'Mid(Trim(lcCtrlIN.Name), 1, 4) = Prefijo
|
|
|
|
End If ''TypeOf lcCtrlIN Is TextBox or TypeOf lcCtrlIN Is combobox
|
|
|
|
Next 'lcCtrlIN In GRPBOX.Controls
|
|
|
|
End If 'TypeOf lcCtrl Is GroupBox
|
|
|
|
Next 'GRPBOX In TabPage.Controls
|
|
|
|
SQLProcesoInsert = SentenciaInsert & ") " & SentenciaValues & ") "
|
|
|
|
Return SQLProcesoInsert
|
|
|
|
Catch er As Exception
|
|
MessageBox.Show("Error en ClsComplejo; sbLlenaCombo: " & er.Message, "MINDS", MessageBoxButtons.OK, MessageBoxIcon.Error)
|
|
Exit Function
|
|
End Try
|
|
'sbCierraCn()
|
|
|
|
End Function
|
|
|
|
Public Function BuscaValores(ByVal SqlSELECT As String, ByVal SqlFROM As String, ByVal SqlWHERE As String) As Object
|
|
Dim fila As DataRow
|
|
Dim SQL As String
|
|
Dim Classcom As New clsComplejo
|
|
'cn2.ConectaBD(clsVaribles.Conexion)
|
|
Try
|
|
|
|
SQL = "SELECT " & SqlSELECT & " " & " FROM " & SqlFROM
|
|
If SqlWHERE <> "" Then
|
|
SQL = SQL & " WHERE " & SqlWHERE
|
|
End If
|
|
|
|
Classcom.fdtDataSet(SQL)
|
|
|
|
'cm.Connection = cn2.cn
|
|
'cm.CommandText = SQL
|
|
'ad.SelectCommand = cm
|
|
'ad.Fill(ds)
|
|
|
|
If Classcom.ds.Tables(0).Rows.Count <> 0 Then
|
|
If IsDBNull(Classcom.ds.Tables(0).Rows(0)) Then
|
|
Return ""
|
|
Else
|
|
Return Classcom.ds.Tables(0).Rows(0).Item(0)
|
|
End If
|
|
|
|
End If
|
|
|
|
Catch ex As Exception
|
|
MessageBox.Show("Error en ClsComplejo; fdtDataSet: ", "MINDS", MessageBoxButtons.OK, MessageBoxIcon.Error)
|
|
Exit Function
|
|
End Try
|
|
cn2.sbCierraCn()
|
|
End Function
|
|
Public Function ProcesoUpdate2(ByRef PrefijoTexto As String, ByVal PrefijoCombo As String, ByVal PrefijoCheckBox As String, ByVal PrefijoDatePicker As String, ByVal Tabla As String, ByVal Panel As Panel, ByVal SentenciaWHERE As String, ByVal Exception As String, ByVal PrefijoRadio As String) As String
|
|
Dim NomCampo As String
|
|
Dim fila As DataRow
|
|
Dim clcmp As clsComplejo = New clsComplejo
|
|
Dim GRPBOX As GroupBox
|
|
Dim SentenciaInsert As String
|
|
Dim SentenciaValues As String
|
|
Dim SentenciaUpdate As String
|
|
Dim Combo As Object
|
|
Dim SQLProcesoUpdate As String
|
|
Dim PrefijoComodin As String
|
|
|
|
Dim lcCtrl As Object
|
|
Dim lcCtrlIN As Object
|
|
|
|
'sbConectaBD()
|
|
|
|
Try
|
|
|
|
'SentenciaInsert = ""
|
|
'SentenciaValues = ""
|
|
SentenciaUpdate = ""
|
|
|
|
|
|
Dim ARRAY() As String
|
|
Dim ArrValores() As String
|
|
|
|
ARRAY = Nothing
|
|
|
|
SentenciaUpdate = ""
|
|
SentenciaValues = ""
|
|
|
|
If Exception <> "" Then
|
|
ARRAY = Split(Exception, "|", -1)
|
|
|
|
If ARRAY.LongLength <> 0 Then
|
|
For i As Integer = 0 To ARRAY.LongLength - 1
|
|
ArrValores = Nothing
|
|
ArrValores = Split(ARRAY(i), "=", -1)
|
|
|
|
If SentenciaUpdate = "" Then
|
|
SentenciaUpdate = SentenciaUpdate & "UPDATE " & Tabla & " SET "
|
|
SentenciaUpdate = SentenciaUpdate & ArrValores(0) & " = " & ArrValores(1)
|
|
Else
|
|
SentenciaUpdate = SentenciaUpdate & "," & ArrValores(0) & " = " & ArrValores(1)
|
|
End If
|
|
Next
|
|
End If
|
|
|
|
End If
|
|
|
|
For Each lcCtrl In Panel.Controls
|
|
If (TypeOf lcCtrl Is GroupBox Or TypeOf lcCtrl Is Panel) Then
|
|
|
|
For Each lcCtrlIN In lcCtrl.Controls
|
|
|
|
'Cuando los controles son Textos se arma la Variable sentenciaInsert
|
|
'Deacuerdo al Nombre Del control que debe de ser igual al nombre del campo
|
|
'omitiendo el prefijo ej. "TXT0"
|
|
'Al mismo Tiempo de Arma la SentenciaValues con los Datos de Cada control de Texto
|
|
|
|
If TypeOf lcCtrlIN Is TextBox Then
|
|
|
|
If Mid(Trim(lcCtrlIN.Name), 1, 4) = PrefijoTexto Then
|
|
|
|
If SentenciaUpdate = "" Then
|
|
SentenciaUpdate = SentenciaUpdate & "UPDATE " & Tabla
|
|
|
|
SentenciaUpdate = SentenciaUpdate & " SET " & Mid(Trim(lcCtrlIN.Name), 5, Len(lcCtrlIN.Name))
|
|
|
|
'SentenciaValues = SentenciaValues & " VALUES ( "
|
|
|
|
If IsNumeric(lcCtrlIN.Text) Then
|
|
SentenciaUpdate = SentenciaUpdate & "=" & lcCtrlIN.Text
|
|
ElseIf IsDate(lcCtrlIN.Text) Then
|
|
SentenciaUpdate = SentenciaUpdate & " = CONVERT(DATETIME,'" & clcmp.ObtenFecha(lcCtrlIN.Text, "YYYYMMDD") & "',112)"
|
|
ElseIf lcCtrlIN.Text = "" Then
|
|
SentenciaUpdate = SentenciaUpdate & " = NULL"
|
|
Else
|
|
SentenciaUpdate = SentenciaUpdate & "=" & " '" & Trim(lcCtrlIN.Text) & "'"
|
|
End If 'IsNumeric(lcCtrlIN.Text)
|
|
|
|
Else
|
|
SentenciaUpdate = SentenciaUpdate & " ," & Mid(Trim(lcCtrlIN.Name), 5, Len(lcCtrlIN.Name))
|
|
|
|
If IsNumeric(lcCtrlIN.Text) Then
|
|
SentenciaUpdate = SentenciaUpdate & " = " & lcCtrlIN.Text
|
|
ElseIf IsDate(lcCtrlIN.Text) Then
|
|
SentenciaUpdate = SentenciaUpdate & " = CONVERT(DATETIME,'" & clcmp.ObtenFecha(lcCtrlIN.TEXT, "YYYYMMDD") & "',112)"
|
|
ElseIf lcCtrlIN.Text = "" Then
|
|
SentenciaUpdate = SentenciaUpdate & " = " & " NULL"
|
|
Else
|
|
SentenciaUpdate = SentenciaUpdate & " = " & " '" & Trim(lcCtrlIN.Text) & "'"
|
|
End If 'IsNumeric(lcCtrlIN.Text)
|
|
|
|
End If 'SentenciaInsert = ""
|
|
|
|
End If 'Mid(Trim(lcCtrlIN.Name), 1, 4) = Prefijo
|
|
|
|
ElseIf TypeOf lcCtrlIN Is ComboBox Then
|
|
|
|
PrefijoComodin = "Cbo" & Mid(PrefijoCombo, 4, 1)
|
|
|
|
If Mid(Trim(lcCtrlIN.Name), 1, 4) = PrefijoCombo Then
|
|
|
|
If SentenciaUpdate = "" Then
|
|
SentenciaUpdate = SentenciaUpdate & "UPDATE " & Tabla
|
|
SentenciaUpdate = SentenciaUpdate & " SET " & Mid(Trim(lcCtrlIN.Name), 5, Len(lcCtrlIN.Name))
|
|
|
|
'SentenciaValues = SentenciaValues & " VALUES ( "
|
|
|
|
If lcCtrlIN.Text = "" Then
|
|
SentenciaUpdate = SentenciaUpdate & " = " & " NULL"
|
|
ElseIf lcCtrlIN.selectedvalue = Nothing Then
|
|
SentenciaUpdate = SentenciaUpdate & " = " & lcCtrlIN.selectedindex + 1
|
|
Else
|
|
SentenciaUpdate = SentenciaUpdate & " = " & lcCtrlIN.selectedvalue
|
|
End If
|
|
|
|
Else
|
|
|
|
SentenciaUpdate = SentenciaUpdate & " ," & Mid(Trim(lcCtrlIN.Name), 5, Len(lcCtrlIN.Name))
|
|
|
|
If lcCtrlIN.Text = "" Then
|
|
SentenciaUpdate = SentenciaUpdate & " = " & " NULL"
|
|
ElseIf lcCtrlIN.selectedvalue = Nothing Then
|
|
SentenciaUpdate = SentenciaUpdate & " = " & lcCtrlIN.selectedindex + 1
|
|
Else
|
|
SentenciaUpdate = SentenciaUpdate & " = " & lcCtrlIN.selectedvalue
|
|
End If
|
|
End If
|
|
|
|
ElseIf Mid(Trim(lcCtrlIN.Name), 1, 4) = PrefijoComodin Then
|
|
|
|
If SentenciaUpdate = "" Then
|
|
SentenciaUpdate = SentenciaUpdate & "UPDATE " & Tabla
|
|
SentenciaUpdate = SentenciaUpdate & " SET " & Mid(Trim(lcCtrlIN.Name), 5, Len(lcCtrlIN.Name))
|
|
|
|
'SentenciaValues = SentenciaValues & " VALUES ( "
|
|
|
|
If lcCtrlIN.Text = "" Then
|
|
SentenciaUpdate = SentenciaUpdate & " = " & " NULL"
|
|
Else
|
|
SentenciaUpdate = SentenciaUpdate & " = '" & lcCtrlIN.text & "'"
|
|
End If
|
|
|
|
Else
|
|
|
|
SentenciaUpdate = SentenciaUpdate & " ," & Mid(Trim(lcCtrlIN.Name), 5, Len(lcCtrlIN.Name))
|
|
|
|
If lcCtrlIN.Text = "" Then
|
|
SentenciaUpdate = SentenciaUpdate & " = " & " NULL"
|
|
Else
|
|
SentenciaUpdate = SentenciaUpdate & " = '" & lcCtrlIN.text & "'"
|
|
End If
|
|
End If
|
|
End If 'Mid(Trim(lcCtrlIN.Name), 1, 4) = Prefijo
|
|
|
|
ElseIf TypeOf lcCtrlIN Is CheckBox Then
|
|
|
|
If Mid(Trim(lcCtrlIN.Name), 1, 4) = PrefijoCheckBox Then
|
|
|
|
If SentenciaUpdate = "" Then
|
|
SentenciaUpdate = SentenciaUpdate & "UPDATE " & Tabla
|
|
SentenciaUpdate = SentenciaUpdate & " SET " & Mid(Trim(lcCtrlIN.Name), 5, Len(lcCtrlIN.Name))
|
|
|
|
'SentenciaUpdate = SentenciaUpdate & " VALUES ( "
|
|
|
|
SentenciaUpdate = SentenciaUpdate & " = " & lcCtrlIN.CheckState
|
|
|
|
Else
|
|
|
|
SentenciaUpdate = SentenciaUpdate & ", " & Mid(Trim(lcCtrlIN.Name), 5, Len(lcCtrlIN.Name))
|
|
|
|
SentenciaUpdate = SentenciaUpdate & " = " & lcCtrlIN.CheckState
|
|
|
|
End If 'SentenciaInsert = ""
|
|
|
|
End If 'Mid(Trim(lcCtrlIN.Name), 1, 4) = Prefijo
|
|
|
|
ElseIf TypeOf lcCtrlIN Is RadioButton Then
|
|
|
|
If Mid(Trim(lcCtrlIN.Name), 1, 4) = PrefijoRadio Then
|
|
|
|
If SentenciaUpdate = "" Then
|
|
SentenciaUpdate = SentenciaUpdate & "UPDATE " & Tabla
|
|
SentenciaUpdate = SentenciaUpdate & " SET " & Mid(Trim(lcCtrlIN.Name), 5, Len(lcCtrlIN.Name))
|
|
|
|
'SentenciaUpdate = SentenciaUpdate & " VALUES ( "
|
|
|
|
SentenciaUpdate = SentenciaUpdate & " = " & IIf(lcCtrlIN.checked = True, 1, 0)
|
|
|
|
Else
|
|
|
|
SentenciaUpdate = SentenciaUpdate & ", " & Mid(Trim(lcCtrlIN.Name), 5, Len(lcCtrlIN.Name))
|
|
|
|
SentenciaUpdate = SentenciaUpdate & " = " & IIf(lcCtrlIN.checked = True, 1, 0)
|
|
|
|
End If 'SentenciaInsert = ""
|
|
|
|
End If 'Mid(Trim(lcCtrlIN.Name), 1, 4) = Prefijo
|
|
|
|
|
|
'End If ''TypeOf lcCtrlIN Is TextBox or TypeOf lcCtrlIN Is combobox
|
|
ElseIf TypeOf lcCtrlIN Is DateTimePicker Then
|
|
|
|
If Mid(Trim(lcCtrlIN.Name), 1, 4) = PrefijoDatePicker Then
|
|
|
|
If SentenciaUpdate = "" Then ' MsgBox(DTP1FechaRegistro.Value.Date)
|
|
SentenciaUpdate = SentenciaUpdate & "UPDATE " & Tabla
|
|
SentenciaUpdate = SentenciaUpdate & " SET " & Mid(Trim(lcCtrlIN.Name), 5, Len(lcCtrlIN.Name))
|
|
|
|
'SentenciaValues = SentenciaValues & " VALUES ( "
|
|
|
|
SentenciaUpdate = SentenciaUpdate & " = " & " CONVERT(DATETIME,'" & clcmp.ObtenFecha(lcCtrlIN.Value.Date, "YYYYMMDD") & "',112)"
|
|
|
|
Else
|
|
|
|
SentenciaUpdate = SentenciaUpdate & " ," & Mid(Trim(lcCtrlIN.Name), 5, Len(lcCtrlIN.Name))
|
|
|
|
SentenciaUpdate = SentenciaUpdate & " = " & " CONVERT(DATETIME,'" & clcmp.ObtenFecha(lcCtrlIN.Value.Date, "YYYYMMDD") & "',112)"
|
|
|
|
End If 'SentenciaInsert = ""
|
|
|
|
End If 'Mid(Trim(lcCtrlIN.Name), 1, 4) = Prefijo
|
|
|
|
End If ''TypeOf lcCtrlIN Is TextBox or TypeOf lcCtrlIN Is combobox
|
|
|
|
Next 'lcCtrlIN In GRPBOX.Controls
|
|
|
|
End If 'TypeOf lcCtrl Is GroupBox
|
|
|
|
Next 'GRPBOX In TabPage.Controls
|
|
|
|
'SQLProcesoUpdate = SentenciaUpdate & " WHERE id_cliente = " & ClsVariables.VarIdCliente
|
|
|
|
If SentenciaWHERE = "" Then
|
|
SQLProcesoUpdate = SentenciaUpdate
|
|
Else
|
|
SQLProcesoUpdate = SentenciaUpdate & " WHERE " & SentenciaWHERE
|
|
End If
|
|
|
|
Return SQLProcesoUpdate
|
|
|
|
Catch er As Exception
|
|
MessageBox.Show("Error en ClsComplejo; sbLlenaCombo: " & er.Message, "MINDS", MessageBoxButtons.OK, MessageBoxIcon.Error)
|
|
Exit Function
|
|
End Try
|
|
'sbCierraCn()
|
|
End Function
|
|
Public Sub LLenaModelo(ByVal Panel As Panel, ByVal PrefijoRDB As String, ByVal SQL As String)
|
|
|
|
Dim NomCampo As String
|
|
Dim fila As DataRow
|
|
Dim Cl As SenteciasSQL.ClassSQL = New SenteciasSQL.ClassSQL
|
|
Dim GRPBOX As GroupBox
|
|
Dim SentenciaInsert As String
|
|
Dim SentenciaValues As String
|
|
Dim Combo As Object
|
|
Dim SQLProcesoInsert As String
|
|
Dim PrefijoComodin As String
|
|
|
|
Dim lcCtrl As Object
|
|
Dim lcCtrlIN As Object
|
|
|
|
'sbConectaBD()
|
|
|
|
Try
|
|
|
|
|
|
Cl.fdtDataSet(SQL)
|
|
|
|
fila = Cl.ds.Tables(0).Rows(0)
|
|
|
|
For Each lcCtrl In Panel.Controls
|
|
If (TypeOf lcCtrl Is GroupBox Or TypeOf lcCtrl Is Panel) Then
|
|
|
|
For Each lcCtrlIN In lcCtrl.Controls
|
|
If TypeOf lcCtrlIN Is RadioButton Then
|
|
If Mid(Trim(lcCtrlIN.Name), 1, 4) = PrefijoRDB Then
|
|
NomCampo = Mid(Trim(lcCtrlIN.Name), 5, Len(lcCtrlIN.Name))
|
|
If Not IsDBNull(fila(Trim$(NomCampo))) Then
|
|
If fila(Trim$(NomCampo)) = 1 Then
|
|
lcCtrlIN.checked = True
|
|
Else
|
|
lcCtrlIN.checked = False
|
|
|
|
End If
|
|
|
|
Else
|
|
lcCtrlIN.checked = False
|
|
|
|
End If
|
|
|
|
End If
|
|
|
|
End If
|
|
Next
|
|
|
|
End If
|
|
Next
|
|
|
|
|
|
Catch er As Exception
|
|
MessageBox.Show("Error en ClsComplejo; sbLlenaCombo: " & er.Message, "MINDS", MessageBoxButtons.OK, MessageBoxIcon.Error)
|
|
Exit Sub
|
|
End Try
|
|
End Sub
|
|
Public Function VerificaPPE(ByVal Nombre As String) As Boolean
|
|
|
|
Dim SQLListas As String
|
|
Dim Classcom2 As New SenteciasSQL.ClassSQL
|
|
|
|
VerificaPPE = False
|
|
|
|
SQLListas = "SELECT * FROM ListaRestringida "
|
|
'SQLListas = SQLListas & " WHERE Nombre LIKE '%" & Nombre & "%'"
|
|
SQLListas = SQLListas & " WHERE Nombre LIKE '" & Nombre & "'"
|
|
SQLListas = SQLListas & " AND id_organismo = 9 "
|
|
|
|
Classcom2.fdtDataSet(SQLListas)
|
|
|
|
If Classcom2.ds.Tables(0).Rows.Count <> 0 Then
|
|
VerificaPPE = True
|
|
End If
|
|
|
|
End Function
|
|
|
|
Function ValidaRFC(ByVal Varnacionalidad As Integer, ByVal Vartipopersona As Integer, ByVal VarRFC As String) As Boolean
|
|
|
|
Try
|
|
ValidaRFC = False
|
|
|
|
If Varnacionalidad = 0 Then
|
|
|
|
|
|
Select Case Vartipopersona
|
|
Case Is = 0 'fisica
|
|
'valida la longitud
|
|
If Len(VarRFC) < 10 Then
|
|
ValidaRFC = False
|
|
Exit Function
|
|
Else
|
|
'valida los primeros 4 digitos deben de ser letras
|
|
For i As Integer = 1 To 4
|
|
Select Case Asc(Mid(VarRFC, i, 1))
|
|
Case Is < 65
|
|
ValidaRFC = False
|
|
Exit Function
|
|
Case Is > 90
|
|
ValidaRFC = False
|
|
Exit Function
|
|
End Select
|
|
Next
|
|
'valida la fecha
|
|
|
|
Dim VarFecha As String
|
|
|
|
VarFecha = Mid(Trim(VarRFC), 9, 2) & "/" & Mid(Trim(VarRFC), 7, 2) & "/" & Mid(Trim(VarRFC), 5, 2)
|
|
|
|
If Not (IsDate(VarFecha)) Then
|
|
ValidaRFC = False
|
|
Exit Function
|
|
End If
|
|
End If
|
|
|
|
Case Is = 1 'moral
|
|
'valida la longitud
|
|
If Len(VarRFC) < 12 Then
|
|
ValidaRFC = False
|
|
Exit Function
|
|
Else
|
|
'valida los primeros 3 digitos deben de ser letras
|
|
For i As Integer = 1 To 3
|
|
Select Case Asc(Mid(VarRFC, i, 1))
|
|
Case Is < 65
|
|
ValidaRFC = False
|
|
Exit Function
|
|
Case Is > 90
|
|
ValidaRFC = False
|
|
Exit Function
|
|
End Select
|
|
Next
|
|
'valida la fecha
|
|
|
|
Dim VarFecha As String
|
|
|
|
If Len(VarRFC) = 12 Then
|
|
VarFecha = Mid(Trim(VarRFC), 8, 2) & "/" & Mid(Trim(VarRFC), 6, 2) & "/" & Mid(Trim(VarRFC), 4, 2)
|
|
ElseIf Len(VarRFC) = 13 Then
|
|
VarFecha = Mid(Trim(VarRFC), 9, 2) & "/" & Mid(Trim(VarRFC), 7, 2) & "/" & Mid(Trim(VarRFC), 5, 2)
|
|
End If
|
|
|
|
|
|
If Not (IsDate(VarFecha)) Then
|
|
ValidaRFC = False
|
|
Exit Function
|
|
End If
|
|
End If
|
|
|
|
Case Is = 2 'fisica act emp
|
|
End Select
|
|
|
|
End If
|
|
|
|
ValidaRFC = True
|
|
|
|
Catch er As Exception
|
|
MessageBox.Show("Error en ClsComplejo; sbLlenaCombo: " & er.Message, "MINDS", MessageBoxButtons.OK, MessageBoxIcon.Error)
|
|
Exit Function
|
|
End Try
|
|
|
|
End Function
|
|
|
|
Public Function ValidaCampos(ByVal strParam As String, ByVal strCHAR As String) As String
|
|
|
|
Select Case UCase(strParam)
|
|
|
|
Case Is = "NUMEROS"
|
|
|
|
If InStr("0123456789", Mid(strCHAR, 1, 1).ToString, CompareMethod.Text) = 0 Then
|
|
ValidaCampos = Nothing
|
|
Else
|
|
ValidaCampos = strCHAR
|
|
End If
|
|
|
|
End Select
|
|
|
|
End Function
|
|
|
|
Public Function Isnull(ByVal varComodin As Object, ByVal varValorReturn As Object) As Object
|
|
|
|
|
|
If IsDBNull(varComodin) Then
|
|
Isnull = varValorReturn
|
|
Else
|
|
Isnull = varComodin
|
|
End If
|
|
|
|
End Function
|
|
|
|
Public Sub GuardaValoresLista(ByVal lngIDCliente As Long)
|
|
|
|
Dim sql As String
|
|
Dim Classcom As New clsComplejo
|
|
Dim Classcom2 As New SenteciasSQL.ClassSQL
|
|
|
|
Classcom.sbInserta("delete from DetLista where id_cliente = " & lngIDCliente)
|
|
|
|
If Not clsVaribles.ARR3 Is Nothing Then
|
|
|
|
sql = "INSERT INTO DetLista (id_cliente,lista,strmenu) "
|
|
sql = sql & " VALUES (" & lngIDCliente & ",'ChkPaisNacionalidad','" & Classcom2.ObtieneCadena(clsVaribles.ARR3) & "')"
|
|
Classcom = New clsComplejo
|
|
Classcom.sbInserta(sql)
|
|
End If
|
|
|
|
|
|
If Not clsVaribles.ARR4 Is Nothing Then
|
|
sql = "INSERT INTO DetLista (id_cliente,lista,strmenu) "
|
|
sql = sql & " VALUES (" & lngIDCliente & ",'CHKPaisRes','" & Classcom2.ObtieneCadena(clsVaribles.ARR4) & "')"
|
|
Classcom = New clsComplejo
|
|
Classcom.sbInserta(sql)
|
|
End If
|
|
|
|
If Not clsVaribles.ARR1 Is Nothing Then
|
|
sql = "INSERT INTO DetLista (id_cliente,lista,strmenu) "
|
|
sql = sql & " VALUES (" & lngIDCliente & ",'CHKProductos','" & Classcom2.ObtieneCadena(clsVaribles.ARR1) & "')"
|
|
Classcom = New clsComplejo
|
|
Classcom.sbInserta(sql)
|
|
End If
|
|
|
|
|
|
If Not clsVaribles.ARR2 Is Nothing Then
|
|
sql = "INSERT INTO DetLista (id_cliente,lista,strmenu) "
|
|
sql = sql & " VALUES (" & lngIDCliente & ",'CHKGiro','" & Classcom2.ObtieneCadena(clsVaribles.ARR2) & "')"
|
|
Classcom = New clsComplejo
|
|
Classcom.sbInserta(sql)
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Function ObtieneCadena(ByVal arr As System.Array) As String
|
|
|
|
Dim Cadena As String
|
|
Dim i As Integer
|
|
|
|
For i = 0 To UBound(arr)
|
|
Cadena = Cadena & arr(i) + "|"
|
|
Next
|
|
|
|
Cadena = Mid(Cadena, 1, Cadena.Length - 1)
|
|
|
|
ObtieneCadena = Cadena
|
|
|
|
End Function
|
|
|
|
Public Sub LlenaLista(ByRef Listas As CheckedListBox, ByVal varIDCliente As Long, ByVal strNombre As String)
|
|
Dim Classcom As New SenteciasSQL.ClassSQL
|
|
Dim SQL As String
|
|
Dim Cadena As String
|
|
Dim i As Integer
|
|
|
|
'Cadena = Classcom.BuscaValores("p.Orden", "Kyc_Respuestaopciones r inner join Kyc_PreguntaOpciones p on r.Id_PreguntaOpcion = p.Id_PreguntaOpcion ", "id_cliente = " & varIDCliente & " and alias = '" & strNombre & "'")
|
|
|
|
Dim fila As DataRow
|
|
SQL = "SELECT p.orden FROM Kyc_Respuestaopciones r inner join Kyc_PreguntaOpciones p on r.Id_PreguntaOpcion = p.Id_PreguntaOpcion "
|
|
SQL = SQL & "WHERE r.id_cliente = " & varIDCliente & "and alias = '" & strNombre & "'"
|
|
Classcom.fdtDataSet(SQL)
|
|
|
|
|
|
|
|
For i = 0 To Classcom.ds.Tables(0).Rows.Count - 1
|
|
|
|
fila = Classcom.ds.Tables(0).Rows(i)
|
|
|
|
Cadena = fila("orden") - 1
|
|
|
|
|
|
Listas.SetItemChecked(Cadena, True)
|
|
|
|
|
|
Next
|
|
|
|
|
|
|
|
End Sub
|
|
|
|
Public Sub LlenaLista2(ByRef Listas As CheckedListBox, ByVal varIDCliente As Long, ByVal strNombre As String)
|
|
Dim Classcom As New SenteciasSQL.ClassSQL
|
|
Dim SQL As String
|
|
Dim Cadena As String
|
|
Dim i As Integer
|
|
|
|
|
|
Dim fila As DataRow
|
|
SQL = "SELECT p.orden FROM Kyc_Respuestaopciones r inner join Kyc_PreguntaOpciones p on r.Id_PreguntaOpcion = p.Id_PreguntaOpcion "
|
|
SQL = SQL & "WHERE r.id_cliente = " & varIDCliente & "and alias = '" & strNombre & "'"
|
|
Classcom.fdtDataSet(SQL)
|
|
|
|
|
|
|
|
For i = 0 To Classcom.ds.Tables(0).Rows.Count - 1
|
|
|
|
fila = Classcom.ds.Tables(0).Rows(i)
|
|
|
|
Cadena = fila("orden") - 1
|
|
|
|
|
|
Listas.SetItemChecked(Cadena, True)
|
|
|
|
|
|
Next
|
|
|
|
|
|
|
|
End Sub
|
|
|
|
Public Function ObtenerArchivoAlarma(ByVal IdArchivo As String) As Byte()
|
|
Dim resultado As Byte()
|
|
|
|
Try
|
|
|
|
Dim strSQL As String = "Select bytes from tbl_evidencias where idarchivo =" & IdArchivo
|
|
|
|
clsVaribles.Conexion.Open()
|
|
cm.Connection = clsVaribles.Conexion
|
|
cm.CommandText = strSQL
|
|
|
|
resultado = cm.ExecuteScalar()
|
|
|
|
Catch ex As Exception
|
|
MessageBox.Show("Error en ClassSQL; ObtenerArchivoAlarma: ", "MINDS", MessageBoxButtons.OK, MessageBoxIcon.Error)
|
|
Return Nothing
|
|
End Try
|
|
|
|
clsVaribles.Conexion.Close()
|
|
|
|
Return resultado
|
|
|
|
End Function
|
|
|
|
End Class
|
|
End Namespace
|