Ingenería Industrial

Páginas: 6 (1391 palabras) Publicado: 27 de noviembre de 2012
Imports System.Data
Imports System.Data.SqlClient
Public Class Empleado
Private Cnn As New SqlConnection("server=.;database=northwind;Integrated security=true")

Public Function EmpleadoListar() As DataTable
Dim dap As New SqlDataAdapter("Select EmployeeID,LastName,FirstName,Title From Employees", Cnn)
Dim tb As New DataTable
dap.Fill(tb)
Returntb
End Function

Public Function ValidaUsuario(ByVal XUser As String, ByVal XPass As String) As Boolean
Dim dap As New SqlDataAdapter("Select * From Employees Where FirstName=@Usuario and LastName=@Password", Cnn)
Dim tb As New DataTable
With dap.SelectCommand
.Parameters.AddWithValue("@Usuario", XUser).Parameters.AddWithValue("@Password", XPass)
End With
dap.Fill(tb)
If tb.Rows.Count > 0 Then
Return True
Else
Return False
End If
End Function

Public Function EmpleadoAdicionar(ByVal Ape As String, ByVal Nom As String, ByVal Car As String) As Boolean
Dim Sql As String = "Insert Into Employees(LastName,FirstName,Title)Values(@Apellido,@Nombre,@Cargo)"
Dim Cmd As New SqlCommand(Sql, Cnn)
'Definir los Parametros
With Cmd
.Parameters.AddWithValue("@Apellido", Ape)
.Parameters.AddWithValue("@Nombre", Nom)
.Parameters.AddWithValue("@Cargo", Car)
End With
Try
Cnn.Open()
Dim N As Integer = Cmd.ExecuteNonQueryCnn.Close()
If N > 0 Then
Return True
Else
Return False
End If
Catch ex As Exception
Throw ex
End Try
End Function

Public Function EmpleadoActualizar(ByVal Cod As Integer, ByVal Ape As String, ByVal Nom As String, ByVal Car As String) As Boolean
Dim sql AsString = "Update Employees set Lastname=@Apellido,FirstName=@Nombre,Title=@Cargo where EmployeeID=@Codigo"
Dim Cmd As New SqlCommand(sql, Cnn)
With Cmd
.Parameters.AddWithValue("@Apellido", Ape)
.Parameters.AddWithValue("@Nombre", Nom)
.Parameters.AddWithValue("Cargo", Car)
.Parameters.AddWithValue("@Codigo", Cod)
EndWith
Try
Cnn.Open()
Dim X As Integer = Cmd.ExecuteNonQuery
Cnn.Close()
If X > 0 Then
Return True
Else
Return False
End If
Catch ex As Exception
Throw ex
End Try
End Function

Public Function EmpleadoEliminar(ByVal Cod As Integer) AsBoolean
Dim sql As String = "Delete From Employees where EmployeeID=@Codigo"
Dim Cmd As New SqlCommand(sql, Cnn)
With Cmd
.Parameters.AddWithValue("@Codigo", Cod)
End With
Try
Cnn.Open()
Dim X As Integer = Cmd.ExecuteNonQuery
Cnn.Close()
If X > 0 Then
Return TrueElse
Return False
End If
Catch ex As Exception
Throw ex
End Try
End Function
End Class

SQL
--Insertar datos para la Tabla Productos--
Insert Into Producto(IdProducto,Nombre,Precio,Stock)
Values ('P001','Arroz Norteño',180.00,100)
Insert Into Producto(IdProducto,Nombre,Precio,Stock)
Values ('P002','AzucarRubia',170.00,140)
Insert Into Producto(IdProducto,Nombre,Precio,Stock)
Values ('P003','Arroz Paisana',160.00,120)
Insert Into Producto(IdProducto,Nombre,Precio,Stock)
Values ('P004','Sal',60.00,80)
Insert Into Producto(IdProducto,Nombre,Precio,Stock)
Values ('P005','Papas',70.00,90)
Insert Into Producto(IdProducto,Nombre,Precio,Stock)
Values ('P006','Menestras',1.50,80)
Insert Into...
Leer documento completo

Regístrate para leer el documento completo.

Estos documentos también te pueden resultar útiles

  • ingeneria industrial
  • Ingeneria industrial
  • ingeneria industrial
  • Ingeneria industrial
  • ingeneria industrial
  • Ingeneria Industrial
  • Ingeneria Industrial
  • Ingeneria Industrial

Conviértase en miembro formal de Buenas Tareas

INSCRÍBETE - ES GRATIS