'โชว์ประเภทสินค้า ใส่ชื่อประเภทใน combo แรก
Private Sub Showtype()
Dim sql As String = "SELECT * FROM Pro_Type"
da.SelectCommand = New OleDbCommand(sql, conn)
da.Fill(ds, "pro")
With cb_type
.DataSource = ds.Tables("pro")
.DisplayMember = "Protype_name"
.ValueMember = "Protype_ID"
End With
End Sub
'ตรงนี้ใส่ในอีเวนท์ของ combo แรก
Private Sub Showpro()
Dim sql As String = "SElECT Product_ID,ProductName FROM Product Where Protype_ID='" & cb_type.SelectedValue.ToString & "'"
da = New OleDbDataAdapter(sql, conn)
Dim dsproduct As New DataSet
da.Fill(dsproduct, "product")
With cb_pro
.BeginUpdate()
.DisplayMember = "ProductName"
.ValueMember = "Product_ID"
.DataSource = dsproduct.Tables("Product")
.EndUpdate()
End With
End Sub
'โชว์ราคาสินค้า ใส่ในอีเวนท์ของ combobox ที่2
Private Sub Showprice()
Dim price As String = ""
Dim sql As String = "SElECT PriceSale FROM Product WHERE Product_ID='" & cb_pro.SelectedValue.ToString & "'"
da = New OleDbDataAdapter(sql, conn)
Dim dsproduct As New DataSet
da.Fill(dsproduct, "pro")
tb_price.Text = cb_pro.SelectedValue.ToString
End Sub
' อันนี้ใส่ในอีเวนท์ของ textbox รหัสสมาชิก โชว์ชื่อสมาชิก
Private Sub Showname()
Dim sql As String = "SElECT Mem_Firstname FROM Member WHERE Member_ID='" & tb_mem.Text.ToString & "'"
da = New OleDbDataAdapter(sql, conn)
Dim dsmem As New DataSet
da.Fill(dsmem, "Member")
tb_name.Text = tb_mem.Text.ToString
End Sub
Private Sub Showname()
Dim sql As String = "SElECT Mem_Firstname FROM Member WHERE Member_ID=mem"
cmd = New OleDbCommand
With cmd
.CommandText = sql
.CommandType = CommandType.Text
.Connection = conn
.Parameters.Clear()
.Parameters.AddWithValue("mem", tb_mem.Text)
.ExecuteNonQuery()
End With
Dim dt As DataTable
dt = New DataTable("Mem_Firstname")
dr = cmd.ExecuteReader
dt.Load(dr)
tb_name.Text = CStr((dt.Rows(0)("Mem_Firstname")))
End Sub