Private Sub TextBox2_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox2.KeyDown
If e.KeyCode = Keys.Enter Then
Dim s As String = ""
s = " select * "
s &= " from [order] [o],order_detail od,material m,unit u"
s &= " where [o].id_order = od.id_order"
s &= " and m.id_material = od.id_material"
s &= " and [o].id_order = '" & TextBox2.Text & "'"
Dim da As New SqlDataAdapter(s, cn)
Dim ds As New DataSet
da.Fill(ds, "4tb")
If ds.Tables("4tb").Rows.Count = 0 Then
MessageBox.Show("ไม่พบข้อมุลใบสั่งซื้อ")
Exit Sub
End If
Dim n As Integer = 0
n = ds.Tables("4tb").Rows.Count
With ds.Tables("4tb").Rows(0)
id_order.Text = .Item("id_order").ToString
order_date.Text = .Item("dateorder").ToString
ComboBox1.Text = .Item("id_sup").ToString
txtid.Text = .Item("id_material").ToString
txtname.Text = .Item("name_met").ToString
txtsung.Text = .Item("unitorder").ToString
'ComboBox2.Text = .Item("uname").ToString
'TextBox1.Text = .Item("perunit").ToString
txtprice.Text = .Item("price").ToString
txttotal.Text = .Item("total").ToString
End With
ListView1.Items.Clear()
num = 0
For i As Integer = 0 To n - 1
With ds.Tables("4tb").Rows(i)
Dim lv As New ListViewItem
lv.UseItemStyleForSubItems = False
num += 1
lv.Text = num
lv.SubItems.Add(.Item("id_material").ToString)
lv.SubItems.Add(.Item("name_met").ToString)
lv.SubItems.Add(.Item("price").ToString)
lv.SubItems.Add(.Item("unitorder").ToString)
lv.SubItems.Add(.Item("uname").ToString)
ListView1.Items.Add(lv)
lv = Nothing
End With
Next
End If
End Sub
Tag : .NET, Ms SQL Server 2008, VBScript, Win (Windows App), VS 2008 (.NET 3.x), Windows