You are on page 1of 2

Imports System.Data.

SqlClient
Imports System.Configuration

Module FUNCIONES

'---------------------------CONEXION CON
SQL-----------------------------------'

Public c_sql As New


SqlConnection(ConfigurationManager.ConnectionStrings("cn").ConnectionString)
Public dr_Sql As SqlDataReader
Public cmd_Sql As New SqlCommand

Public c_sql1 As New


SqlConnection(ConfigurationManager.ConnectionStrings("cn").ConnectionString)
Public dr_Sql1 As SqlDataReader
Public cmd_Sql1 As New SqlCommand
Public sql As String = ""
Public Sub ConectarserSQLSERVER()

Try
c_sql.Open()
c_sql1.Open()
Form1.Label2.Text = "Conectado"
Form1.Label2.ForeColor = Color.Blue

Catch ex As Exception
MsgBox(ex.ToString)

Form1.Label2.Text = "Desconectado"
Form1.Label2.ForeColor = Color.Red
End Try
End Sub

'--------------------------------------------------------------------------------'
Public Sub consultarPersona(ByRef identificacion As String)

cmd_Sql.Connection = c_sql
cmd_Sql.CommandType = CommandType.Text

cmd_Sql.CommandText = "SELECT * FROM MAEMP001 WHERE CEDULA=" +


identificacion

Try
dr_Sql = cmd_Sql.ExecuteReader()
Catch ex As Exception
MsgBox(ex.ToString)
End Try

End Sub

Public Sub consultarPorCodigo(ByRef identificacion As String)

cmd_Sql.Connection = c_sql
cmd_Sql.CommandType = CommandType.Text

cmd_Sql.CommandText = "SELECT * FROM MAEMP001 WHERE CODIGO='" &


identificacion & "'"
Try
dr_Sql = cmd_Sql.ExecuteReader()
Catch ex As Exception
MsgBox(ex.ToString)
End Try

End Sub

Public Sub Horarios()

cmd_Sql.Connection = c_sql
cmd_Sql.CommandType = CommandType.Text

cmd_Sql.CommandText = "SELECT * FROM NTURN"

Try
dr_Sql = cmd_Sql.ExecuteReader()
Catch ex As Exception

End Try

End Sub

'------------------------------------------------------------------------
Validaciones de
campos----------------------------------------------------------------------'
Public Sub soloLetras(ByRef e As System.Windows.Forms.KeyPressEventArgs)

Dim CaracteresPermitidos As String = "abcdefghijklmnñopqrstuvwxyz


ABCDEFGHIJKLMNÑOPQRSTUVWXYZ áéíóú ÁÉÍÓÚ" & Convert.ToChar(8)
Dim c As Char = e.KeyChar
If Not (CaracteresPermitidos.Contains(c)) Then
MsgBox("Los NUMEROS O CARACTERES ESPACIALES no estan permitidos en este
campo", MsgBoxStyle.Exclamation, "SCA 3.0")
e.Handled = True
End If

End Sub

Public Sub soloNumeros(ByRef e As System.Windows.Forms.KeyPressEventArgs)


Dim CaracteresPermitidos As String = "1234567890" & Convert.ToChar(8)
Dim c As Char = e.KeyChar
If Not (CaracteresPermitidos.Contains(c)) Then
MsgBox("Las LETRAS O CARACTERES ESPECIALES no estan permitidos en este
campo", MsgBoxStyle.Exclamation, "SCAN 3.0")
e.Handled = True
End If
End Sub

End Module

You might also like