hi everyone! below i will be showing you the codes of my scheduling module for an enrollment system..my problem is that on how to set conflict. i included a screenshot of the interface for further understanding... i hope you could help me...
here is the code:
Option Explicit On
Imports System.Data
Imports System.Data.OleDb
Public Class Scheduling
Dim con As OleDbConnection
Dim com As New OleDbCommand
Dim cmd As OleDbCommandBuilder
Dim ds As DataSet
Dim da As New OleDbDataAdapter
Dim lastrow As Integer
Dim myrow As Data.DataRow
Dim rid As OleDbDataReader
Private Sub Button2_Click(ByVal sEer As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If ListView1.Items.Count <> 8 Then
MsgBox("There must be eight subjects!", MsgBoxStyle.Information, "Warning")
ElseIf ComboBox1.Text = "First Year" Then
For i = 0 To ListView1.Items.Count - 1
con = New OleDbConnection("Provider=Microsoft.ace.oledb.12.0;Data Source=C:\Users\edenzam\Desktop\CBFMNHS Enrollment System\CBFMNHS Enrollment System\bin\Debug\Enrollment System.accdb")
da.SelectCommand = New OleDbCommand("Select* from Schedulings", con)
cmd = New OleDbCommandBuilder(da)
If con.State = ConnectionState.Closed Then con.Open()
ds = New DataSet
da.Fill(ds, "Schedulings")
ds.Tables("Schedulings").Rows.Add()
lastrow = ds.Tables("Schedulings").Rows.Count - 1
myrow = ds.Tables("Schedulings").Rows.Item(lastrow)
myrow.Item("YearLevels") = ComboBox1.Text
myrow.Item("Sections") = ComboBox3.Text
myrow.Item("SectionNames") = TextBox9.Text
myrow.Item("Adviser") = TextBox1.Text
myrow.Item("SubjectTeacher") = TextBox2.Text
myrow.Item("SubjectNames") = ComboBox7.Text
myrow.Item("Days") = ComboBox2.Text
myrow.Item("StartTimes") = ComboBox4.Text
myrow.Item("EndTimes") = ComboBox5.Text
myrow.Item("Rooms") = ComboBox6.Text
ds.Tables("Schedulings").GetChanges()
cmd.GetInsertCommand()
da.Update(ds, "Schedulings")
con.Close()
Next i
MsgBox("Registration Successful")
ElseIf ComboBox1.Text = "Second Year" Then
For i = 0 To ListView1.Items.Count - 1
con = New OleDbConnection("Provider=Microsoft.ace.oledb.12.0;Data Source=C:\Users\edenzam\Desktop\CBFMNHS Enrollment System\CBFMNHS Enrollment System\bin\Debug\Enrollment System.accdb")
da.SelectCommand = New OleDbCommand("Select* from Schedulings", con)
cmd = New OleDbCommandBuilder(da)
If con.State = ConnectionState.Closed Then con.Open()
ds = New DataSet
da.Fill(ds, "Schedulings")
ds.Tables("Schedulings").Rows.Add()
lastrow = ds.Tables("Schedulings").Rows.Count - 1
myrow = ds.Tables("Schedulings").Rows.Item(lastrow)
myrow.Item("YearLevels") = ComboBox1.Text
myrow.Item("Sections") = ComboBox3.Text
myrow.Item("SectionNames") = TextBox9.Text
myrow.Item("Adviser") = TextBox1.Text
myrow.Item("SubjectTeacher") = TextBox2.Text
myrow.Item("SubjectNames") = ComboBox8.Text
myrow.Item("Days") = ComboBox2.Text
myrow.Item("StartTimes") = ComboBox4.Text
myrow.Item("EndTimes") = ComboBox5.Text
myrow.Item("Rooms") = ComboBox6.Text
ds.Tables("Schedulings").GetChanges()
cmd.GetInsertCommand()
da.Update(ds, "Schedulings")
con.Close()
Next i
MsgBox("Registration Successful")
ElseIf ComboBox1.Text = "Third Year" Then
For i = 0 To ListView1.Items.Count - 1
con = New OleDbConnection("Provider=Microsoft.ace.oledb.12.0;Data Source=C:\Users\edenzam\Desktop\CBFMNHS Enrollment System\CBFMNHS Enrollment System\bin\Debug\Enrollment System.accdb")
da.SelectCommand = New OleDbCommand("Select* from Schedulings", con)
cmd = New OleDbCommandBuilder(da)
If con.State = ConnectionState.Closed Then con.Open()
ds = New DataSet
da.Fill(ds, "Schedulings")
ds.Tables("Schedulings").Rows.Add()
lastrow = ds.Tables("Schedulings").Rows.Count - 1
myrow = ds.Tables("Schedulings").Rows.Item(lastrow)
myrow.Item("YearLevels") = ComboBox1.Text
myrow.Item("Sections") = ComboBox3.Text
myrow.Item("SectionNames") = TextBox9.Text
myrow.Item("Adviser") = TextBox1.Text
myrow.Item("SubjectTeacher") = TextBox2.Text
myrow.Item("SubjectNames") = ComboBox9.Text
myrow.Item("Days") = ComboBox2.Text
myrow.Item("StartTimes") = ComboBox4.Text
myrow.Item("EndTimes") = ComboBox5.Text
myrow.Item("Rooms") = ComboBox6.Text
ds.Tables("Schedulings").GetChanges()
cmd.GetInsertCommand()
da.Update(ds, "Schedulings")
con.Close()
Next i
MsgBox("Registration Successful")
ElseIf ComboBox1.Text = "Fourth Year" Then
For i = 0 To ListView1.Items.Count - 1
con = New OleDbConnection("Provider=Microsoft.ace.oledb.12.0;Data Source=C:\Users\edenzam\Desktop\CBFMNHS Enrollment System\CBFMNHS Enrollment System\bin\Debug\Enrollment System.accdb")
da.SelectCommand = New OleDbCommand("Select* from Schedulings", con)
cmd = New OleDbCommandBuilder(da)
If con.State = ConnectionState.Closed Then con.Open()
ds = New DataSet
da.Fill(ds, "Schedulings")
ds.Tables("Schedulings").Rows.Add()
lastrow = ds.Tables("Schedulings").Rows.Count - 1
myrow = ds.Tables("Schedulings").Rows.Item(lastrow)
myrow.Item("YearLevels") = ComboBox1.Text
myrow.Item("Sections") = ComboBox3.Text
myrow.Item("SectionNames") = TextBox9.Text
myrow.Item("Adviser") = TextBox1.Text
myrow.Item("SubjectTeacher") = TextBox2.Text
myrow.Item("SubjectNames") = ComboBox27.Text
myrow.Item("Days") = ComboBox2.Text
myrow.Item("StartTimes") = ComboBox4.Text
myrow.Item("EndTimes") = ComboBox5.Text
myrow.Item("Rooms") = ComboBox6.Text
ds.Tables("Schedulings").GetChanges()
cmd.GetInsertCommand()
da.Update(ds, "Schedulings")
con.Close()
Next i
MsgBox("Registration Successful")
End If
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
If ListView1.Items.Count > 1 Then
TextBox9.Clear()
TextBox1.Clear()
TextBox2.Clear()
ListView1.Items.Clear()
ComboBox1.SelectedIndex = -1
ComboBox3.SelectedIndex = -1
ComboBox2.SelectedIndex = -1
ComboBox4.SelectedIndex = -1
ComboBox5.SelectedIndex = -1
ComboBox6.SelectedIndex = -1
ComboBox7.SelectedIndex = -1
ComboBox8.SelectedIndex = -1
ComboBox9.SelectedIndex = -1
ComboBox27.SelectedIndex = -1
Else
MsgBox("Empty", MsgBoxStyle.Information, "Message")
End If
End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
If ComboBox1.Text = "First Year" Then
If ComboBox1.Text = "" Or ComboBox3.Text = "" Or TextBox9.Text = "" Or TextBox1.Text = "" Or TextBox2.Text = "" _
Or ComboBox4.Text = "" Or ComboBox5.Text = "" Or ComboBox6.Text = "" Or ComboBox7.Text = "" Then
MsgBox("Complete The Schedule", MsgBoxStyle.Information)
Else
Dim lv As ListViewItem = ListView1.Items.Add(ComboBox7.Text)
lv.SubItems.Add(ComboBox2.Text)
lv.SubItems.Add(ComboBox4.Text)
lv.SubItems.Add(ComboBox5.Text)
lv.SubItems.Add(ComboBox6.Text)
lv.SubItems.Add(TextBox2.Text)
End If
ElseIf ComboBox1.Text = "Second Year" Then
If ComboBox1.Text = "" Or ComboBox3.Text = "" Or TextBox9.Text = "" Or TextBox1.Text = "" Or TextBox2.Text = "" _
Or ComboBox4.Text = "" Or ComboBox5.Text = "" Or ComboBox6.Text = "" Or ComboBox8.Text = "" Then
MsgBox("Complete The Schedule", MsgBoxStyle.Information)
Else
Dim lv As ListViewItem = ListView1.Items.Add(ComboBox8.Text)
lv.SubItems.Add(ComboBox2.Text)
lv.SubItems.Add(ComboBox4.Text)
lv.SubItems.Add(ComboBox5.Text)
lv.SubItems.Add(ComboBox6.Text)
lv.SubItems.Add(TextBox2.Text)
End If
ElseIf ComboBox1.Text = "Third Year" Then
If ComboBox1.Text = "" Or ComboBox3.Text = "" Or TextBox9.Text = "" Or TextBox1.Text = "" Or TextBox2.Text = "" _
Or ComboBox4.Text = "" Or ComboBox5.Text = "" Or ComboBox6.Text = "" Or ComboBox9.Text = "" Then
MsgBox("Complete The Schedule", MsgBoxStyle.Information)
Else
Dim lv As ListViewItem = ListView1.Items.Add(ComboBox9.Text)
lv.SubItems.Add(ComboBox2.Text)
lv.SubItems.Add(ComboBox4.Text)
lv.SubItems.Add(ComboBox5.Text)
lv.SubItems.Add(ComboBox6.Text)
lv.SubItems.Add(TextBox2.Text)
End If
ElseIf ComboBox1.Text = "Fourth Year" Then
If ComboBox1.Text = "" Or ComboBox3.Text = "" Or TextBox9.Text = "" Or TextBox1.Text = "" Or TextBox2.Text = "" _
Or ComboBox4.Text = "" Or ComboBox5.Text = "" Or ComboBox6.Text = "" Or ComboBox27.Text = "" Then
MsgBox("Complete The Schedule", MsgBoxStyle.Information)
Else
Dim lv As ListViewItem = ListView1.Items.Add(ComboBox27.Text)
lv.SubItems.Add(ComboBox2.Text)
lv.SubItems.Add(ComboBox4.Text)
lv.SubItems.Add(ComboBox5.Text)
lv.SubItems.Add(ComboBox6.Text)
lv.SubItems.Add(TextBox2.Text)
End If
End If
End Sub
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
If ListView1.SelectedItems.Count > 0 AndAlso MessageBox.Show("Do you want to remove this item?", "Confirm", MessageBoxButtons.YesNo) = Windows.Forms.DialogResult.Yes Then
ListView1.SelectedItems(0).Remove()
Else
MsgBox("No item is selected", MsgBoxStyle.Information, "Message")
End If
End Sub
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
If ComboBox1.Text = "First Year" Then
ComboBox7.Visible = True
ComboBox8.Visible = False
ComboBox9.Visible = False
ComboBox27.Visible = False
ElseIf ComboBox1.Text = "Second Year" Then
ComboBox7.Visible = False
ComboBox8.Visible = True
ComboBox9.Visible = False
ComboBox27.Visible = False
ElseIf ComboBox1.Text = "Third Year" Then
ComboBox7.Visible = False
ComboBox8.Visible = False
ComboBox9.Visible = True
ComboBox27.Visible = False
ElseIf ComboBox1.Text = "Fourth Year" Then
ComboBox7.Visible = False
ComboBox8.Visible = False
ComboBox9.Visible = False
ComboBox27.Visible = True
End If
End Sub