//when the user changes class, retrieve from database updated grade categories
        private void cbEventClass_SelectedIndexChanged(object sender, EventArgs e)
        {
            //if no class is selected, simply ignore
            if (cbEventClass.Text.Equals(""))
            {
                return;
            }

            //dynamically add class grade categories to combo box
            Util.addTypes(cbEventType, currentClassId[cbEventClass.SelectedIndex].ToString(), false, null);
        }
Exemple #2
0
 //when the user changes class, retrieve from database updated grade categories
 private void cbEventClass_SelectedIndexChanged(object sender, EventArgs e)
 {
     Util.addTypes(cbEventType, classId[cbEventClass.SelectedIndex].ToString(), false, null);
 }
        public void loadEvent(int eventNum)
        {
            //dynamically get information about the selected event
            SQLiteDataReader events = Database.executeQuery("SELECT * FROM Event WHERE EventID = '" + eventNum + "';");

            //there should only be one event returned
            while (events.Read() == true)
            {
                //populate form with information retrieved from database
                txtEventTitle.Text       = events.GetString(1);
                txtEventDescription.Text = events.GetValue(2).ToString();
                txtLocation.Text         = events.GetValue(3).ToString();
                dtEventStartDate.Value   = events.GetDateTime(4);
                dtEventStartTime.Value   = events.GetDateTime(4);
                dtEventEndDate.Value     = events.GetDateTime(5);
                dtEventEndTime.Value     = events.GetDateTime(5);
                chkAllDayEvent.Checked   = Convert.ToBoolean(events.GetString(6));
                chkAllDayEvent_CheckedChanged(null, null);
            }
            events.Close();

            //query to get information if a graded assignment
            SQLiteDataReader graded = Database.executeQuery("SELECT * FROM GradedAssignment WHERE EventID = '"
                                                            + eventNum + "';");

            //clear the existing grade information
            txtEventGrade.ResetText();
            txtEventGradeTotalPoints.ResetText();

            //get the grade information from the database (there should only be one result row returned)
            if (graded.Read() == true)
            {
                chkGradedAssignment.Checked = true;
                chkGradedAssignment_CheckedChanged(null, null);

                //set the name and grade information for the event
                txtAssignmentName.Text        = graded.GetString(1);
                txtEventGrade.Text            = graded.GetValue(2).ToString();
                txtEventGradeTotalPoints.Text = graded.GetValue(3).ToString();

                //set the current class associated with the grade assignment
                cbEventClass.SelectedIndex = currentClassId.IndexOf(graded.GetInt32(4));

                //add possible types to choose from based on current class
                Util.addTypes(cbEventType, currentClassId[cbEventClass.SelectedIndex].ToString(), false, null);

                //set the current event type for the drop down list
                cbEventType.Text = graded.GetString(5);
            }
            else
            {
                //reset all parts of the graded assignment portion of the event
                chkGradedAssignment.Checked = false;
                chkGradedAssignment_CheckedChanged(null, null);
                txtAssignmentName.ResetText();
                cbEventClass.SelectedIndex = -1;
                cbEventType.SelectedIndex  = -1;
            }
            graded.Close();

            //set the selected event to the event with the given id (used if passing in event id
            //  into constructor when an event is double clicked)
            cbEvent.SelectedIndex = eventId.IndexOf(eventNum);

            //update save and delete buttons (will now be enabled since we have selected an event)
            updateButtons();
        }