client/Busquedas/FRMListasR.vb

1122 lines
50 KiB
VB.net

Imports System.Threading
Public Class FRMListasR
Public lbFullTextIndex As Boolean
Private Sub FRMListasR_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim CLasscom As New clsComplejo
Dim strSQL As String
Try
'strSQL = "SELECT id_organismo clave,nombreorganismo nombre FROM organismointernacional WHERE activo = 1 ORDER BY 1"
'CLasscom.sbLlenaComboESP(strSQL, Me.cmbOrganismo, "nombre")
CLasscom.sbLlenaCombo("sp_ConsultarOrgInternacionales ", cmbOrganismo)
CLasscom = New clsComplejo
'strSQL = "SELECT id_pais clave,nombre FROM pais order by nombre "
'CLasscom.sbLlenaComboESP(strSQL, Me.cmbPaises, "nombre")
CLasscom.sbLlenaCombo("sp_ConsultarPais ", cmbPaises)
Me.cmbOrganismo.SelectedIndex = -1
Me.cmbPaises.SelectedIndex = -1
Call ValidateFullTextIndex()
If Not lbFullTextIndex Then
opt_Free.Enabled = False
opt_Contents.Enabled = True
opt_Exact.Checked = True
End If
opt_Free.Enabled = True
opt_Contents.Enabled = True
opt_Exact.Checked = True
chk_Field0.Checked = True ''Campo Nombre
chk_Field3.Checked = True ''Campo Observaciones
opt_EstatusTodos.Checked = True ''Todos; activos e inactivos.
Me.Text = "Búsqueda en Listas Restringidas"
Catch ex As Exception
End Try
End Sub
Public Sub ValidateFullTextIndex()
Dim Classcom1 As New clsComplejo
Dim sSQL As String
Dim iRecords As Integer
Try
lbFullTextIndex = True
sSQL = "Select FULLTEXTSERVICEPROPERTY('IsFullTextInstalled ')"
Classcom1.fdtDataSet(sSQL)
If Classcom1.ds.Tables(0).Rows.Count <> 0 Then
If Classcom1.ds.Tables(0).Rows.Count <> 1 Then
lbFullTextIndex = False
End If
Else
lbFullTextIndex = False
End If
If Not lbFullTextIndex Then
MsgBox("No se ha instalado el servicio 'Full Text Index' en el servidor de base de datos." & vbCrLf & "Las opciones de búsqueda avanzada no estarán disponibles.", vbOKOnly + vbInformation, "Minds")
Exit Sub
End If
sSQL = "Select DATABASEPROPERTYEX('" & Classcom1.cn.Database & "','IsFulltextEnabled')"
Classcom1.fdtDataSet(sSQL)
If Classcom1.ds.Tables(0).Rows.Count <> 0 Then
If Classcom1.ds.Tables(0).Rows.Count <> 1 Then
'lbFullTextIndex = False
End If
Else
lbFullTextIndex = False
End If
If Not lbFullTextIndex Then
MsgBox("El servicio 'Full Text Index' está instalado, pero no se ha habilitado para la base de datos de Minds." & vbCrLf & "Las opciones de búsqueda avanzada no estarán disponibles.", vbOKOnly + vbInformation, "Minds")
Exit Sub
End If
Exit Sub
Catch ex As Exception
End Try
End Sub
Public Function My_CleanStr(ByVal strTheString As String, Optional ByVal strTheChars As String = "",
Optional ByVal blnIncluded As Boolean = False) As String
Dim i As Integer, l As Integer
Dim strReturn As String, strSpecials As String
strSpecials = ""
strReturn = Trim$(strTheString)
If "" = strReturn Then
Else
If "" = Trim$(strTheChars) Then
strSpecials = Chr(34) & "'|;"
ElseIf blnIncluded Then
strSpecials = Chr(34) & "'|;" & Trim$(strTheChars)
ElseIf Not blnIncluded Then
strSpecials = Trim$(strTheChars)
End If
l = Len(strSpecials)
For i = 1 To l
strReturn = Replace(strReturn, Mid(strSpecials, i, 1), " ")
Next i
End If
My_CleanStr = strReturn
End Function
Public Function My_ExtractFix(ByVal strTheString As String) As String
Dim i As Integer, intPos As Integer
Dim strReturn As String
Dim strList As String
Dim astrList() As String
strList = " AC ; A C ; CV ; C V ; DE ; DEL ; INC ; LA ; LAS ; OF ; S A ; SA ; SC ; S C ; SRL "
astrList = Split(strList, ";")
strReturn = strTheString & " "
For i = 0 To UBound(astrList)
intPos = InStr(1, strReturn, astrList(i))
If intPos > 0 Then
strReturn = Replace(strReturn, astrList(i), Space(Len(astrList(i))))
End If
Next i
My_ExtractFix = strReturn
End Function
Public Function My_OnlyOneSpc(ByVal strTheString As String) As String
'
Dim i As Integer
Dim bln1stOne As Boolean
Dim strFoo As String
Dim strReturn As String
strFoo = Trim$(strTheString)
strReturn = ""
For i = 1 To Len(strFoo)
If Mid(strFoo, i, 1) = " " Then
If bln1stOne Then
strReturn = strReturn & " "
bln1stOne = False
Else
GoTo Next_i
End If
Else
strReturn = strReturn & Mid(strFoo, i, 1)
bln1stOne = True
End If
Next_i:
Next i
My_OnlyOneSpc = Trim$(strReturn)
End Function
Public Function VerificacionListasRestringidasRiesgo(ByVal cadenaSql As String, ByVal Tipo As Integer, ByVal Porcentaje As Long, ByVal Proceso As String, ByVal FiguraFin As String, ByVal strNIC As String, ByVal strProceso As String, ByVal strWHERE As String) As Boolean
'CadenaSql : determina si es una persona o un querie con muchas personas tomadas de una tabla
'Tipo: variable entera para distinguir si se trata de un query o de una cadena (1 = query, 2 = cadena)
'Porcentaje: variable que define el porcentaje a partir del cual se van a reportar los clientes
' Fabiola Vega G.
' Carlos Cantero R.
' 15/04/2004
Dim a, nombre As Object
Dim num, num1 As Integer
Dim tam, porcen, Porcen1 As Double
Dim Tam1 As Integer, Tam2 As Integer
Dim TotalList As Long
Dim i As Long
Dim CadenaCON As String
Dim CmdSQL As String
Dim Porcen2 As Double
Dim Cadena As String
Dim strNombre As String
Dim lngId As Long
Dim l As Long
Try
VerificacionListasRestringidasRiesgo = False
porcen = 0
Porcen1 = 0
CmdSQL = "SELECT MIN(id_ListaRestringida), nombre " &
"FROM listasRestringidas " &
"WHERE nombre is NOT NULL GROUP BY nombre "
If strWHERE <> "" Then
CmdSQL = CmdSQL & " AND " & strWHERE
End If
cadenaSql = My_OnlyOneSpc(My_ExtractFix((My_CleanStr(cadenaSql & " ", "*."))))
cadenaSql = UCase(cadenaSql)
nombre = Split(cadenaSql, " ")
num1 = UBound(nombre)
'cambio que se realizo para optimizar la busqueda de nombres en listasrestringidas
'busca dentro de las conincidencias encontradas no dentro TODA la tabla de listas
CadenaCON = ""
If num1 > 0 Then
For i = 0 To num1 - 1
If i <> 0 Then
CadenaCON = CadenaCON & " OR nombre like '%" & nombre(i) & "%'"
Else
CadenaCON = CadenaCON & " AND (nombre like '%" & nombre(i) & "%'"
End If
Next i
Else
'CadenaCON = " and Nombre "
End If
CmdSQL = "SELECT id_listarestringida, nombre "
CmdSQL = CmdSQL & "FROM ListaRestringida"
CmdSQL = CmdSQL & " WHERE nombre is not null "
If num1 > 0 Then
CmdSQL = CmdSQL & CadenaCON & ") "
End If
CmdSQL = CmdSQL & " AND estatus <> 0 "
If strWHERE <> "" Then
CmdSQL = CmdSQL & " AND " & strWHERE
End If
'CmdSQL = CmdSQL & " AND nombre = 'syria'"
'CmdSQL = CmdSQL & "GROUP BY nombre "
Dim Classcom As New SenteciasSQL.ClassSQL
Classcom.fdtDataSet(CmdSQL)
If Not Classcom.ds.Tables(0).Rows.Count = 0 Then
TotalList = Classcom.ds.Tables(0).Rows.Count
Dim nombresLista(,) As Object = {{}, {}}
For i = 0 To TotalList - 1
lngId = Classcom.ds.Tables(0).Rows(i).Item(0)
strNombre = My_OnlyOneSpc(My_ExtractFix((My_CleanStr(Classcom.ds.Tables(0).Rows(i).Item(1) & " ", "*."))))
strNombre = UCase(strNombre)
'a = Split(Trim(nombresLista(1, i)), " ")
a = Split(Trim(strNombre), " ")
num = UBound(a)
porcen = 0
If num1 > -1 Then
Porcen1 = 100 / (num1 + 1)
Porcen2 = Porcen1 / 5
Porcen1 = Porcen1 - Porcen2
For l = 0 To num1
If InStr(1, strNombre, nombre(l)) <> 0 Then
porcen = porcen + Porcen1
End If
tam = (Len(nombre(l)) \ 2) + IIf(Len(nombre(l)) Mod 2 = 0, 0, 1)
Cadena = Mid(nombre(l), 1, tam)
If InStr(1, strNombre, Cadena) <> 0 Then
porcen = porcen + Porcen2
End If
Next
Tam1 = UBound(Split(Trim(cadenaSql), " ")) + 1
Tam2 = UBound(Split((strNombre), " ")) + 1
If Tam2 > Tam1 And porcen > 0 Then
porcen = porcen * (1 - ((1 / IIf(Tam2 > Tam1, Tam2, Tam1))))
Else
Tam1 = Len(Trim(cadenaSql))
Tam2 = Len(Trim(strNombre))
If Tam2 <> Tam1 And porcen > 0 Then
porcen = porcen * (1 - ((1 / IIf(Tam2 > Tam1, Tam2, Tam1))))
End If
End If
End If
If porcen > 100 Then
porcen = 99
End If
If porcen >= 95 Then
VerificacionListasRestringidasRiesgo = True
End If
Next
porcen = 0
Porcen1 = 0
Porcen2 = 0
End If 'Existen listas restringidas
Salir:
Exit Function
Catch ex As Exception
End Try
End Function
Private Sub Consultar()
Try
Dim sSQL As String
Dim sSql2 As String
Dim iField As Integer
Dim iRecords As Long
Dim iRecordsFound As Long
Dim sText As String
Dim iPais As Integer
Dim iOrganismo As Integer
Dim aText() As String
Dim sSrchChain As String
Dim iStrings As Integer
Dim sSearchFields As String
Dim Classcom1 As New clsComplejo
sText = Trim(Text_Busqueda.Text)
If sText = "" Then
MsgBox("Suministre un texto a buscar.", vbOKOnly + vbInformation)
Exit Sub
End If
If chk_Field0.CheckState = CheckState.Unchecked And chk_Field1.CheckState = CheckState.Unchecked And chk_Field2.CheckState = CheckState.Unchecked And chk_Field3.CheckState = CheckState.Unchecked Then
MsgBox("Debe seleccionar en qué campo desea buscar.", vbOKOnly + vbInformation)
chk_Field0.Focus()
Exit Sub
End If
iPais = -1
iOrganismo = -1
If cmbOrganismo.SelectedIndex <> -1 Then iOrganismo = cmbOrganismo.SelectedValue
If cmbPaises.SelectedIndex <> -1 Then iPais = cmbPaises.SelectedValue
'Campos en los que se buscará
sSearchFields = ""
If sSearchFields <> "" And chk_Field0.CheckState = CheckState.Checked Then sSearchFields = sSearchFields & ","
If chk_Field0.CheckState = CheckState.Checked Then sSearchFields = sSearchFields & chk_Field0.Tag
If sSearchFields <> "" And chk_Field1.CheckState = CheckState.Checked Then sSearchFields = sSearchFields & ","
If chk_Field1.CheckState = CheckState.Checked Then sSearchFields = sSearchFields & chk_Field1.Tag
If sSearchFields <> "" And chk_Field2.CheckState = CheckState.Checked Then sSearchFields = sSearchFields & ","
If chk_Field2.CheckState = CheckState.Checked Then sSearchFields = sSearchFields & chk_Field2.Tag
If sSearchFields <> "" And chk_Field3.CheckState = CheckState.Checked Then sSearchFields = sSearchFields & ","
If chk_Field3.CheckState = CheckState.Checked Then sSearchFields = sSearchFields & chk_Field3.Tag
If opt_Free.Checked = True Then
sSQL = "sp_ConsultarLRBuscarAproximada " & IIf(cmbOrganismo.SelectedValue <> Nothing, cmbOrganismo.SelectedValue, "NULL")
'sSQL = sSQL & "," & IIf(cmbPaises.SelectedValue <> Nothing, cmbPaises.SelectedValue & ",NULL", "NULL,''")
sSQL = sSQL & ",NULL," & IIf(txtpais.Text.Trim().Length = 0, "NULL", "'" & txtpais.Text.Trim() & "'")
sSQL = sSQL & ",'" & Text_Busqueda.Text & "'"
sSQL = sSQL & "," & chk_Field0.CheckState
sSQL = sSQL & "," & chk_Field3.CheckState
If opt_EstatusActivo.Checked Then
sSQL = sSQL & "," & 1
ElseIf opt_EstatusInactivo.Checked Then
sSQL = sSQL & "," & 0
End If
'sSQL = "SELECT"
'sSQL = sSQL & " IsNull(case LISTARESTRINGIDA.Estatus WHEN 0 THEN 'Inactivo' ELSE 'Activo' END, '') AS Estatus,"
'sSQL = sSQL & " LISTARESTRINGIDA.Nombre,"
'sSQL = sSQL & " LISTARESTRINGIDA.observaciones,"
'sSQL = sSQL & " ORGANISMOINTERNACIONAL.nombreorganismo as Organismo,"
''sSQL = sSQL & " PAIS.PaisNom as Pais,"
'sSQL = sSQL & " LISTARESTRINGIDA.PaisTxt as Pais,"
'sSQL = sSQL & " LISTARESTRINGIDA.CmpAux01 as FNac,"
'sSQL = sSQL & " LISTARESTRINGIDA.CmpAux02 as Puesto,"
'sSQL = sSQL & " LISTARESTRINGIDA.CmpAux03 as Direccion1"
''sSQL = sSQL & " LISTARESTRINGIDA.CmpAux04 as Direccion2,"
''sSQL = sSQL & " LISTARESTRINGIDA.Observaciones"
'sSQL = sSQL & " From"
'sSQL = sSQL & " LISTARESTRINGIDA"
'sSQL = sSQL & " INNER JOIN FREETEXTTABLE(LISTARESTRINGIDA,(" & sSearchFields & "), '" & sText & "') AS KEY_TBL ON LISTARESTRINGIDA.Id_ListaRestringida = KEY_TBL.[KEY]"
'sSQL = sSQL & " left outer join ORGANISMOINTERNACIONAL ON LISTARESTRINGIDA.ID_Organismo = ORGANISMOINTERNACIONAL.ID_Organismo"
'sSQL = sSQL & " Left outer join PAIS ON LISTARESTRINGIDA.ID_Pais = PAIS.ID_Pais"
'If iOrganismo <> -1 Or iPais <> -1 Or opt_EstatusActivo.Checked Or opt_EstatusInactivo.Checked Then sSQL = sSQL & " WHERE"
'If iOrganismo <> -1 And iOrganismo = 0 Then sSQL = sSQL & " (LISTARESTRINGIDA.ID_Organismo = 0 OR LISTARESTRINGIDA.ID_Organismo IS NULL)"
'If iOrganismo <> -1 And iOrganismo <> 0 Then sSQL = sSQL & " LISTARESTRINGIDA.ID_Organismo = " & CStr(iOrganismo)
'If iOrganismo <> -1 And iPais <> -1 Then sSQL = sSQL & " AND"
'If iPais <> -1 Then
' sSQL = sSQL & " (PAIS.ID_Pais= " & CStr(iPais)
' sSQL = sSQL & " OR UPPER(LISTARESTRINGIDA.PaisTxt) = '" & UCase(Trim(cmbPaises.Text)) & "' )"
'End If
'If opt_EstatusActivo.Checked Or opt_EstatusInactivo.Checked Then
' If iOrganismo <> -1 Or iPais <> -1 Then sSQL = sSQL & " AND"
' If opt_EstatusActivo.Checked Then sSQL = sSQL & " LISTARESTRINGIDA.Estatus = 1"
' If opt_EstatusInactivo.Checked Then sSQL = sSQL & " LISTARESTRINGIDA.Estatus = 0"
'End If
'sSQL = sSQL & " order by KEY_TBL.rank desc"
ElseIf opt_Contents.Checked = True Then
''Parametros del store
'@NomBuscar as varchar(200),
'@IdOrganismo as int = NULL,
'@IdPais as int = NULL,
'@IdEstatus as int = NULL,
'@Campos as varchar(200) = NULL
sSQL = "EXEC spListaRPorcentaje60 "
sSQL = sSQL & Chr(39) & sText & Chr(39) 'KAZUHIRO HARAGUCHI', NULL, NULL, NULL, NULL"
If cmbOrganismo.SelectedIndex <> -1 Then
sSQL = sSQL & "," & cmbOrganismo.SelectedValue
Else
sSQL = sSQL & ",NULL "
End If
If cmbPaises.SelectedIndex <> -1 Then
sSQL = sSQL & "," & cmbPaises.SelectedValue
Else
sSQL = sSQL & ",NULL "
End If
If opt_EstatusActivo.Checked Then
sSQL = sSQL & ",1 "
ElseIf opt_EstatusInactivo.Checked Then
sSQL = sSQL & ",0 "
ElseIf opt_EstatusTodos.Checked Then
sSQL = sSQL & ",NULL "
Else
sSQL = sSQL & ",NULL "
End If
'Buscar en el campo Nombre o observaciones'
If chk_Field0.Checked = True And chk_Field3.Checked = True Then
sSQL = sSQL & ", 'NombreCompleto, Observaciones'"
ElseIf chk_Field0.Checked = True And chk_Field3.Checked = False Then
sSQL = sSQL & ", 'NombreCompleto'"
ElseIf chk_Field0.Checked = False And chk_Field3.Checked = True Then
sSQL = sSQL & ", 'Observaciones'"
ElseIf chk_Field0.Checked = False And chk_Field3.Checked = False Then
sSQL = sSQL & ", 'NULL' "
End If
''Arma la búsqueda separando las palabras
'aText = Split(sText, " ", , vbTextCompare)
'sSrchChain = "'("
'For iStrings = 0 To UBound(aText)
' If iStrings <> 0 Then sSrchChain = sSrchChain & " NEAR "
' sSrchChain = sSrchChain & """" & aText(iStrings) & "*"""
'Next iStrings
'sSrchChain = sSrchChain & ")'"
'sSQL = "SELECT"
'sSQL = sSQL & " IsNull(case LISTARESTRINGIDA.Estatus WHEN 0 THEN 'Inactivo' ELSE 'Activo' END, '') AS Estatus,"
'sSQL = sSQL & " LISTARESTRINGIDA.Nombre,"
'sSQL = sSQL & " LISTARESTRINGIDA.observaciones,"
'sSQL = sSQL & " ORGANISMOINTERNACIONAL.nombreorganismo as Organismo,"
''sSQL = sSQL & " PAIS.PaisNom as Pais,"
'sSQL = sSQL & " LISTARESTRINGIDA.PaisTxt as Pais,"
'sSQL = sSQL & " LISTARESTRINGIDA.CmpAux01 as FNac,"
'sSQL = sSQL & " LISTARESTRINGIDA.CmpAux02 as Puesto,"
'sSQL = sSQL & " LISTARESTRINGIDA.CmpAux03 as Direccion1"
''sSQL = sSQL & " LISTARESTRINGIDA.CmpAux04 as Direccion2,"
''sSQL = sSQL & " LISTARESTRINGIDA.observaciones"
'sSQL = sSQL & " From"
'sSQL = sSQL & " LISTARESTRINGIDA"
'sSQL = sSQL & " INNER JOIN CONTAINSTABLE(LISTARESTRINGIDA, (" & sSearchFields & "), " & sSrchChain & ") AS KEY_TBL ON LISTARESTRINGIDA.Id_ListaRestringida = KEY_TBL.[KEY]"
'sSQL = sSQL & " left outer join ORGANISMOINTERNACIONAL ON LISTARESTRINGIDA.ID_Organismo = ORGANISMOINTERNACIONAL.ID_Organismo"
'sSQL = sSQL & " Left outer join PAIS ON LISTARESTRINGIDA.ID_Pais = PAIS.ID_Pais"
'If iOrganismo <> -1 Or iPais <> -1 Or opt_EstatusActivo.Checked Or opt_EstatusInactivo.Checked Then sSQL = sSQL & " WHERE"
'If iOrganismo <> -1 And iOrganismo = 0 Then sSQL = sSQL & " (LISTARESTRINGIDA.ID_Organismo = 0 OR LISTARESTRINGIDA.ID_Organismo IS NULL)"
'If iOrganismo <> -1 And iOrganismo <> 0 Then sSQL = sSQL & " LISTARESTRINGIDA.ID_Organismo = " & CStr(iOrganismo)
'If iOrganismo <> -1 And iPais <> -1 Then sSQL = sSQL & " AND"
'If iPais <> -1 Then
' sSQL = sSQL & " (PAIS.ID_Pais= " & CStr(iPais)
' sSQL = sSQL & " OR UPPER(LISTARESTRINGIDA.PaisTxt) = '" & UCase(Trim(cmbPaises.Text)) & "' )"
'End If
'If opt_EstatusActivo.Checked Or opt_EstatusInactivo.Checked Then
' If iOrganismo <> -1 Or iPais <> -1 Then sSQL = sSQL & " AND"
' If opt_EstatusActivo.Checked Then sSQL = sSQL & " LISTARESTRINGIDA.Estatus = 1"
' If opt_EstatusInactivo.Checked Then sSQL = sSQL & " LISTARESTRINGIDA.Estatus = 0"
'End If
'sSQL = sSQL & " order by KEY_TBL.rank desc"
ElseIf opt_Exact.Checked = True Then
'sp_ConsultarLRBuscarAproximada
sSQL = "sp_ConsultarLRBuscarExacta " & IIf(cmbOrganismo.SelectedValue <> Nothing, cmbOrganismo.SelectedValue, "NULL")
sSQL = sSQL & "," & IIf(cmbPaises.SelectedValue <> Nothing, cmbPaises.SelectedValue & ",NULL", "NULL,''")
sSQL = sSQL & ",'" & Text_Busqueda.Text & "'"
sSQL = sSQL & "," & chk_Field0.CheckState
sSQL = sSQL & "," & chk_Field3.CheckState
If opt_EstatusActivo.Checked Then
sSQL = sSQL & "," & 1
ElseIf opt_EstatusInactivo.Checked Then
sSQL = sSQL & "," & 0
End If
'sSQL = "SELECT"
'sSQL = sSQL & " IsNull(case LISTARESTRINGIDA.Estatus WHEN 0 THEN 'Inactivo' ELSE 'Activo' END, '') AS Estatus,"
'sSQL = sSQL & " LISTARESTRINGIDA.Nombre,"
'sSQL = sSQL & " LISTARESTRINGIDA.observaciones,"
'sSQL = sSQL & " ORGANISMOINTERNACIONAL.nombreorganismo as Organismo,"
''sSQL = sSQL & " PAIS.PaisNom as Pais,"
'sSQL = sSQL & " LISTARESTRINGIDA.PaisTxt as Pais,"
'sSQL = sSQL & " LISTARESTRINGIDA.CmpAux01 as FNac,"
'sSQL = sSQL & " LISTARESTRINGIDA.CmpAux02 as Puesto,"
'sSQL = sSQL & " LISTARESTRINGIDA.CmpAux03 as Direccion1"
''sSQL = sSQL & " LISTARESTRINGIDA.CmpAux04 as Direccion2,"
''sSQL = sSQL & " LISTARESTRINGIDA.Observaciones"
'sSQL = sSQL & " From"
'sSQL = sSQL & " LISTARESTRINGIDA"
'sSQL = sSQL & " Left outer join ORGANISMOINTERNACIONAL ON LISTARESTRINGIDA.ID_Organismo = ORGANISMOINTERNACIONAL.ID_Organismo"
'sSQL = sSQL & " Left outer join PAIS ON LISTARESTRINGIDA.ID_Pais = PAIS.ID_Pais"
'sSQL = sSQL & " WHERE "
''Separamos las palabras para poder buscar con un and
'aText = Split(sText, " ", , vbTextCompare)
'sSql2 = ""
'If sSql2 <> "" And chk_Field0.CheckState = CheckState.Checked Then sSql2 = sSql2 & " OR "
'If chk_Field0.CheckState = CheckState.Checked Then
' sSql2 = sSql2 & " ("
' For iStrings = 0 To UBound(aText)
' If iStrings <> 0 Then
' sSql2 = sSql2 & " AND UPPER(LISTARESTRINGIDA." & chk_Field0.Tag & ") like '%" & UCase(aText(iStrings)) & "%'"
' Else
' sSql2 = sSql2 & "UPPER(LISTARESTRINGIDA." & chk_Field0.Tag & ") like '%" & UCase(aText(iStrings)) & "%'"
' End If
' Next iStrings
' sSql2 = sSql2 & ")"
'End If
'If sSql2 <> "" And chk_Field1.CheckState = CheckState.Checked Then sSql2 = sSql2 & " OR "
'If chk_Field1.CheckState = CheckState.Checked Then
' sSql2 = sSql2 & " ("
' For iStrings = 0 To UBound(aText)
' If iStrings <> 0 Then
' sSql2 = sSql2 & " AND UPPER(LISTARESTRINGIDA." & chk_Field1.Tag & ") like '%" & UCase(aText(iStrings)) & "%'"
' Else
' sSql2 = sSql2 & "UPPER(LISTARESTRINGIDA." & chk_Field1.Tag & ") like '%" & UCase(aText(iStrings)) & "%'"
' End If
' Next iStrings
' sSql2 = sSql2 & ")"
'End If
'If sSql2 <> "" And chk_Field2.CheckState = CheckState.Checked Then sSql2 = sSql2 & " OR "
'If chk_Field2.CheckState = CheckState.Checked Then
' sSql2 = sSql2 & " ("
' For iStrings = 0 To UBound(aText)
' If iStrings <> 0 Then
' sSql2 = sSql2 & " AND UPPER(LISTARESTRINGIDA." & chk_Field2.Tag & ") like '%" & UCase(aText(iStrings)) & "%'"
' Else
' sSql2 = sSql2 & "UPPER(LISTARESTRINGIDA." & chk_Field2.Tag & ") like '%" & UCase(aText(iStrings)) & "%'"
' End If
' Next iStrings
' sSql2 = sSql2 & ")"
'End If
'If sSql2 <> "" And chk_Field3.CheckState = CheckState.Checked Then sSql2 = sSql2 & " OR "
'If chk_Field3.CheckState = CheckState.Checked Then
' sSql2 = sSql2 & " ("
' For iStrings = 0 To UBound(aText)
' If iStrings <> 0 Then
' sSql2 = sSql2 & " AND UPPER(LISTARESTRINGIDA." & chk_Field3.Tag & ") like '%" & UCase(aText(iStrings)) & "%'"
' Else
' sSql2 = sSql2 & "UPPER(LISTARESTRINGIDA." & chk_Field3.Tag & ") like '%" & UCase(aText(iStrings)) & "%'"
' End If
' Next iStrings
' sSql2 = sSql2 & ")"
'End If
'sSQL = sSQL & "(" & sSql2 & ")"
'If iOrganismo <> -1 And iOrganismo = 0 Then sSQL = sSQL & " AND (LISTARESTRINGIDA.ID_Organismo = 0 OR LISTARESTRINGIDA.ID_Organismo IS NULL)"
'If iOrganismo <> -1 And iOrganismo <> 0 Then sSQL = sSQL & " AND LISTARESTRINGIDA.ID_Organismo = " & CStr(iOrganismo)
'If iPais <> -1 Then
' sSQL = sSQL & " AND (PAIS.ID_Pais= " & CStr(iPais)
' sSQL = sSQL & " OR UPPER(LISTARESTRINGIDA.PaisTxt) = '" & UCase(Trim(cmbPaises.Text)) & "' )"
'End If
'If opt_EstatusActivo.Checked Then sSQL = sSQL & " AND LISTARESTRINGIDA.Estatus = 1"
'If opt_EstatusInactivo.Checked Then sSQL = sSQL & " AND LISTARESTRINGIDA.Estatus = 0"
'sSQL = sSQL & " order by LISTARESTRINGIDA.Nombre"
End If
'recSearch = Nothing
Dim ClassCatalogos As New ClassCatalogos
Dim ds As DataSet
'Screen.MousePointer = vbHourglass
clsVaribles.strSQL = sSQL
'ds = Classcom1.fdtDataSetTabla(sSQL)
'grBox.Visible = True
Classcom1.sbLlenaDataGridView(sSQL, DGVResultados)
' grBox.Visible = False
'DGVResultados.DataSource = ds.Tables(0).DefaultView
'ClassCatalogos.LlenaGrid(sSQL, Me.dataGrid1)
'Dim s1 As New C1.Win.C1TrueDBGrid.Style
's1.ForeColor = Color.Black
'dataGrid1.Splits(0).DisplayColumns(1).AddRegexCellStyle(C1.Win.C1TrueDBGrid.CellStyleFlag.AllCells, s1, "NOMBRECOMPLETO")
'DataGridView1.DataSource = Classcom1.ds
'Me.dataGrid1.SetDataBinding(Classcom1.ds, "tabla")
'dataGrid1.Visible = True
' grd_Busqueda.ForeColor = Color.Black
iRecordsFound = 0
If Classcom1.ds.Tables(0).Rows.Count = 0 Then
MsgBox("No se encontraron datos para los criterios de búsqueda suministrados.", vbOKOnly + vbInformation)
Else
iRecordsFound = Classcom1.ds.Tables(0).Rows.Count
End If
lbl_Records.Text = CStr(iRecordsFound) & " Registros."
lbl_Records.Visible = True
Exit Sub
Catch ex As Exception
End Try
End Sub
Private Sub CmdBusqueda_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CmdBusqueda.Click
Dim trd As Thread
Try
Dim sSQL As String
Dim sSql2 As String
Dim iField As Integer
Dim iRecords As Long
Dim iRecordsFound As Long
Dim sText As String
Dim iPais As Integer
Dim iOrganismo As Integer
Dim aText() As String
Dim sSrchChain As String
Dim iStrings As Integer
Dim sSearchFields As String
Dim Classcom1 As New clsComplejo
Dim c As Cursor = Me.Cursor
sText = Trim(Text_Busqueda.Text.Trim)
If sText = "" Then
MsgBox("Suministre un texto a buscar.", vbOKOnly + vbInformation)
Exit Sub
End If
If chk_Field0.CheckState = CheckState.Unchecked And chk_Field1.CheckState = CheckState.Unchecked And chk_Field2.CheckState = CheckState.Unchecked And chk_Field3.CheckState = CheckState.Unchecked Then
MsgBox("Debe seleccionar en qué campo desea buscar.", vbOKOnly + vbInformation)
chk_Field0.Focus()
Exit Sub
End If
iPais = -1
iOrganismo = -1
If cmbOrganismo.SelectedIndex <> -1 Then iOrganismo = cmbOrganismo.SelectedValue
If cmbPaises.SelectedIndex <> -1 Then iPais = cmbPaises.SelectedValue
'Campos en los que se buscará
sSearchFields = ""
If sSearchFields <> "" And chk_Field0.CheckState = CheckState.Checked Then sSearchFields = sSearchFields & ","
If chk_Field0.CheckState = CheckState.Checked Then sSearchFields = sSearchFields & chk_Field0.Tag
If sSearchFields <> "" And chk_Field1.CheckState = CheckState.Checked Then sSearchFields = sSearchFields & ","
If chk_Field1.CheckState = CheckState.Checked Then sSearchFields = sSearchFields & chk_Field1.Tag
If sSearchFields <> "" And chk_Field2.CheckState = CheckState.Checked Then sSearchFields = sSearchFields & ","
If chk_Field2.CheckState = CheckState.Checked Then sSearchFields = sSearchFields & chk_Field2.Tag
If sSearchFields <> "" And chk_Field3.CheckState = CheckState.Checked Then sSearchFields = sSearchFields & ","
If chk_Field3.CheckState = CheckState.Checked Then sSearchFields = sSearchFields & chk_Field3.Tag
If opt_Free.Checked = True Then
sSQL = "sp_ConsultarLRBuscarAproximada " & IIf(cmbOrganismo.SelectedValue <> Nothing, cmbOrganismo.SelectedValue, "NULL")
'sSQL = sSQL & "," & IIf(cmbPaises.SelectedValue <> Nothing, cmbPaises.SelectedValue & ",NULL", "NULL,''")
sSQL = sSQL & ",NULL," & IIf(txtpais.Text.Trim().Length = 0, "NULL", "'" & txtpais.Text.Trim() & "'")
sSQL = sSQL & ",'" & Text_Busqueda.Text.Trim & "'"
sSQL = sSQL & "," & chk_Field0.CheckState
sSQL = sSQL & "," & chk_Field3.CheckState
If opt_EstatusActivo.Checked Then
sSQL = sSQL & "," & 1
ElseIf opt_EstatusInactivo.Checked Then
sSQL = sSQL & "," & 0
End If
'sSQL = "SELECT"
'sSQL = sSQL & " IsNull(case LISTARESTRINGIDA.Estatus WHEN 0 THEN 'Inactivo' ELSE 'Activo' END, '') AS Estatus,"
'sSQL = sSQL & " LISTARESTRINGIDA.Nombre,"
'sSQL = sSQL & " LISTARESTRINGIDA.observaciones,"
'sSQL = sSQL & " ORGANISMOINTERNACIONAL.nombreorganismo as Organismo,"
''sSQL = sSQL & " PAIS.PaisNom as Pais,"
'sSQL = sSQL & " LISTARESTRINGIDA.PaisTxt as Pais,"
'sSQL = sSQL & " LISTARESTRINGIDA.CmpAux01 as FNac,"
'sSQL = sSQL & " LISTARESTRINGIDA.CmpAux02 as Puesto,"
'sSQL = sSQL & " LISTARESTRINGIDA.CmpAux03 as Direccion1"
''sSQL = sSQL & " LISTARESTRINGIDA.CmpAux04 as Direccion2,"
''sSQL = sSQL & " LISTARESTRINGIDA.Observaciones"
'sSQL = sSQL & " From"
'sSQL = sSQL & " LISTARESTRINGIDA"
'sSQL = sSQL & " INNER JOIN FREETEXTTABLE(LISTARESTRINGIDA,(" & sSearchFields & "), '" & sText & "') AS KEY_TBL ON LISTARESTRINGIDA.Id_ListaRestringida = KEY_TBL.[KEY]"
'sSQL = sSQL & " left outer join ORGANISMOINTERNACIONAL ON LISTARESTRINGIDA.ID_Organismo = ORGANISMOINTERNACIONAL.ID_Organismo"
'sSQL = sSQL & " Left outer join PAIS ON LISTARESTRINGIDA.ID_Pais = PAIS.ID_Pais"
'If iOrganismo <> -1 Or iPais <> -1 Or opt_EstatusActivo.Checked Or opt_EstatusInactivo.Checked Then sSQL = sSQL & " WHERE"
'If iOrganismo <> -1 And iOrganismo = 0 Then sSQL = sSQL & " (LISTARESTRINGIDA.ID_Organismo = 0 OR LISTARESTRINGIDA.ID_Organismo IS NULL)"
'If iOrganismo <> -1 And iOrganismo <> 0 Then sSQL = sSQL & " LISTARESTRINGIDA.ID_Organismo = " & CStr(iOrganismo)
'If iOrganismo <> -1 And iPais <> -1 Then sSQL = sSQL & " AND"
'If iPais <> -1 Then
' sSQL = sSQL & " (PAIS.ID_Pais= " & CStr(iPais)
' sSQL = sSQL & " OR UPPER(LISTARESTRINGIDA.PaisTxt) = '" & UCase(Trim(cmbPaises.Text)) & "' )"
'End If
'If opt_EstatusActivo.Checked Or opt_EstatusInactivo.Checked Then
' If iOrganismo <> -1 Or iPais <> -1 Then sSQL = sSQL & " AND"
' If opt_EstatusActivo.Checked Then sSQL = sSQL & " LISTARESTRINGIDA.Estatus = 1"
' If opt_EstatusInactivo.Checked Then sSQL = sSQL & " LISTARESTRINGIDA.Estatus = 0"
'End If
'sSQL = sSQL & " order by KEY_TBL.rank desc"
ElseIf opt_Contents.Checked = True Then
''Parametros del store
'@NomBuscar as varchar(200),
'@IdOrganismo as int = NULL,
'@IdPais as int = NULL,
'@IdEstatus as int = NULL,
'@Campos as varchar(200) = NULL
sSQL = "EXEC spListaRPorcentaje60 "
sSQL = sSQL & Chr(39) & sText & Chr(39) 'KAZUHIRO HARAGUCHI', NULL, NULL, NULL, NULL"
If cmbOrganismo.SelectedIndex <> -1 Then
sSQL = sSQL & "," & cmbOrganismo.SelectedValue
Else
sSQL = sSQL & ",NULL "
End If
If cmbPaises.SelectedIndex <> -1 Then
sSQL = sSQL & "," & cmbPaises.SelectedValue
Else
sSQL = sSQL & ",NULL "
End If
If opt_EstatusActivo.Checked Then
sSQL = sSQL & ",1 "
ElseIf opt_EstatusInactivo.Checked Then
sSQL = sSQL & ",0 "
ElseIf opt_EstatusTodos.Checked Then
sSQL = sSQL & ",NULL "
Else
sSQL = sSQL & ",NULL "
End If
'Buscar en el campo Nombre o observaciones'
If chk_Field0.Checked = True And chk_Field3.Checked = True Then
sSQL = sSQL & ", 'NombreCompleto, Observaciones'"
ElseIf chk_Field0.Checked = True And chk_Field3.Checked = False Then
sSQL = sSQL & ", 'NombreCompleto'"
ElseIf chk_Field0.Checked = False And chk_Field3.Checked = True Then
sSQL = sSQL & ", 'Observaciones'"
ElseIf chk_Field0.Checked = False And chk_Field3.Checked = False Then
sSQL = sSQL & ", 'NULL' "
End If
''Arma la búsqueda separando las palabras
'aText = Split(sText, " ", , vbTextCompare)
'sSrchChain = "'("
'For iStrings = 0 To UBound(aText)
' If iStrings <> 0 Then sSrchChain = sSrchChain & " NEAR "
' sSrchChain = sSrchChain & """" & aText(iStrings) & "*"""
'Next iStrings
'sSrchChain = sSrchChain & ")'"
'sSQL = "SELECT"
'sSQL = sSQL & " IsNull(case LISTARESTRINGIDA.Estatus WHEN 0 THEN 'Inactivo' ELSE 'Activo' END, '') AS Estatus,"
'sSQL = sSQL & " LISTARESTRINGIDA.Nombre,"
'sSQL = sSQL & " LISTARESTRINGIDA.observaciones,"
'sSQL = sSQL & " ORGANISMOINTERNACIONAL.nombreorganismo as Organismo,"
''sSQL = sSQL & " PAIS.PaisNom as Pais,"
'sSQL = sSQL & " LISTARESTRINGIDA.PaisTxt as Pais,"
'sSQL = sSQL & " LISTARESTRINGIDA.CmpAux01 as FNac,"
'sSQL = sSQL & " LISTARESTRINGIDA.CmpAux02 as Puesto,"
'sSQL = sSQL & " LISTARESTRINGIDA.CmpAux03 as Direccion1"
''sSQL = sSQL & " LISTARESTRINGIDA.CmpAux04 as Direccion2,"
''sSQL = sSQL & " LISTARESTRINGIDA.observaciones"
'sSQL = sSQL & " From"
'sSQL = sSQL & " LISTARESTRINGIDA"
'sSQL = sSQL & " INNER JOIN CONTAINSTABLE(LISTARESTRINGIDA, (" & sSearchFields & "), " & sSrchChain & ") AS KEY_TBL ON LISTARESTRINGIDA.Id_ListaRestringida = KEY_TBL.[KEY]"
'sSQL = sSQL & " left outer join ORGANISMOINTERNACIONAL ON LISTARESTRINGIDA.ID_Organismo = ORGANISMOINTERNACIONAL.ID_Organismo"
'sSQL = sSQL & " Left outer join PAIS ON LISTARESTRINGIDA.ID_Pais = PAIS.ID_Pais"
'If iOrganismo <> -1 Or iPais <> -1 Or opt_EstatusActivo.Checked Or opt_EstatusInactivo.Checked Then sSQL = sSQL & " WHERE"
'If iOrganismo <> -1 And iOrganismo = 0 Then sSQL = sSQL & " (LISTARESTRINGIDA.ID_Organismo = 0 OR LISTARESTRINGIDA.ID_Organismo IS NULL)"
'If iOrganismo <> -1 And iOrganismo <> 0 Then sSQL = sSQL & " LISTARESTRINGIDA.ID_Organismo = " & CStr(iOrganismo)
'If iOrganismo <> -1 And iPais <> -1 Then sSQL = sSQL & " AND"
'If iPais <> -1 Then
' sSQL = sSQL & " (PAIS.ID_Pais= " & CStr(iPais)
' sSQL = sSQL & " OR UPPER(LISTARESTRINGIDA.PaisTxt) = '" & UCase(Trim(cmbPaises.Text)) & "' )"
'End If
'If opt_EstatusActivo.Checked Or opt_EstatusInactivo.Checked Then
' If iOrganismo <> -1 Or iPais <> -1 Then sSQL = sSQL & " AND"
' If opt_EstatusActivo.Checked Then sSQL = sSQL & " LISTARESTRINGIDA.Estatus = 1"
' If opt_EstatusInactivo.Checked Then sSQL = sSQL & " LISTARESTRINGIDA.Estatus = 0"
'End If
'sSQL = sSQL & " order by KEY_TBL.rank desc"
ElseIf opt_Exact.Checked = True Then
'sp_ConsultarLRBuscarAproximada
sSQL = "sp_ConsultarLRBuscarExacta " & IIf(cmbOrganismo.SelectedValue <> Nothing, cmbOrganismo.SelectedValue, "NULL")
sSQL = sSQL & "," & IIf(cmbPaises.SelectedValue <> Nothing, cmbPaises.SelectedValue & ",NULL", "NULL,''")
sSQL = sSQL & ",'" & Text_Busqueda.Text.Trim & "'"
sSQL = sSQL & "," & chk_Field0.CheckState
sSQL = sSQL & "," & chk_Field3.CheckState
If opt_EstatusActivo.Checked Then
sSQL = sSQL & "," & 1
ElseIf opt_EstatusInactivo.Checked Then
sSQL = sSQL & "," & 0
End If
'sSQL = "SELECT"
'sSQL = sSQL & " IsNull(case LISTARESTRINGIDA.Estatus WHEN 0 THEN 'Inactivo' ELSE 'Activo' END, '') AS Estatus,"
'sSQL = sSQL & " LISTARESTRINGIDA.Nombre,"
'sSQL = sSQL & " LISTARESTRINGIDA.observaciones,"
'sSQL = sSQL & " ORGANISMOINTERNACIONAL.nombreorganismo as Organismo,"
''sSQL = sSQL & " PAIS.PaisNom as Pais,"
'sSQL = sSQL & " LISTARESTRINGIDA.PaisTxt as Pais,"
'sSQL = sSQL & " LISTARESTRINGIDA.CmpAux01 as FNac,"
'sSQL = sSQL & " LISTARESTRINGIDA.CmpAux02 as Puesto,"
'sSQL = sSQL & " LISTARESTRINGIDA.CmpAux03 as Direccion1"
''sSQL = sSQL & " LISTARESTRINGIDA.CmpAux04 as Direccion2,"
''sSQL = sSQL & " LISTARESTRINGIDA.Observaciones"
'sSQL = sSQL & " From"
'sSQL = sSQL & " LISTARESTRINGIDA"
'sSQL = sSQL & " Left outer join ORGANISMOINTERNACIONAL ON LISTARESTRINGIDA.ID_Organismo = ORGANISMOINTERNACIONAL.ID_Organismo"
'sSQL = sSQL & " Left outer join PAIS ON LISTARESTRINGIDA.ID_Pais = PAIS.ID_Pais"
'sSQL = sSQL & " WHERE "
''Separamos las palabras para poder buscar con un and
'aText = Split(sText, " ", , vbTextCompare)
'sSql2 = ""
'If sSql2 <> "" And chk_Field0.CheckState = CheckState.Checked Then sSql2 = sSql2 & " OR "
'If chk_Field0.CheckState = CheckState.Checked Then
' sSql2 = sSql2 & " ("
' For iStrings = 0 To UBound(aText)
' If iStrings <> 0 Then
' sSql2 = sSql2 & " AND UPPER(LISTARESTRINGIDA." & chk_Field0.Tag & ") like '%" & UCase(aText(iStrings)) & "%'"
' Else
' sSql2 = sSql2 & "UPPER(LISTARESTRINGIDA." & chk_Field0.Tag & ") like '%" & UCase(aText(iStrings)) & "%'"
' End If
' Next iStrings
' sSql2 = sSql2 & ")"
'End If
'If sSql2 <> "" And chk_Field1.CheckState = CheckState.Checked Then sSql2 = sSql2 & " OR "
'If chk_Field1.CheckState = CheckState.Checked Then
' sSql2 = sSql2 & " ("
' For iStrings = 0 To UBound(aText)
' If iStrings <> 0 Then
' sSql2 = sSql2 & " AND UPPER(LISTARESTRINGIDA." & chk_Field1.Tag & ") like '%" & UCase(aText(iStrings)) & "%'"
' Else
' sSql2 = sSql2 & "UPPER(LISTARESTRINGIDA." & chk_Field1.Tag & ") like '%" & UCase(aText(iStrings)) & "%'"
' End If
' Next iStrings
' sSql2 = sSql2 & ")"
'End If
'If sSql2 <> "" And chk_Field2.CheckState = CheckState.Checked Then sSql2 = sSql2 & " OR "
'If chk_Field2.CheckState = CheckState.Checked Then
' sSql2 = sSql2 & " ("
' For iStrings = 0 To UBound(aText)
' If iStrings <> 0 Then
' sSql2 = sSql2 & " AND UPPER(LISTARESTRINGIDA." & chk_Field2.Tag & ") like '%" & UCase(aText(iStrings)) & "%'"
' Else
' sSql2 = sSql2 & "UPPER(LISTARESTRINGIDA." & chk_Field2.Tag & ") like '%" & UCase(aText(iStrings)) & "%'"
' End If
' Next iStrings
' sSql2 = sSql2 & ")"
'End If
'If sSql2 <> "" And chk_Field3.CheckState = CheckState.Checked Then sSql2 = sSql2 & " OR "
'If chk_Field3.CheckState = CheckState.Checked Then
' sSql2 = sSql2 & " ("
' For iStrings = 0 To UBound(aText)
' If iStrings <> 0 Then
' sSql2 = sSql2 & " AND UPPER(LISTARESTRINGIDA." & chk_Field3.Tag & ") like '%" & UCase(aText(iStrings)) & "%'"
' Else
' sSql2 = sSql2 & "UPPER(LISTARESTRINGIDA." & chk_Field3.Tag & ") like '%" & UCase(aText(iStrings)) & "%'"
' End If
' Next iStrings
' sSql2 = sSql2 & ")"
'End If
'sSQL = sSQL & "(" & sSql2 & ")"
'If iOrganismo <> -1 And iOrganismo = 0 Then sSQL = sSQL & " AND (LISTARESTRINGIDA.ID_Organismo = 0 OR LISTARESTRINGIDA.ID_Organismo IS NULL)"
'If iOrganismo <> -1 And iOrganismo <> 0 Then sSQL = sSQL & " AND LISTARESTRINGIDA.ID_Organismo = " & CStr(iOrganismo)
'If iPais <> -1 Then
' sSQL = sSQL & " AND (PAIS.ID_Pais= " & CStr(iPais)
' sSQL = sSQL & " OR UPPER(LISTARESTRINGIDA.PaisTxt) = '" & UCase(Trim(cmbPaises.Text)) & "' )"
'End If
'If opt_EstatusActivo.Checked Then sSQL = sSQL & " AND LISTARESTRINGIDA.Estatus = 1"
'If opt_EstatusInactivo.Checked Then sSQL = sSQL & " AND LISTARESTRINGIDA.Estatus = 0"
'sSQL = sSQL & " order by LISTARESTRINGIDA.Nombre"
End If
'recSearch = Nothing
Dim ClassCatalogos As New ClassCatalogos
Dim ds As DataSet
'Screen.MousePointer = vbHourglass
clsVaribles.strSQL = sSQL
'ds = Classcom1.fdtDataSetTabla(sSQL)
' grBox.Visible = True
Me.Cursor = Cursors.WaitCursor
'Classcom1.sbLlenaDataGridView(sSQL, DGVResultados)
' grBox.Visible = False
'DGVResultados.DataSource = ds.Tables(0).DefaultView
ClassCatalogos.LlenaGrid(sSQL, Me.dataGrid1)
'Dim s1 As New C1.Win.C1TrueDBGrid.Style
's1.ForeColor = Color.Black
'dataGrid1.Splits(0).DisplayColumns(1).AddRegexCellStyle(C1.Win.C1TrueDBGrid.CellStyleFlag.AllCells, s1, "NOMBRECOMPLETO")
'DataGridView1.DataSource = Classcom1.ds
'Me.dataGrid1.SetDataBinding(Classcom1.ds, "tabla")
'dataGrid1.Visible = True
' grd_Busqueda.ForeColor = Color.Black
'iRecordsFound = 0
' If Classcom1.ds.Tables(0).Rows.Count = 0 Then
'MsgBox("No se encontraron datos para los criterios de búsqueda suministrados.", vbOKOnly + vbInformation)
'Else
' iRecordsFound = Classcom1.ds.Tables(0).Rows.Count
'End If
If dataGrid1.RowCount = 0 Then
MsgBox("No se encontraron datos para los criterios de búsqueda suministrados.", vbOKOnly + vbInformation)
End If
lbl_Records.Text = CStr(dataGrid1.RowCount) & " Registros."
lbl_Records.Visible = True
Me.Cursor = c
' Cursor.Hide()
Me.Cursor = Cursors.Default
Exit Sub
Catch ex As Exception
End Try
End Sub
Private Sub cmdClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdClose.Click
Me.Close()
End Sub
Private Sub CmdExportar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CmdExportar.Click
Dim CLASSCOM = New clsComplejo
CLASSCOM.fdtDataSetTabla(clsVaribles.strSQL)
If CLASSCOM.ds.Tables.Count = 0 Then
MessageBox.Show("Realiza una consulta ", "MINDS", MessageBoxButtons.OK, MessageBoxIcon.Information)
Else
If CLASSCOM.ds.Tables(0).Rows.Count = 0 Then
MessageBox.Show("No hay datos para exportar ", "MINDS", MessageBoxButtons.OK, MessageBoxIcon.Information)
Else
Dim Resul As DialogResult
Resul = MessageBox.Show("Este proceso puede tardar varios minutos, ¿Deseas continuar? ", "MINDS", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
If Resul = DialogResult.Yes Then
'Creamos una copia del dataset
Dim copyDS As DataSet = CLASSCOM.ds.Copy()
'Quitamos las siguientes columnas para no exportarlas
'copyDS.Tables(0).Columns.Remove("Id_Transaccion")
'copyDS.Tables(0).Columns.Remove("Id_Producto")
'copyDS.Tables(0).Columns.Remove("Id_Subproducto")
'copyDS.Tables(0).Columns.Remove("Id_Patron")
'copyDS.Tables(0).Columns.Remove("Id_EstatusTransaccion")
'Creo una instancia de la clase aExcel
Dim clsExcel As aExcel = New aExcel
'Obtenemos el nombre o el titulo del form
clsExcel.Titulo = Me.Text
'Utilizo la funcion ExportDataset de la clase aExcel
clsExcel.ExportDataset(copyDS) 'Asigno el dataset a exportar
End If
End If
End If
End Sub
Private Sub btnLimpiar_Click(sender As Object, e As EventArgs) Handles btnLimpiar.Click
Me.cmbOrganismo.SelectedIndex = -1
Me.cmbPaises.SelectedIndex = -1
txtpais.Text = ""
Text_Busqueda.Text = ""
opt_Free.Checked = False
opt_Contents.Checked = False
opt_Exact.Checked = True
opt_EstatusActivo.Checked = False
opt_EstatusInactivo.Checked = False
opt_EstatusTodos.Checked = True
chk_Field0.Checked = True
chk_Field1.Checked = False
chk_Field2.Checked = False
chk_Field3.Checked = True
dataGrid1.DataSource = Nothing
dataGrid1.Refresh()
End Sub
End Class