Exemplo n.º 1
0
 public TrainCategoryForm(trainCategory _item, timetable _timetable, bool isNewItem)
     : base(_item, _timetable)
 {
     InitializeComponent();
     EnableCategoryID = isNewItem;
     LoadControls();
 }
Exemplo n.º 2
0
 internal void AddItem(object item)
 {
     if (item is trainCategory)
     {
         if (trainCategory == null) trainCategory = new trainCategory[0];
         var foos = new List<trainCategory>(trainCategory);
         foos.Add(item as trainCategory);
         trainCategory = foos.ToArray();
     }
     else if (item is schedule)
     {
         if (schedule == null) schedule = new schedule[0];
         var foos = new List<schedule>(schedule);
         foos.Add(item as schedule);
         schedule = foos.ToArray();
     }
     else if (item is rule)
     {
         if (rule == null) rule = new rule[0];
         var foos = new List<rule>(rule);
         foos.Add(item as rule);
         rule = foos.ToArray();
     }
 }
Exemplo n.º 3
0
        private void addButton_Click(object sender, EventArgs e)
        {
            object item = null;
            BaseEditForm frm = null;
            switch (selectComboBox.SelectedIndex)
            {
                case 0:
                    item = new trainCategory();
                    (item as trainCategory).categoryID = Timetable.GetNewID();
                    frm = new TrainCategoryForm((trainCategory)item, Timetable, true);
                    break;

                case 1:
                    item = new schedule();
                    (item as schedule).scheduleID = Timetable.GetNewID();
                    frm = new EditScheduleForm(item as schedule, Timetable, Locations, true);
                    item = frm.Item;
                    break;

                case 2:
                    frm = new EditRuleForm(new rule(), Timetable);
                    item = frm.Item;
                    break;
            }

            if ((frm != null) && (frm.ShowDialog() == System.Windows.Forms.DialogResult.OK))
            {
                item.ToString();
                listBox1.Items.Add(item);
                Timetable.AddItem(item);
                Changed = true;
            }
        }