-
Notifications
You must be signed in to change notification settings - Fork 0
/
Form1.vb
93 lines (70 loc) · 2.95 KB
/
Form1.vb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
Imports System.Windows.Forms.VisualStyles.VisualStyleElement.Button
Imports MySql.Data.MySqlClient
Public Class Form1
Dim mySqlConnection As New MySqlConnection("host=127.0.0.1;user = root;database = schoolmanagementsystem")
Dim query As MySqlCommand
Private Sub Label6_Click(sender As Object, e As EventArgs) Handles Label6.Click
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Try
mySqlConnection.Open()
MessageBox.Show("Successfully connected to Database")
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Try
Dim gender As String = ""
If RadioButton1.Checked Then
gender = "Male"
End If
If RadioButton2.Checked Then
gender = "Female"
End If
Dim datavalid = True
If TextBox1.Text = "" Then
MsgBox("Please enter name!")
datavalid = False
End If
If TextBox2.Text = "" Then
MsgBox("Please enter phone number!")
datavalid = False
End If
If TextBox6.Text = "" Then
MsgBox("Please enter your email!")
datavalid = False
End If
If datavalid = True Then
query = New MySqlCommand("insert into registration values(' " & TextBox1.Text & "', '" & gender & "','" & TextBox2.Text & "','" & TextBox3.Text & "','" & TextBox4.Text & "','" & TextBox5.Text & "','" & TextBox6.Text & "','" & DateTimePicker1.Value & "','" & ComboBox1.GetItemText(ComboBox1.SelectedItem) & "')", mySqlConnection)
query.ExecuteNonQuery()
MsgBox("Information Saved")
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
TextBox5.Text = ""
TextBox6.Text = ""
RadioButton1.Checked = False
RadioButton2.Checked = False
End If
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
TextBox5.Text = ""
TextBox6.Text = ""
RadioButton1.Checked = False
RadioButton2.Checked = False
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
Me.Close()
End Sub
Private Sub ComboBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox1.SelectedIndexChanged
End Sub
End Class