Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
- Try
- Dim conn As New MySqlConnection
- conn.ConnectionString = "server =localhost;user = root;password =1; database = pof"
- Try
- conn.Open()
- Catch ex As MySqlException
- MsgBox("Error", MsgBoxStyle.Exclamation)
- End Try
- Dim myCOmmand As New MySqlCommand
- Dim myReader As MySqlDataReader
- myCOmmand = New MySqlCommand
- myCOmmand.Connection = conn
- myCOmmand.CommandText = "select * from iteminfo where item_code = '" + TextBox1.Text + "';"
- myReader = myCOmmand.ExecuteReader
- If myReader.Read Then
- dayaCode.Text = myReader(0)
- dayaName.Text = myReader(1)
- dayaQty.Text = myReader(2)
- dayaPresyo.Text = myReader(3)
- Else
- MsgBox("No Available Product for the Item Code !", MsgBoxStyle.Exclamation, "")
- End If
- With myCOmmand
- .CommandText = "Insert into transaction values('" & Me.dayaCode.Text & _
- "','" & Me.dayaName.Text & "'," & Val(Me.dayaQty.Text) & _
- "," & Val(Me.dayaPresyo.Text) & ",'" & Me.TextBox1.Text & "');"
- End With
- ShowMe("select item_code,item_name,item_quantity,item_price from transaction where item_code='" & Me.dayaCode.Text & "'")
- Catch ex As Exception
- MessageBox.Show(ex.Message)
- End Try
- End Sub
- Public Sub ShowMe(ByVal statement As String)
- mycommand = New MySqlCommand
- Try
- connect()
- mycon.Open()
- With mycommand
- .CommandText = statement
- .Connection = mycon
- myreader = .ExecuteReader
- End With
- Me.ListView1.Items.Clear()
- Do While myreader.Read
- Dim ShowMe As New ListViewItem(myreader.Item("item_code").ToString)
- ShowMe.SubItems.Add(myreader.Item("item_name").ToString)
- ShowMe.SubItems.Add(myreader.Item("item_quantity").ToString)
- ShowMe.SubItems.Add(myreader.Item("item_price").ToString)
- Me.ListView1.Items.Add(ShowMe)
- Me.ListView1.Refresh()
- Loop
- Catch ex As Exception
- MessageBox.Show(ex.Message)
- Finally
- mycon.Close()
- myreader.Close()
- mycommand.Dispose()
- End Try
- End Sub
Add Comment
Please, Sign In to add comment