Guys I need help. I am doing a system (project) entitled “Automatic Examination Scheduling System”. This system as it stressed in its title, aim to automate the assigning of proctors, rooms and times to subjects. So it must be triggered with only one button all at once. I have tables in my database named Subject, Professor (as proctors) and Room. I am having a trouble as of assigning a proctor to a subject. Here is what I’ve done:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnSave.Click
Dim connect As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim rss As New ADODB.Recordset
connect.ConnectionString = "PROVIDER=Microsoft.JET.OLEDB.4.0;Data Source=C:\Users\Spongebob\Desktop\Database1.mdb"
connect.Open()
Dim sql, sql1 As String
sql = "Select * from Class"
rs.Open(sql, connect)
sql1 = "Select * from Professor"
rss.Open(sql1, connect)
Do Until rs.EOF
TxtbxClassID.Text = rs("ClassID").Value
Do Until rss.EOF
Dim prof As String
prof = rss("ProfID").Value
For i As Integer = 0 To DataGridExamSched.RowCount - 1
Dim a As Integer
If prof = DataGridExamSched.Rows(i).Cells(1).Value Then
a = a + 1
End If
If a <= 5 Then
TxtbxProfID.Text = prof
Exit Do
Else
Exit For
End If
Next
rss.Move(MakeNumRand)
Loop
rs.MoveNext()
DataGridExamSched.Rows.Add(TxtbxClassID.Text, TxtbxProfID.Text)
Loop
End Sub
Public Function MakeNumRand() As String
Dim temp As String
Dim NumRand As New Random
temp = NumRand.Next(1, 20)
Dim i As Integer = 0
Return temp
End Function
As you can see I’ve used two textboxes to hold the ClassID and the ProfID values to be saved in a datagrid named datagridexamsched. The thing is that, a certain professor must only be assigned to subjects 5 times and in a random way. Guys please help…