-
Notifications
You must be signed in to change notification settings - Fork 2
/
ManageStudents.vb
40 lines (33 loc) · 1.68 KB
/
ManageStudents.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
Public Class ManageStudents
Private Sub ManageStudents_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.StudentsTableAdapter.Fill(Me.SMS.Students)
End Sub
Private Sub TextSearch_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextSearch.KeyUp
If TextSearch.Text = "" Then
ManageStudents_Load(sender, e)
Else
Me.StudentsTableAdapter.FillByFullname(Me.SMS.Students, TextSearch.Text & "%")
End If
End Sub
Private Sub ButtonNew_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonNew.Click
AddStudent.Show()
ManageStudents_Load(sender, e)
End Sub
Private Sub ButtonRefresh_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonRefresh.Click
ManageStudents_Load(sender, e)
End Sub
Private Sub ButtonDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonDelete.Click
Try
Dim db As New SMSDataContext
Dim SelectedStudent = From p In db.Students
Where p.StudentID = Val(DataGridView1.CurrentRow.Cells(0).Value)
Select p
db.Students.DeleteOnSubmit(SelectedStudent.FirstOrDefault)
db.SubmitChanges()
MsgBox("Student record Successfully Deleted !!", MsgBoxStyle.Information + MsgBoxStyle.OkOnly)
ManageStudents_Load(sender, e)
Catch ex As Exception
MsgBox("Please Select a record first !! ", MsgBoxStyle.Exclamation + MsgBoxStyle.OkOnly)
End Try
End Sub
End Class