You are on page 1of 7

c 

 






Public Class Form1

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


System.EventArgs) Handles Button1.Click
If TextBox1.Text = "sachin" Then

If TextBox2.Text = "123" Then


Form2.Show()
Me.Hide()

End If

End If
End Sub

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


System.EventArgs) Handles Button2.Click
End
End Sub

End Class


 



c 


Imports System.IO
Imports System.Data.Odbc
Public Class Form2
Dim con As New OdbcConnection("dsn=netvb")
Public dadapter As New OdbcDataAdapter
Public dset As New DataSet
Public dtable As New DataTable
Dim dr As OdbcDataReader

Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object,


ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
MessageBox.Show("Address Is::" & ComboBox1.SelectedItem)
End Sub

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


As System.EventArgs) Handles TextBox3.TextChanged
Dim a As Integer
a = ComboBox2.Text * 400
TextBox3.Text = a

End Sub

Private Sub ComboBox2_SelectedIndexChanged(ByVal sender As System.Object,


ByVal e As System.EventArgs) Handles ComboBox2.SelectedIndexChanged
'MessageBox.Show("Choice Is::" & ComboBox2.SelectedItem)
Dim a As Integer
a = ComboBox2.Text * 400
TextBox3.Text = a
If a >= 4000 Then
TextBox5.Text = "Twenty Percent Discount"
ElseIf a <= 4000 And a >= 2000 Then
TextBox5.Text = "Ten Percent Discount"
Else
TextBox5.Text = "No Discount"

End If

End Sub

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


As System.EventArgs) Handles TextBox6.TextChanged
TextBox6.Text = 400
End Sub

Private Sub DateTimePicker1_ValueChanged(ByVal sender As System.Object,


ByVal e As System.EventArgs) Handles DateTimePicker1.ValueChanged
DateTimePicker1.Format = DateTimePickerFormat.Custom
DateTimePicker1.CustomFormat = "yyyy-MM-dd"
TextBox7.Text = DateTimePicker1.Value

End Sub

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


System.EventArgs) Handles Button3.Click
con.Open()

Dim qry As String


qry = "insert into
raj(CustomerName,CustomerAddress,MobileNo,EmailID,NoOfCylinder,Price,Discount
)values (' " + TextBox1.Text + " ',' " + ComboBox1.Text + " ',' " +
TextBox2.Text + " ',' " + TextBox4.Text + " ',' " + ComboBox2.Text + " ',' "
+ TextBox3.Text + " ',' " + TextBox5.Text + " ')"

Dim com As New OdbcCommand(qry, con)


com.ExecuteNonQuery()
MessageBox.Show("One Record Inserted")

con.Close()
Form3.Show()
End Sub

Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object,


ByVal e As System.EventArgs)
End
End Sub

Private Sub DeleteRecordToolStripMenuItem_Click(ByVal sender As


System.Object, ByVal e As System.EventArgs) Handles
DeleteRecordToolStripMenuItem.Click
con.Open()
Dim qry As String
Dim a As String
a = TextBox1.Text
qry = "delete from raj where CustomerName=' " + TextBox1.Text + " ' "
Dim comm As New OdbcCommand(qry, con)
comm.ExecuteNonQuery()
MessageBox.Show("Record Deleted Form Database")
con.Close()
Form3.Show()
End Sub

Private Sub UpdateRecordToolStripMenuItem_Click(ByVal sender As


System.Object, ByVal e As System.EventArgs) Handles
UpdateRecordToolStripMenuItem.Click
con.Open()
Dim query As String
query = "update raj set CustomerAddress = 'Phagwara' where
CustomerName= ' " & TextBox1.Text & " ' "
Dim comm As New OdbcCommand(query, con)
comm.ExecuteNonQuery()
MessageBox.Show("Record Updated in Database")
con.Close()
Form3.Show()

End Sub

Private Sub RetriveToolStripMenuItem_Click(ByVal sender As System.Object,


ByVal e As System.EventArgs) Handles RetriveToolStripMenuItem.Click
Dim dr As OdbcDataReader
Dim str As String
con.Open()
str = "select * from raj where CustomerName = ' " & TextBox1.Text & "
' ; "

Dim comm As New OdbcCommand(str, con)


comm.ExecuteNonQuery()
dr = comm.ExecuteReader

If dr.HasRows Then
While dr.Read
MessageBox.Show("Record Is Available In Database")
TextBox8.Text = dr.Item("CustomerName")
Form3.Show()

End While
Else
MessageBox.Show("Record Not Available")
End If
con.Close()

End Sub

Private Sub ViewRecordToolStripMenuItem1_Click(ByVal sender As


System.Object, ByVal e As System.EventArgs) Handles
ViewRecordToolStripMenuItem1.Click
Form3.Show()
Me.Hide()
End Sub
Private Sub LogToolStripMenuItem_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles LogToolStripMenuItem.Click
Form1.Show()
Form1.TextBox1.Text = ""
Form1.TextBox2.Text = ""

Me.Hide()

End Sub

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


System.EventArgs) Handles Button1.Click
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
TextBox5.Text = ""
TextBox6.Text = ""
TextBox7.Text = ""
TextBox8.Text = ""
ComboBox2.Text = ""
ComboBox1.Text = ""
DateTimePicker1.Text = ""
End Sub

Private Sub ExitToolStripMenuItem1_Click(ByVal sender As System.Object,


ByVal e As System.EventArgs) Handles ExitToolStripMenuItem1.Click
End
End Sub

Private Sub AboutUsToolStripMenuItem_Click(ByVal sender As System.Object,


ByVal e As System.EventArgs) Handles AboutUsToolStripMenuItem.Click
Dialog1.Show()

End Sub
End Class

R R