forked from Abhivendra/School-Management-System
-
Notifications
You must be signed in to change notification settings - Fork 1
/
EnterFA1.vb
72 lines (63 loc) · 3.47 KB
/
EnterFA1.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
Public Class EnterFA1
Private Sub EnterCA_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Dim RecordPosition As Integer
Private Sub ButtonLoadRecords_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonLoadRecords.Click
If ComboClass.Text = "" Or ComboStream.Text = "" Or ComboSubject.Text = "" Then
MsgBox("Please select a class , subject and stream to proceed !", MsgBoxStyle.Exclamation + MsgBoxStyle.OkOnly)
Exit Sub
End If
Dim db As New SMSDataContext
Dim AssessmentRecords = From p In db.Assessments
Where p.Class = ComboClass.Text And p.Stream = ComboStream.Text And p.Subject = ComboSubject.Text
Select p
If AssessmentRecords.Count <> 0 Then
Me.AssessmentsTableAdapter.FillByclassstreamsubject(Me.SMS.Assessments, ComboClass.Text, ComboStream.Text, ComboSubject.Text)
Else
Dim StudentsRecord = From p In db.Students
Where p.Class = ComboClass.Text And p.Stream = ComboStream.Text
Select p
If StudentsRecord.Count = 0 Then
MsgBox("No Student in the system matches your criteria !", MsgBoxStyle.Exclamation + MsgBoxStyle.OkOnly)
Exit Sub
Else
For j = 1 To StudentsRecord.Count
Dim NewAssessmentRecord As New Assessment With {.FA1 = 0, .Class = ComboClass.Text, .Total1 = 0, .Full_Name = StudentsRecord.ToList(j - 1).Full_Name, .Registration_No = StudentsRecord.ToList(j - 1).Registration_No, .Stream = ComboStream.Text, .Subject = ComboSubject.Text}
db.Assessments.InsertOnSubmit(NewAssessmentRecord)
RecordPosition = 0
db.SubmitChanges()
Next
Me.AssessmentsTableAdapter.FillByclassstreamsubject(Me.SMS.Assessments, ComboClass.Text, ComboStream.Text, ComboSubject.Text)
LabelCurrentStudent.Text = AssessmentRecords.FirstOrDefault.Full_Name
TextScore.Focus()
End If
End If
End Sub
Private Sub ButtonEnter_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonEnter.Click
If TextScore.Text = "" Then
MsgBox("Assessment Score Can't be empty !", MsgBoxStyle.Exclamation + MsgBoxStyle.OkOnly)
Exit Sub
End If
If Not IsNumeric(TextScore.Text) Then
MsgBox("Score Must Be Numeric!", MsgBoxStyle.Exclamation + MsgBoxStyle.OkOnly)
Exit Sub
End If
Dim db As New SMSDataContext
Dim AssessmentRecord = From p In db.Assessments
Where p.Class = ComboClass.Text And p.Stream = ComboStream.Text And p.Subject = ComboSubject.Text
Select p
If RecordPosition > (AssessmentRecord.Count - 1) Then
MsgBox("end of records reached !", MsgBoxStyle.Exclamation + MsgBoxStyle.OkOnly)
Exit Sub
End If
AssessmentRecord.ToList(RecordPosition).FA1 = Val(TextScore.Text)
db.SubmitChanges()
RecordPosition += 1
If RecordPosition = (AssessmentRecord.Count) Then
MsgBox("End of Record Reached!", MsgBoxStyle.Exclamation + MsgBoxStyle.OkOnly)
Exit Sub
End If
TextScore.Clear()
TextScore.Focus()
End Sub
End Class