Ejemplo n.º 1
0
        public void AddPluginItemButtonHandler(Object obj, EventArgs e)
        {
            DateRange range = new DateRange(_fromDateTimePicker.Value, _toDateTimePicker.Value);

            using (SelectItemDialog sd = new SelectItemDialog())
            {
                sd.LoadItems(_iCoord.GetAssociableItemOf(SelectedItem.BaseItem.BaseItem));
                if (sd.ShowDialog() == DialogResult.OK)
                {
                    IItem plugin = sd.SelectedItem;
                    if (plugin != null)
                    {
                        _itemPrenotation.AddPlugin(plugin, range);
                        _pluginListView.Items.Add(plugin.FriendlyName + " (" + range.StartDate.ToShortDateString() + " - " + range.EndDate.ToShortDateString() + ")");
                    }
                }
                else
                {
                    return;
                }
            }
        }
 /// <summary>
 /// Gestisce l'azione dell'add button permettendo l'inserimento di una
 /// nuova categoria
 /// </summary>
 private void AddHandler(Object sender, EventArgs eventArgs)
 {
     if (_structureTree.SelectedNode != null)
     {
         Object selectedItem = _structureTree.SelectedNode.Tag;
         string text         = _structureTree.SelectedNode.Text;
         if (selectedItem == null && text.Contains("nessun elemento"))
         {
             IItem    baseItem = null;
             Position position = new Position((int)_structureTree.SelectedNode.Parent.Tag, _structureTree.SelectedNode.Index + 1);
             Sector   sector   = _structureTree.SelectedNode.Parent.Parent.Tag as Sector;
             using (SelectItemDialog sd = new SelectItemDialog())
             {
                 sd.LoadItems(_iCoordinator.BaseItems);
                 if (sd.ShowDialog() == DialogResult.OK)
                 {
                     baseItem = sd.SelectedItem;
                 }
                 else
                 {
                     return;
                 }
             }
             if (baseItem != null)
             {
                 IBookableItem bookItem = new SectorBookableItem(baseItem, position, sector);
                 _bCoordinator.AddBookableItem(bookItem);
                 StructureChangedHandler(this, EventArgs.Empty);
             }
         }
         else
         {
             //non si può aggiungere
         }
     }
 }