This repository has been archived by the owner on Jan 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfrmEdit.vb
39 lines (32 loc) · 1.73 KB
/
frmEdit.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
Public Class frmEdit
Public Sub addCombo()
'add item for college
cboEditCollege.Items.Add("College of Agriculture")
cboEditCollege.Items.Add("College of Arts and Sciences")
'add item for course
cboEditCourse.Items.Add("Bachelor of Science in Information Technology")
cboEditCourse.Items.Add("Bachelor of Science in Computer Science")
'add item for gender
cboEditGender.Items.Add("Male")
cboEditGender.Items.Add("Female")
End Sub
Private Sub cmdUpdate_Click(sender As Object, e As EventArgs) Handles cmdUpdate.Click
Try
DBConnect()
cmd.CommandType = CommandType.Text
cmd.Connection = conn
cmd.CommandText = "UPDATE tblstudent SET student_id = '" & txtEditID.Text.ToString.Trim & "', name = '" & txtEditName.Text.ToString.Trim & "', college = '" & cboEditCollege.Text.ToString & "', course = '" & cboEditCourse.Text.ToString & "', age = '" & txtEditAge.Text.ToString.Trim & "', gender = '" & cboEditGender.Text.ToString & "', phone_number = '" & txtEditPhone.Text.ToString.Trim & "', address = '" & txtEditAddress.Text.ToString.Trim & "' WHERE id = '" & frmMain.DataGridView1.Item("Column9", frmMain.DataGridView1.CurrentRow.Index).Value & "';"
cmd.ExecuteNonQuery()
cmd.Dispose()
DBClose()
MessageBox.Show("Successfully Updated Record", "Edit Student", MessageBoxButtons.OK, MessageBoxIcon.Information)
Me.Hide()
frmMain.loadData()
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
Private Sub cmdCancel_Click(sender As Object, e As EventArgs) Handles cmdCancel.Click
Me.Close()
End Sub
End Class