Private Sub ComboBox2_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox2.SelectedIndexChanged
Dim ds As New DsbaseTableAdapters.Table_ProduckTableAdapter
Dim dt As DataTable
dt = ds.GetDataBy1(ComboBox2.SelectedItem)
If ComboBox1.SelectedIndex <= 0 And ComboBox2.SelectedIndex >= 0 Then
TextBox1.Text = dt.Rows(0).Item("P_ID")
ComboBox1.Text = dt.Rows(0).Item("Produck")
ElseIf ComboBox1.SelectedIndex >= 0 And ComboBox2.SelectedIndex >= 0 Then
TextBox1.Text = dt.Rows(0).Item("P_ID")
ComboBox1.Text = dt.Rows(0).Item("Produck")
End If
End Sub
Private Sub ComboBox1_TextChanged(sender As Object, e As EventArgs) Handles ComboBox1.TextChanged
Dim ds As New DsbaseTableAdapters.Table_ProduckTableAdapter
Dim dt As DataTable
dt = ds.GetDataBy(ComboBox1.SelectedItem)
If ComboBox1.SelectedIndex >= 0 And ComboBox2.SelectedIndex <= 0 Then
TextBox1.Text = dt.Rows(0).Item("P_ID")
ComboBox2.Text = dt.Rows(0).Item("id")
ElseIf ComboBox1.SelectedIndex >= 0 And ComboBox2.SelectedIndex >= 0 Then
TextBox1.Text = dt.Rows(0).Item("P_ID")
ComboBox2.Text = dt.Rows(0).Item("id")
End If
End Sub
Private Sub FormPO_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim cn1 As New SqlConnection("Data Source=WAKDATABASE;Initial Catalog=WakoStock;Persist Security Info=True;User ID=sa;Password=*******")
Dim cmd1 As New SqlCommand("select * from PartList", cn)
Dim da1 As New SqlDataAdapter(cmd1)
Dim dt, dt1 As New DataTable()
da1.Fill(dt1)
cbb2.DataSource = dt1
cbb2.DisplayMember = "PartNo"
cbb2.ValueMember = "Id"
End Sub
Private Sub cbb2(sender As Object, e As EventArgs) Handles cbb2.SelectedIndexChanged
Try
open_database()
sql = "select * from PartList where PartNo='" + cbb2.Text + "'"
cmd = New SqlClient.SqlCommand(sql, cn)
reader = cmd.ExecuteReader
While reader.Read
cbb1.Text = reader.Item("PartName")
TextBox4.Text = reader.Item("MaterialName")
TextBox3.Text = reader.Item("MaterialColor")
TextBox1.Text = reader.Item("GrossWeight")
TextBox7.Text = reader.Item("MachineNo")
TextBox5.Text = reader.Item("Ton")
End While
cn.Close()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub