CONSULTA EN UN DATAGRIDVIEW

Class1.vb Imports System.Data Imports System.Data.SqlClient Public Class Class1 Private con As SqlConnection Private dtb As DataTable Private da As SqlDataAdapter Private lispro As New List(Of Producto) Private Shared dato As String Sub New() con = New SqlConnection _ ("Integrated security=true;server=.;database=ventas") dtb = New DataTable da = New SqlDataAdapter("select * from productos1", con) da.Fill(dtb) For Each f As DataRow In dtb.Rows

Rows(i). ByVal e As System.Selected = False i = obj.Add(New Producto(f(0).Add(New Producto(f(0).Text) .TextChanged Try Me.DataGridView1.vb Imports Componente Public Class Form1 Dim obj As Class1 Dim i As Integer = 0 Private Sub Form1_Load(ByVal sender As System.Buscar(Me. f(2).DataSource = obj.lispro. ByVal e As System.Listado() End Sub Private Sub TextBox1_TextChanged(ByVal sender As System.ToString) End Try Return i End Function Private Shared Function compara(ByVal p As Producto) As Boolean Return p.EventArgs) Handles TextBox1.DataGridView1.Fill(dtb) For Each f As DataRow In dtb.Object.StartsWith(dato.ToUpper) End Function End Class Form1. f(3))) Next End Sub Public Function Listado() As List(Of Producto) dtb = New DataTable da = New SqlDataAdapter("select * from productos1".Rows lispro.TextBox1.ToUpper().Producto. f(3))) Next Return lispro End Function Public Function Buscar(ByVal pro As String) As Integer dato = pro Dim i As Integer = 0 Try i = lispro.FindIndex(AddressOf compara) Catch ex As Exception Throw New Exception(ex.EventArgs) Handles MyBase. f(2). con) da. f(1).Load obj = New Class1 Me.ToString().Object. f(1).

DataGridView1.vb Public Class Producto Private _codigo As Integer Private _producto As String Private _precio As Double Private _stock As Integer Sub New() End Sub Sub New(ByVal codigo As Integer. ByVal producto As String. ByVal stock As Integer) _codigo = codigo _producto = producto _precio = precio _stock = stock End Sub Public Property Codigo() Get Return _codigo End Get Set(ByVal value) _codigo = value End Set End Property Public Property Producto() Get Return _producto End Get Set(ByVal value) _producto = value End Set End Property Public Property Precio() Get Return _precio End Get Set(ByVal value) _precio = value End Set .FirstDisplayedScrollingRowIndex = i Catch ex As Exception MsgBox(ex. ByVal precio As Double.Message) End Try End Sub End Class Producto.DataGridView1.Selected = True Me.Me.Rows(i).

End Property Public Property Stock() Get Return _stock End Get Set(ByVal value) _stock = value End Set End Property End Class .

Sign up to vote on this title
UsefulNot useful