Exemplo n.º 1
0
 private void addCategoryButton_Click(object sender, EventArgs e)
 {
     selectedCategory = new scheduleCategory();
     var foos = new List<scheduleCategory>(schedule.trainCategory);
     foos.Add(selectedCategory);
     schedule.trainCategory = foos.ToArray();
     categoriesListBox.SelectedIndex = categoriesListBox.Items.Add(selectedCategory);
     LoadCategoryPanel();
     categoryCategorycomboBox.Focus();
 }
Exemplo n.º 2
0
        private void LoadCategoryPanel()
        {
            if (categoriesListBox.SelectedIndex >= 0)
            {
                ((Control)categoryTabPage).Enabled = true;
                selectedCategory = categoriesListBox.SelectedItem as scheduleCategory;

                loadingCategory = true;

                categoryCategorycomboBox.Items.Clear();
                categoryCategorycomboBox.Items.AddRange(Timetable.trainCategory);
                foreach (trainCategory category in categoryCategorycomboBox.Items)
                    if (category.categoryID == selectedCategory.categoryID)
                        categoryCategorycomboBox.SelectedItem = category;

                categoryDaysCheckedListBox.SetItemChecked(0, selectedCategory.days.monday);
                categoryDaysCheckedListBox.SetItemChecked(1, selectedCategory.days.tuesday);
                categoryDaysCheckedListBox.SetItemChecked(2, selectedCategory.days.wednesday);
                categoryDaysCheckedListBox.SetItemChecked(3, selectedCategory.days.thursday);
                categoryDaysCheckedListBox.SetItemChecked(4, selectedCategory.days.friday);
                categoryDaysCheckedListBox.SetItemChecked(5, selectedCategory.days.saturday);
                categoryDaysCheckedListBox.SetItemChecked(6, selectedCategory.days.sunday);

                if (selectedCategory.startDate.Year > 1) categoryStartDateTimePicker.Value = selectedCategory.startDate;
                UpdateDateTime(categoryStartDateTimePicker, categoryStartCheckBox);
                categoryStartCheckBox.Checked = selectedCategory.startDateSpecified;

                if (selectedCategory.endDate.Year > 1) categoryEndDateTimePicker.Value = selectedCategory.endDate;
                UpdateDateTime(categoryEndDateTimePicker, categoryEndCheckBox);
                categoryEndCheckBox.Checked = selectedCategory.endDateSpecified;

                loadingCategory = false;
            }
            else
            {
                ((Control)categoryTabPage).Enabled = false;
                selectedCategory = null;
            }
        }
Exemplo n.º 3
0
 private void deleteCategoryButton_Click(object sender, EventArgs e)
 {
     if (categoriesListBox.SelectedItem != null)
     {
         scheduleCategory ass = categoriesListBox.SelectedItem as scheduleCategory;
         if (MessageBox.Show("Delete " + ass.ToString() + "?", "Delete", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
         {
             var foos = new List<scheduleCategory>(schedule.trainCategory);
             foos.Remove(ass);
             schedule.trainCategory = foos.ToArray();
             selectedCategory = null;
             categoriesListBox.Items.Remove(ass);
             LoadCategoryPanel();
         }
     }
 }