0% found this document useful (0 votes)
112 views4 pages

Welcome Form:: Form5 Object Eventargs Form1

This document contains code for a Visual Basic .NET Windows Forms application that allows users to view product details and purchase history. There are five forms: 1. Form1 is the entry form which loads product data and allows searching by product name. 2. Form2 displays the product details retrieved from the database. 3. Form3 shows the product price. 4. Form4 is used for purchase where total price is calculated. 5. Form5 is a welcome form that opens Form1. The forms are connected and pass data between each other using buttons to open and close forms. Database queries are made to retrieve product information from a SQL Server database table.

Uploaded by

Nisha Elango
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
112 views4 pages

Welcome Form:: Form5 Object Eventargs Form1

This document contains code for a Visual Basic .NET Windows Forms application that allows users to view product details and purchase history. There are five forms: 1. Form1 is the entry form which loads product data and allows searching by product name. 2. Form2 displays the product details retrieved from the database. 3. Form3 shows the product price. 4. Form4 is used for purchase where total price is calculated. 5. Form5 is a welcome form that opens Form1. The forms are connected and pass data between each other using buttons to open and close forms. Database queries are made to retrieve product information from a SQL Server database table.

Uploaded by

Nisha Elango
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 4

Welcome form:

Public Class Form5

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button1.Click
Me.Close()
Form1.Show()
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button2.Click
Me.Close()
End Sub

Private Sub Form5_Load(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles MyBase.Load

End Sub
End Class

Entry form:

Imports System.Data.SqlClient
Imports System.Data
Public Class Form1
Dim con As New SqlClient.SqlConnection
Dim cmd As New SqlCommand
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the
'MasterDataSet.ForeignTrade' table. You can move, or remove it, as needed.
Me.ForeignTradeTableAdapter.Fill(Me.MasterDataSet.ForeignTrade)
con.ConnectionString = "Data Source=NISHA-PC\NISHA;Initial
Catalog=master;Integrated Security=True"
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button2.Click
Me.Close()
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button1.Click
con.Open()
cmd.CommandText = "select * from ForeignTrade where ProductName = '" &
ComboBox1.Text & "' "
cmd.Connection = con
cmd.ExecuteNonQuery()
Dim rdr As SqlDataReader
rdr = cmd.ExecuteReader
If rdr.Read = False Then
MsgBox("Sorry!Product unavailable..Try Again")
Else
Me.Hide()
Form2.Show()
End If
con.Close()
End Sub

End Class

Product Details Form:

Imports System.Data.SqlClient
Imports System.Data
Public Class Form2

Dim con As New SqlClient.SqlConnection


Dim cmd As New SqlCommand

Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles MyBase.Load
con.ConnectionString = "Data Source=NISHA-PC\NISHA;Initial
Catalog=master;Integrated Security=True"
Me.Label7.Text = Form1.ComboBox1.Text
con.Open()
cmd.CommandText = "select * from ForeignTrade where ProductName = '" &
Label7.Text & "'"
cmd.Connection = con
cmd.ExecuteNonQuery()
Dim rdr1 As SqlDataReader
rdr1 = cmd.ExecuteReader
rdr1.Read()
Dim ad = rdr1.Item("Address")
Dim num = rdr1.Item("PhoneNum")
Dim id = rdr1.Item("ProductID")
Label6.Text = id.ToString
Label8.Text = ad.ToString
Label9.Text = num.ToString
con.Close()
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button1.Click
Me.Close()
form3.show()
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button2.Click
Me.Close()
Form1.Show()
End Sub
End Class
Price Info:

Imports System.Data.SqlClient
Imports System.Data
Public Class Form3
Dim con As New SqlClient.SqlConnection
Dim cmd As New SqlCommand

Private Sub Form3_Load(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles MyBase.Load
con.ConnectionString = "Data Source=NISHA-PC\NISHA;Initial
Catalog=master;Integrated Security=True"
Me.Label3.Text = Form1.ComboBox1.Text
con.Open()
cmd.CommandText = "select * from ForeignTrade where ProductName = '" &
Label3.Text & "'"
cmd.Connection = con
cmd.ExecuteNonQuery()
Dim rdr1 As SqlDataReader
rdr1 = cmd.ExecuteReader
rdr1.Read()
Dim pr = rdr1.Item("Price")
Label5.Text = pr.ToString
con.Close()

End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button2.Click
Me.Close()
Form1.Show()
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button1.Click
Me.Close()
Form4.Show()
End Sub
End Class

Purchase Form:

Imports System.Data.SqlClient
Imports System.Data
Public Class Form4
Dim con As New SqlClient.SqlConnection
Dim cmd As New SqlCommand
Private Sub Form4_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
con.ConnectionString = "Data Source=NISHA-PC\NISHA;Initial
Catalog=master;Integrated Security=True"
Me.Label2.Text = Form1.ComboBox1.Text

Label5.Hide()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
Me.Close()
Form1.Show()
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button1.Click
MsgBox("Purchased '" & Label2.Text & "' Successfully!! Thank You")
End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button3.Click
con.Open()
cmd.CommandText = "select * from ForeignTrade where ProductName = '" &
Label2.Text & "'"
cmd.Connection = con
cmd.ExecuteNonQuery()
Dim rdr1 As SqlDataReader
rdr1 = cmd.ExecuteReader
rdr1.Read()
Dim pr = rdr1.Item("Price")
Dim qu = Convert.ToInt16(TextBox1.Text)
Dim tprice = pr * qu
Label5.Text = tprice.ToString
Label5.Show()
con.Close()
End Sub
End Class

You might also like