Пример #1
0
        private void OnEditCategory(object sender, EventArgs e)
        {
            FormEnterCategory form = new FormEnterCategory(CurrentClass.RemainingWeight + CurrentClass.CurrentCategory.Weight, CurrentClass.CurrentCategory.Weight, CurrentClass.CurrentCategory.Name);

            if (form.ShowDialog() == DialogResult.OK)
            {
                int index = comboBoxCategory.Items.IndexOf(CurrentClass.CurrentCategory.Name);
                comboBoxCategory.Items.Remove(CurrentClass.CurrentCategory.Name);
                CurrentClass.CurrentCategory.Name   = (string)form.data[0];
                CurrentClass.CurrentCategory.Weight = Convert.ToInt32(form.data[1]);
                comboBoxCategory.Items.Insert(index, CurrentClass.CurrentCategory.Name);
                comboBoxCategory.SelectedIndex = index;
                groupBoxTotals.Text            = CurrentClass.CurrentCategory.Name + " Totals (" + CurrentClass.CurrentCategory.Weight + "%)";
                UpdateGrade();
            }
        }
Пример #2
0
        //This event is fired when the user selects a category from the category selection spinner
        private void OnCategoryChange(object sender, EventArgs e)
        {
            //If the option selected is the first index, a new category is created.
            if (comboBoxCategory.SelectedIndex == 0)
            {
                if (CurrentClass.RemainingWeight == 0)
                {
                    comboBoxCategory.Text = CurrentClass.CurrentCategory.Name;
                    SystemSounds.Asterisk.Play();
                    MessageBox.Show("Class is full!");
                }
                else
                {
                    //Deselect text
                    comboBoxCategory.SelectedIndex = -1;
                    //Open up category selection form
                    FormEnterCategory formEnterCatgory = new FormEnterCategory(CurrentClass.RemainingWeight);
                    if (formEnterCatgory.ShowDialog() == DialogResult.OK)
                    {
                        //Create the category
                        Category category = new Category(formEnterCatgory.data[0].ToString(), Convert.ToInt32(formEnterCatgory.data[1]));
                        CurrentClass.RemainingWeight -= Convert.ToInt32(formEnterCatgory.data[1]);

                        //Add it to the categoryList
                        CurrentClass.CategoryList.Add(category);

                        //Add it to the comboBoxCategory
                        comboBoxCategory.Items.Add(category.Name);

                        //Set the currentCategoryIndex to the last index
                        CurrentClass.CurrentCategoryIndex = CurrentClass.CategoryList.Count - 1;
                        if (dataGridView.Enabled == false)
                        {
                            dataGridView.Enabled = true;
                        }

                        //Set the comboBox text to the new currentCategory's name
                        comboBoxCategory.Text = CurrentClass.CurrentCategory.Name;

                        //Load the data
                        LoadData();

                        //Store the data
                        StoreData();

                        //Update the totals
                        UpdateTotals();

                        //Update the grade
                        UpdateGrade();

                        editCategoryToolStripMenuItem.Enabled   = true;
                        deleteCategoryToolStripMenuItem.Enabled = true;
                        calculateToolStripMenuItem.Enabled      = true;
                    }
                    else if (CurrentClass.CategoryList.Count != 0)
                    {
                        comboBoxCategory.SelectedIndex = comboBoxCategory.Items.IndexOf(CurrentClass.CurrentCategory.Name);
                    }
                }
            }

            //Else, set the currentCategoryIndex to the index of the selected option minus one
            else
            {
                CurrentClass.CurrentCategoryIndex = comboBoxCategory.SelectedIndex - 1;

                //Load the data
                LoadData();

                //Store the data
                StoreData();

                //Update the totals
                UpdateTotals();

                //Update the grade
                UpdateGrade();
            }
        }
Пример #3
0
        //This event is fired when the user selects a category from the category selection spinner
        private void OnCategoryChange(object sender, EventArgs e)
        {
            //If the option selected is the first index, a new category is created.
            if (comboBoxCategory.SelectedIndex == 0)
            {
                //Deselect text
                comboBoxCategory.SelectedIndex = -1;
                //Open up category selection form
                FormEnterCategory formEnterCatgory = new FormEnterCategory(100);
                if (formEnterCatgory.ShowDialog() == DialogResult.OK)
                {
                    //Create the category
                    Category category = new Category(formEnterCatgory.data[0].ToString(), Convert.ToDouble(formEnterCatgory.data[1]));

                    //Add it to the categoryList
                    CurrentClass.CategoryList.Add(category);

                    //Add it to the comboBoxCategory
                    comboBoxCategory.Items.Add(category.Name);

                    //Set the currentCategoryIndex to the last index
                    CurrentClass.CurrentCategoryIndex = CurrentClass.CategoryList.Count - 1;
                    if (dataGridView.Enabled == false)
                    {
                        dataGridView.Enabled = true;
                    }

                    //Set the comboBox text to the new currentCategory's name
                    comboBoxCategory.Text = CurrentClass.CurrentCategory.Name;

                    //Load the data
                    LoadData();

                    //Store the data
                    StoreData();

                    //Update the totals
                    UpdateTotals();

                    //Update the grade
                    UpdateGrade();
                }
                else if (CurrentClass.CategoryList.Count != 0)
                {
                    comboBoxCategory.SelectedIndex = comboBoxCategory.Items.IndexOf(CurrentClass.CurrentCategory.Name);
                }
            }

            //Else, set the currentCategoryIndex to the index of the selected option minus one
            else
            {
                CurrentClass.CurrentCategoryIndex = comboBoxCategory.SelectedIndex - 1;

                //Load the data
                LoadData();

                //Store the data
                StoreData();

                //Update the totals
                UpdateTotals();

                //Update the grade
                UpdateGrade();
            }
        }