Documentos de Académico
Documentos de Profesional
Documentos de Cultura
SqlClient
Sub ListarCliente()
Try
conectar()
con.Open()
ejecutar = comando.ExecuteReader()
tabla.Load(ejecutar)
dgvCLIENTE.DataSource = tabla
dgvCLIENTE.Refresh()
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
'Clase Nuevo'
txtCODIGO.Enabled = Ctexto
txtNOMBRES.Enabled = Ctexto
txtAPELLIDOS.Enabled = Ctexto
txtDOCUMENTO.Enabled = Ctexto
txtDIRECCION.Enabled = Ctexto
End Sub
'Clase limpiar'
Sub limpiar()
txtCODIGO.Clear()
txtNOMBRES.Clear()
txtAPELLIDOS.Clear()
txtDOCUMENTO.Clear()
txtDIRECCION.Clear()
End Sub
Sub getCLIENTE()
Dim c As Integer
Dim a As Integer
c = dgvCLIENTE.RowCount
a = Convert.ToInt32(c) - 1
lblNUMERO.Text = Str(a)
End Sub
'Formulario'
Call ListarCliente()
getCLIENTE()
nuevo(False)
End Sub
'Botón btnListar'
Call ListarCliente()
End Sub
'Botón btnNuevo'
Call nuevo(True)
Call limpiar()
txtCODIGO.Select()
End Sub
'Botón btnAgregar'
Try
conectar()
con.Open()
comando.CommandType = CommandType.Text
comando.Parameters.Add("@estado", SqlDbType.Bit).Value = 1
insertar = comando.ExecuteNonQuery()
ListarCliente()
getCLIENTE()
Else
End If
Catch ex As Exception
End Try
End Sub
'Botón btnActualizar'
Try
conectar()
con.Open()
consulta = "update cliente set nombre=@nombre, apellidos=@apellidos,
documento=@documento, direccion=@direccion where codigo=@codigo"
comando.CommandType = CommandType.Text
actualizar = comando.ExecuteNonQuery()
ListarCliente()
getCLIENTE()
Else
End If
Catch ex As Exception
End Try
End Sub
'Botón btnEliminar'
Try
conectar()
con.Open()
comando.CommandType = CommandType.Text
eliminar = comando.ExecuteNonQuery()
ListarCliente()
getCLIENTE()
Else
End If
Catch ex As Exception
End Try
End Sub
'DataGridView evento cellclick'
Try
txtCODIGO.Text = dgvCLIENTE.CurrentRow.Cells(0).Value
txtNOMBRES.Text = dgvCLIENTE.CurrentRow.Cells(1).Value
txtAPELLIDOS.Text = dgvCLIENTE.CurrentRow.Cells(2).Value
txtDOCUMENTO.Text = dgvCLIENTE.CurrentRow.Cells(3).Value
txtDIRECCION.Text = dgvCLIENTE.CurrentRow.Cells(4).Value
Call nuevo(True)
txtCODIGO.Enabled = False
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
End Class