VB SQL
VB SQL
Imports
Imports
Imports
Imports
System.Data.Sql
System.Data.SqlClient
System
System.IO
System.Collections
Module globales
Public
Public
Public
Public
Public
Public
Public
Public
Public
Public
Public
Public
Public
Public
Public
Dato(4) As String
cadena As Object
ReiPasw As String
ReiSer As String
ReiUsu As String
ReiDB As String
K As Integer
ArchivoConexion As String = Application.StartupPath.ToString + "\Cfg.cfg"
Cadena_Conexion As String
ConexionDb As String
datos_usu As String
datos_emp As String
Cn As SqlConnection
com As SqlCommand
com2 As SqlCommand
Public
Public
Public
Public
Public
Public
Public
Public
Public
Public
Public
Public
Public
Public
Public
Public
Public
Public
Public
Public
Public
Public
Public
Public
Public
Public
Public
Public
Public
Public
Public
Public
Public
Public
Public
Public
Public
Public
Public
Public
Public
Public
Public
Public
Public
Public
Public
Public
Public
Public
Public
Public
Public
Public
Public
Public
Public
Public
Public
Public
Public
Public
Public
Public
Public
Public
Public
Public
Public
Public
Public
ComboDR As SqlDataReader
ComboDR1 As SqlDataReader
ComboDR2 As SqlDataReader
ComboDR3 As SqlDataReader
ComboDR4 As SqlDataReader
ComboDR5 As SqlDataReader
miCon As SqlConnection
Nombrecito As String
Sql_gdafac As String
Sql_delFac As String
Sql_act As String
usu As String
pass As String
x As Integer = 1
UsuPass As String
lector As SqlDataReader
Ausuario As String
Apassword As String
nivelUsr As String
ANombre As String
nom As String
d_nom As String
e_num As String
Aarchivo As String
Afecha As String
Adescar As String
dat_arch As String
lectorA As SqlDataReader
fechaD, fechaA As Date
aclec As String
achor As String
acsuc As String
acinc As String
acemp As String
acusu As String
apeth As String
appue As String
adloc As String
adsuc As String
adarc As String
apcie As String
apcig As String
apcme As String
apcmg As String
amgru As String
arana As String
artar As String
arkar As String
aracu As String
arrep As String
arvis As String
apcal As String
aprep As String
auhue As String
audat As String
aucon As String
acret As String
Trep As String
dirIp As String
dirpuerto As String
dirComm As String
dirBaud As String
numdispIp As String
numdispComm As String
Msg As Integer
Querys1, nomQuery, querys2 As String
Cuantos As Boolean
Tblname As String
ObjComm As SqlCommand
Vnum, Vnom As String
datos_lect As String
Cadena_Conexion = ConexionDb
Cn = New SqlConnection(Cadena_Conexion)
If Cn.State = ConnectionState.Open Then Cn.Close()
Try
Cn.Open()
Catch ex As Exception
MsgBox("Unos de los Parametros esta mal,Para accesar a la base de datos", MessageBoxButtons.OK Or
MessageBoxIcon.Error, "Conexion")
Cn.Close()
End
End Try
End Sub
Public Sub pulsaEnter(ByVal e As System.Windows.Forms.KeyPressEventArgs)
'Subrutina para captar cuando se pulse enter en los controles
If e.KeyChar = ChrW(Keys.Enter) Then
e.Handled = True
SendKeys.Send("{TAB}")
End If
End Sub
Public Sub Llama_Cfg()
K = 0
FileOpen(1, ArchivoConexion, OpenMode.Input)
cadena = LineInput(1)
ReiSer = Trim(cadena)
cadena = LineInput(1)
ReiUsu = Trim(cadena)
cadena = LineInput(1)
ReiPasw = Trim(cadena)
Do While EOF(1) = False
Input(1, cadena)
If cadena <> "" Then Dato(K) = Trim(cadena)
K = K + 1
Loop
ReiDB = Dato(0)
FileClose(1)
End Sub
Function BuscaUsuario(ByVal usu As String, ByVal pass As String) As String
Try
Abrir_Conexion()
datos_usu = ("SELECT * FROM Tbl_Usuarios WHERE Usuario='" & usu & "' AND Password = '" & pass & "'")
com = New SqlCommand(datos_usu, Cn)
lector = com.ExecuteReader()
If lector.HasRows = True Then
While lector.Read()
'Asigna los valores del usuario a las variables correspondientes
Ausuario = Trim(lector("usuario"))
Apassword = Trim(lector("password"))
ANombre = Trim(lector("nombre"))
aclec = Trim(lector("cat_lec"))
achor = Trim(lector("cat_hor"))
acinc = Trim(lector("cat_inc"))
acemp = Trim(lector("cat_emp"))
acusu = Trim(lector("cat_usu"))
acret = Trim(lector("cat_reta"))
adloc = Trim(lector("des_loc"))
apcie = Trim(lector("pro_cie"))
apcig = Trim(lector("pro_cig"))
artar = Trim(lector("rep_tar"))
arkar = Trim(lector("rep_kar"))
End While
If UCase(Trim(usu)) = UCase(Ausuario) And UCase(Trim(pass)) = UCase(Apassword) Then
lector.Close()
frm_Principal.Show()
frm_acceso.Hide()
Cn.Close()
End If
Else
lector.Close()
MsgBox("Firma del Sistema Incorrecta", MsgBoxStyle.Information, "Intento " & x & " de
If x = 3 Then End
x = x + 1
frm_acceso.txtusu.Text = ""
frm_acceso.txtpass.Text = ""
frm_acceso.txtusu.Focus()
End If
Catch ex As SqlException
MessageBox.Show("Error SQL", "BuscaUsuario", MessageBoxButtons.OK, MessageBoxIcon.Error)
lector.Close()
End Try
Return False
End Function
Function BuscaArchivo(ByVal nom) As String
Try
'Abrir_Conexion()
d_nom = ("SELECT * FROM tbl_archivos where archivo= '" & nom & "'")
com2 = New SqlCommand(d_nom, Cn)
lectorA = com2.ExecuteReader()
If lectorA.HasRows = True Then
While lectorA.Read
Aarchivo = Trim(lectorA("archivo"))
Afecha = Trim(lectorA("fecha"))
Adescar = Trim(lectorA("descar"))
End While
Else
lectorA.Close()
End If
3")
Catch ex As Exception
MessageBox.Show("Error SQL", "BuscaArchivo", MessageBoxButtons.OK, MessageBoxIcon.Error)
lector.Close()
End Try
Return False
End Function
Public Sub Inserta_Campo()
Dim cmd As SqlCommand
If Cn.State = ConnectionState.Open Then Cn.Close()
Try
Cn.Open()
cmd = New SqlCommand(Sql_gdafac, Cn)
cmd.ExecuteNonQuery()
Catch ex As Exception
MsgBox(ex.Message & vbCrLf & "Consulte al Administrador", MsgBoxStyle.Critical, "Inserta_Campo")
End Try
End Sub
Public Sub Actualiza_Campo()
Dim cmd1 As SqlCommand
If Cn.State = ConnectionState.Open Then Cn.Close()
Try
Cn.Open()
cmd1 = New SqlCommand(Sql_act, Cn)
cmd1.ExecuteNonQuery()
Catch ex As Exception
MsgBox(ex.Message & vbCrLf & "Consulte al Administrador", MsgBoxStyle.Critical, "Modificar ")
End Try
End Sub
Public Sub Borrar_Campo()
Dim cmd As SqlCommand
If Cn.State = ConnectionState.Open Then Cn.Close()
Try
Cn.Open()
cmd = New SqlCommand(Sql_delFac, Cn)
cmd.ExecuteNonQuery()
Catch ex As Exception
End Try
End Sub
End Module
Imports System.Data.Sql
Imports System.Data.SqlClient
#End Region
#Region " verifica usuario"
Function Verifica_usuario()
Try
Dim Cm As SqlCommand
Dim Dr As SqlDataReader
Cm = New SqlCommand("Select Usuario, Password from Tbl_usuarios where Usuario = '" &
txt_usuario.Text.ToString.Trim & "' and Password = '" & txt_pass.Text.ToString.Trim & "'", Cn)
Dr = Cm.ExecuteReader
Dr.Read()
If Dr.HasRows = True Then
Dr.Close()
Return False
Else
Dr.Close()
Return True
End If
Dr.Close()
Catch Ex As Exception
MsgBox(Ex.Message, MsgBoxStyle.Critical, "Verifica Clave")
End Try
Return False
End Function
#End Region
End Class