private void btnRemove_Click(object sender, EventArgs e)
        {
            DialogResult sureDelete = MessageBox.Show("Are you sure you want to delete all of the selected timeslots?", "Deletion confirmation", MessageBoxButtons.YesNo);

            if (sureDelete == DialogResult.Yes)
            {
                bool weeklyChoice = checkChecked();
                setPreviousWeekliesToFalse();                                //set the previous weeklies to false
                if (weeklyChoice)
                {
                    DialogResult choice = MessageBox.Show("Would you like to delete the weekly time slots until the end of the semester?", "Delete weekly timeslots?", MessageBoxButtons.YesNo);
                    if (choice == DialogResult.Yes)                         //if the user says yes
                    {
                        deleteAvail(true);                                  //delete the time block and all of its weekly future ones
                    }
                    else if (choice == DialogResult.No)                     //if they say no
                    {
                        deleteAvail(false);                                 //delete the time slots of only the ones that have checked off
                    }
                }
                else
                {
                    deleteAvail(false);
                }

                for (int c = 0; c < lvTimeSlots.CheckedItems.Count; c++)    //remove all of the selected time slots from the listview
                {
                    lvTimeSlots.CheckedItems[c].Remove();
                    c--;
                }

                if (!admin)
                {
                    StudentMain g = new StudentMain(id);                    //send the user back to the student main
                    g.Show();
                    this.Dispose();
                }
                else
                {
                    AdminSeeSchedule g = new AdminSeeSchedule(id);         //send the user to admin
                    g.Show();
                    this.Dispose();
                }
            }
            else
            {
                MessageBox.Show("Cancellation confirmed, the selected time slots have not been deleted from your availability.");
            }
        }
 private void btnCancel_Click(object sender, EventArgs e)
 {
     if (!admin)//send the user to student main
     {
         StudentMain g = new StudentMain(id);
         g.Show();
         this.Dispose();
     }
     else//otherwise, send the user to admin
     {
         AdminSeeSchedule g = new AdminSeeSchedule(id);
         g.Show();
         this.Dispose();
     }
 }
        private void btnSubmit_Click(object sender, EventArgs e)
        {
            if (lvTimeMatches.CheckedItems.Count == 0)
            {
                MessageBox.Show("Please pick one time slot for the appointment.");
            }
            else if (string.IsNullOrWhiteSpace(tbxLocation.Text.ToString()))
            {
                MessageBox.Show("Please input a location for this appointment.");
            }
            else
            {
                TutorMasterDBEntities4 db = new TutorMasterDBEntities4();

                List <Commitment> tuteeCommits = new List <Commitment>();
                List <Commitment> tutorCommits = new List <Commitment>();


                if (!tutoring)                                                                                                                                      //if this person is not a tutor
                {
                    tuteeCommits = (from stucmt in db.StudentCommitments.AsEnumerable()                                                                             //get the tutee commitment list
                                    where stucmt.ID == id
                                    join cmt in db.Commitments.AsEnumerable() on stucmt.CmtID equals cmt.CmtID
                                    select cmt).ToList();
                    SortsAndSearches.QuickSort(ref tuteeCommits, tuteeCommits.Count);                                                                               //sort the tutee commitment list

                    tutorCommits = (from stucmt in db.StudentCommitments.AsEnumerable()                                                                             //get and sort the tutor commitment list
                                    where stucmt.ID == rememberStudIDs[chosenStudentIndex]
                                    join cmt in db.Commitments.AsEnumerable() on stucmt.CmtID equals cmt.CmtID
                                    select cmt).ToList();

                    SortsAndSearches.QuickSort(ref tutorCommits, tutorCommits.Count);
                    string classCode = (from row in db.Classes.AsEnumerable() where row.ClassName == cbxClasses.Text.ToString() select row.ClassCode).First();          //get the classcode

                    string timeSlot      = lvTimeMatches.CheckedItems[0].SubItems[0].Text.ToString() + "," + lvTimeMatches.CheckedItems[0].SubItems[1].Text.ToString(); //time slot of the commitment
                    int    sessionLength = Convert.ToInt32(cbxHour.Text) * 4 + (Convert.ToInt32(cbxMinutes.Text) / 15);                                                 //number of 15 minute time blocks

                    addCommits(timeSlot, rememberStudIDs[chosenStudentIndex], id, tutorCommits, tuteeCommits, classCode, db, cbWeekly.Checked, sessionLength);          //add the commitment to the student's schedules
                }
                else
                {
                    tutorCommits = (from stucmt in db.StudentCommitments.AsEnumerable()                                                                             //get and sort the tutor commitments
                                    where stucmt.ID == id
                                    join cmt in db.Commitments.AsEnumerable() on stucmt.CmtID equals cmt.CmtID
                                    select cmt).ToList();
                    SortsAndSearches.QuickSort(ref tutorCommits, tutorCommits.Count);

                    tuteeCommits = (from stucmt in db.StudentCommitments.AsEnumerable()                                                                             //get and sort the tutee commitments
                                    where stucmt.ID == rememberStudIDs[chosenStudentIndex]
                                    join cmt in db.Commitments.AsEnumerable() on stucmt.CmtID equals cmt.CmtID
                                    select cmt).ToList();

                    SortsAndSearches.QuickSort(ref tuteeCommits, tuteeCommits.Count);
                    string classCode = (from row in db.Classes.AsEnumerable() where row.ClassName == cbxClasses.Text.ToString() select row.ClassCode).First();          //get the classcode

                    string timeSlot      = lvTimeMatches.CheckedItems[0].SubItems[0].Text.ToString() + "," + lvTimeMatches.CheckedItems[0].SubItems[1].Text.ToString(); //get the time slot that has been chosen
                    int    sessionLength = Convert.ToInt32(cbxHour.Text) * 4 + (Convert.ToInt32(cbxMinutes.Text) / 15);                                                 //get the number of 15 minute time blocks

                    addCommits(timeSlot, id, rememberStudIDs[chosenStudentIndex], tutorCommits, tuteeCommits, classCode, db, cbWeekly.Checked, sessionLength);          //add commitments to student's schedules
                }

                if (edit)
                {
                    MessageBox.Show("The appointment has been updated for both students and availability schedules have been adjusted approriately.");
                }
                else
                {
                    MessageBox.Show("The appointment has been set and finalized in both student's schedules.");
                }

                AdminSeeSchedule g = new AdminSeeSchedule(id);
                g.Show();
                this.Dispose();
            }
        }