Imports
Imports
Imports
Imports
Imports
[Link]
[Link]
System
[Link]
[Link]
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 = [Link] + "\[Link]"
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
Public Sub Abrir_Conexion()
ConexionDb = Trim("Server=" & ReiSer & ";Password=" & ReiPasw & ";Persist Security Info=True;User ID=" & ReiUsu &
";Initial Catalog=" & ReiDB)
Cadena_Conexion = ConexionDb
Cn = New SqlConnection(Cadena_Conexion)
If [Link] = [Link] Then [Link]()
Try
[Link]()
Catch ex As Exception
MsgBox("Unos de los Parametros esta mal,Para accesar a la base de datos", [Link] Or
[Link], "Conexion")
[Link]()
End
End Try
End Sub
Public Sub pulsaEnter(ByVal e As [Link])
'Subrutina para captar cuando se pulse enter en los controles
If [Link] = ChrW([Link]) Then
[Link] = True
[Link]("{TAB}")
End If
End Sub
Public Sub Llama_Cfg()
K = 0
FileOpen(1, ArchivoConexion, [Link])
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 = [Link]()
If [Link] = True Then
While [Link]()
'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
[Link]()
frm_Principal.Show()
frm_acceso.Hide()
[Link]()
End If
Else
[Link]()
MsgBox("Firma del Sistema Incorrecta", [Link], "Intento " & x & " de
If x = 3 Then End
x = x + 1
frm_acceso.[Link] = ""
frm_acceso.[Link] = ""
frm_acceso.[Link]()
End If
Catch ex As SqlException
[Link]("Error SQL", "BuscaUsuario", [Link], [Link])
[Link]()
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 = [Link]()
If [Link] = True Then
While [Link]
Aarchivo = Trim(lectorA("archivo"))
Afecha = Trim(lectorA("fecha"))
Adescar = Trim(lectorA("descar"))
End While
Else
[Link]()
End If
3")
Catch ex As Exception
[Link]("Error SQL", "BuscaArchivo", [Link], [Link])
[Link]()
End Try
Return False
End Function
Public Sub Inserta_Campo()
Dim cmd As SqlCommand
If [Link] = [Link] Then [Link]()
Try
[Link]()
cmd = New SqlCommand(Sql_gdafac, Cn)
[Link]()
Catch ex As Exception
MsgBox([Link] & vbCrLf & "Consulte al Administrador", [Link], "Inserta_Campo")
End Try
End Sub
Public Sub Actualiza_Campo()
Dim cmd1 As SqlCommand
If [Link] = [Link] Then [Link]()
Try
[Link]()
cmd1 = New SqlCommand(Sql_act, Cn)
[Link]()
Catch ex As Exception
MsgBox([Link] & vbCrLf & "Consulte al Administrador", [Link], "Modificar ")
End Try
End Sub
Public Sub Borrar_Campo()
Dim cmd As SqlCommand
If [Link] = [Link] Then [Link]()
Try
[Link]()
cmd = New SqlCommand(Sql_delFac, Cn)
[Link]()
Catch ex As Exception
End Try
End Sub
End Module
Imports [Link]
Imports [Link]
Public Class frm_usuarios
Private Sub frm_usuarios_FormClosing(ByVal sender As Object, ByVal e As [Link])
Handles [Link]
frm_Principal.Show()
End Sub
Private Sub frm_usuarios_Load(ByVal sender As [Link], ByVal e As [Link]) Handles [Link]
Llama_Cfg()
[Link] = True
desh_cajas()
cajas_bco()
[Link] = [Link]
End Sub
#Region "limpiar cajas"
Sub Limpiar_Cajas()
Actualiza_Grid()
txt_usuario.Text = [Link]
txt_pass.Text = [Link]
txt_nombre.Text = [Link]
cat_emp.Text = [Link]
cat_hor.Text = [Link]
cat_inc.Text = [Link]
cat_lec.Text = [Link]
cat_usu.Text = [Link]
cat_ret.Text = [Link]
des_loc.Text = [Link]
pro_cie.Text = [Link]
pro_cig.Text = [Link]
rep_kar.Text = [Link]
rep_tar.Text = [Link]
End Sub
#End Region
#Region "Actualiza Grid"
Sub Actualiza_Grid()
Dim adaptador As New SqlDataAdapter
Dim dset As New DataSet()
Try
Abrir_Conexion()
lista_usuario.[Link] = [Link]
lista_usuario.[Link] = [Link]
adaptador = New SqlDataAdapter("select * from Tbl_usuarios", Cn)
[Link](dset, "Tbl_usuarios")
lista_usuario.DataSource = [Link]("Tbl_usuarios")
lista_usuario.Columns("Usuario").Width = 120
lista_usuario.Columns("Password").Width = 120
lista_usuario.Columns("Nombre").Width = 170
lista_usuario.Columns("cat_lec").Width = 50
lista_usuario.Columns("Cat_hor").Width = 50
lista_usuario.Columns("Cat_inc").Width = 50
lista_usuario.Columns("Cat_emp").Width = 50
lista_usuario.Columns("cat_usu").Width = 50
lista_usuario.Columns("cat_reta").Width = 50
lista_usuario.Columns("des_loc").Width = 50
lista_usuario.Columns("pro_cie").Width = 50
lista_usuario.Columns("pro_cig").Width = 50
lista_usuario.Columns("rep_tar").Width = 50
lista_usuario.Columns("rep_kar").Width = 50
Catch Ex As Exception
MsgBox([Link], [Link], "Actializa_Grid")
End Try
End Sub
#End Region
#Region "controles vista, Altas, modificaciones, bajas usuarios "
Private Sub vista_CheckedChanged(ByVal sender As [Link], ByVal e As [Link]) Handles
[Link]
If [Link] = True Then
[Link] = True
Limpiar_Cajas()
End If
txt_usuario.Enabled = False
txt_nombre.Enabled = False
txt_pass.Enabled = False
desh_cajas()
End Sub
Private Sub alta_usr_CheckedChanged(ByVal sender As [Link], ByVal e As [Link]) Handles
alta_usr.CheckedChanged
[Link] = False
baja_usr.Enabled = False
mod_usr.Enabled = False
txt_usuario.Enabled = True
txt_pass.Enabled = True
txt_nombre.Enabled = True
txt_usuario.Focus()
hab_cajas()
cajas_ambar()
btn_ok.Text = "Aceptar"
Limpiar_Cajas()
End Sub
Private Sub mod_usr_CheckedChanged(ByVal sender As [Link], ByVal e As [Link]) Handles
mod_usr.CheckedChanged
[Link] = False
alta_usr.Enabled = False
baja_usr.Enabled = False
txt_usuario.Enabled = False
txt_pass.Enabled = True
txt_nombre.Enabled = True
hab_cajas()
cajas_ambar()
btn_ok.Text = "Modificar"
Limpiar_Cajas()
End Sub
Private Sub baja_usr_CheckedChanged(ByVal sender As [Link], ByVal e As [Link]) Handles
baja_usr.CheckedChanged
txt_usuario.Enabled = False
txt_nombre.Enabled = False
txt_pass.Enabled = False
[Link] = False
mod_usr.Enabled = False
alta_usr.Enabled = False
baja_usr.Enabled = False
btn_ok.Text = "Eliminar"
Limpiar_Cajas()
End Sub
#End Region
#Region "botones"
Private Sub btn_salir_Click(ByVal sender As [Link], ByVal e As [Link]) Handles btn_salir.Click
frm_Principal.[Link] = True
frm_Principal.Enabled = True
frm_Principal.[Link] = True
[Link]()
End Sub
Private Sub tbn_cancelar_Click(ByVal sender As [Link], ByVal e As [Link]) Handles tbn_cancelar.Click
[Link] = True
[Link] = True
alta_usr.Enabled = True
baja_usr.Enabled = True
mod_usr.Enabled = True
cajas_bco()
[Link]()
btn_ok.Text = ""
End Sub
#End Region
#Region "Obtener datos en grid"
Private Sub lista_usuario_CellMouseClick(ByVal sender As Object, ByVal e As
[Link]) Handles lista_usuario.CellMouseClick
Try
If lista_usuario.[Link] <= 0 Then Exit Sub
If baja_usr.Checked = True Or mod_usr.Checked = True Then
txt_usuario.Text = Me.lista_usuario.Rows(lista_usuario.[Link]).Cells(0).[Link]
txt_pass.Text = Me.lista_usuario.Rows(lista_usuario.[Link]).Cells(1).[Link]
txt_nombre.Text = Me.lista_usuario.Rows(lista_usuario.[Link]).Cells(2).[Link]
cat_lec.Text = Me.lista_usuario.Rows(lista_usuario.[Link]).Cells(3).[Link]
cat_hor.Text = Me.lista_usuario.Rows(lista_usuario.[Link]).Cells(4).[Link]
cat_inc.Text = Me.lista_usuario.Rows(lista_usuario.[Link]).Cells(5).[Link]
cat_emp.Text = Me.lista_usuario.Rows(lista_usuario.[Link]).Cells(6).[Link]
cat_usu.Text = Me.lista_usuario.Rows(lista_usuario.[Link]).Cells(7).[Link]
cat_ret.Text = Me.lista_usuario.Rows(lista_usuario.[Link]).Cells(8).[Link]
des_loc.Text = Me.lista_usuario.Rows(lista_usuario.[Link]).Cells(9).[Link]
pro_cie.Text = Me.lista_usuario.Rows(lista_usuario.[Link]).Cells(10).[Link]
pro_cig.Text = Me.lista_usuario.Rows(lista_usuario.[Link]).Cells(11).[Link]
rep_tar.Text = Me.lista_usuario.Rows(lista_usuario.[Link]).Cells(12).[Link]
rep_kar.Text = Me.lista_usuario.Rows(lista_usuario.[Link]).Cells(13).[Link]
End If
Catch ex As Exception
MsgBox([Link], [Link], "Lista_Usuario_SelectionChanged")
End Try
End Sub
#End Region
#Region "Ejecutar Altas, midificaciones y bajas"
Private Sub btn_ok_Click(ByVal sender As [Link], ByVal e As [Link]) Handles btn_ok.Click
Dim Cm As SqlCommand
Dim Dr As SqlDataReader
Dim Mensaje As MsgBoxResult
If alta_usr.Checked = True Then
txt_usuario.Enabled = True
If Verifica_usuario() = False Then MsgBox("El usuario ya fue fado de Alta", [Link], "Aceptar
Click") : Exit Sub
If txt_usuario.Text = [Link] Or txt_pass.Text = [Link] Or txt_nombre.Text = [Link] Then
MsgBox("Es necesario llenar todos los campos para dar de alta un Usuario", [Link], "Alta de Usuario") :
Exit Sub
Cm = New SqlCommand("Insert Into Tbl_usuarios (Usuario, Password, Nombre, cat_emp, cat_hor, cat_inc, cat_lec,
cat_usu, cat_reta,des_loc, pro_cie, pro_cig, rep_tar,rep_kar) VALUES ('" & _
txt_usuario.[Link] & "'" & ",'" & txt_pass.[Link] & "'" & ",'" &
txt_nombre.[Link] & "'" & ",'" & cat_emp.[Link] & "'" & ",'" & cat_hor.[Link] & "'" &
",'" & _
cat_inc.[Link] & "'" & ",'" & cat_lec.[Link] & "'" & ",'" & cat_usu.[Link]
& "'" & ",'" & "'" & ",'" & cat_ret.[Link] & "'" & ",'" & _
des_loc.[Link] & "'" & ",'" & pro_cie.[Link] & "'" & ",'" & pro_cig.[Link]
& "'" & ",'" & _
rep_tar.[Link] & "'" & ",'" & rep_kar.[Link] & "')", Cn)
Dr = [Link]
[Link]()
[Link] = True
baja_usr.Enabled = True
mod_usr.Enabled = True
desh_cajas()
cajas_bco()
btn_ok.Text = ""
End If
If baja_usr.Checked = True Then
Mensaje = MsgBox("Desea eliminar a " & txt_usuario.[Link] & " de la lista de usuarios?",
[Link] Or [Link])
If Mensaje = [Link] Then
Cm = New SqlCommand("Delete from Tbl_usuarios where Usuario='" & txt_usuario.[Link] & "' and
Password='" & txt_pass.[Link] & "'", Cn)
Dr = [Link]
[Link]()
Limpiar_Cajas()
[Link] = True
alta_usr.Enabled = True
mod_usr.Enabled = True
baja_usr.Enabled = True
desh_cajas()
cajas_bco()
btn_ok.Text = ""
End If
End If
If mod_usr.Checked = True Then
If txt_usuario.Text = [Link] Or txt_pass.Text = [Link] Or txt_nombre.Text = [Link] Then
MsgBox("Es necesario llenar todos los campos para Modificar un Usuario", [Link], "Modificar Usuario") :
Exit Sub
Cm = New SqlCommand("Update Tbl_usuarios Set Password='" & txt_pass.[Link] & "', Nombre='" &
txt_nombre.[Link] & "', cat_emp='" & cat_emp.[Link] & "', cat_hor='" & cat_hor.[Link]
& _
"', cat_inc='" & cat_inc.[Link] & "', cat_lec='" & cat_lec.[Link] & "', cat_usu='" &
cat_usu.[Link] & "', cat_reta='" & cat_ret.[Link] & _
"', des_loc='" & des_loc.[Link] & "', pro_cie='" & pro_cie.[Link] & "', pro_cig='" &
pro_cig.[Link] & _
"', rep_tar='" & rep_tar.[Link] & "', rep_kar='" & des_des.[Link] & "'where
Usuario='" & txt_usuario.[Link] & "'", Cn)
Dr = [Link]
[Link]()
Limpiar_Cajas()
[Link] = True
baja_usr.Enabled = True
alta_usr.Enabled = True
desh_cajas()
cajas_bco()
btn_ok.Text = ""
End If
End Sub
#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.[Link] & "' and Password = '" & txt_pass.[Link] & "'", Cn)
Dr = [Link]
[Link]()
If [Link] = True Then
[Link]()
Return False
Else
[Link]()
Return True
End If
[Link]()
Catch Ex As Exception
MsgBox([Link], [Link], "Verifica Clave")
End Try
Return False
End Function
#End Region
End Class