public void AddItemPrenotationButtonHandler(Object obj, EventArgs e)
        {
            DateRange range = new DateRange(_fromDateTimePicker.Value, _toDateTimePicker.Value);

            using (AddItemPrenotationDialog sd = new AddItemPrenotationDialog(range))
            {
                if (sd.ShowDialog() == DialogResult.OK)
                {
                    ICustomizableItemPrenotation itemPrenotation = sd.SelectedItem;
                    if (itemPrenotation != null)
                    {
                        _itemsPrenotation.Add(itemPrenotation);
                        _itemPrenotationListView.Items.Add(itemPrenotation.InformationString);
                        if (CanCreate())
                        {
                            _createButton.Enabled = true;
                        }
                    }
                    _clearButton.Enabled = true;
                }
                else
                {
                    return;
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// CustomPrenotation per l'interfaccia ICustomizableItemPrenotation
        /// Recupera i plugin associati
        /// </summary>
        /// <param name="ip"></param>
        /// <returns></returns>
        private TreeNode[] CustomItemPrenotation(ICustomizableItemPrenotation ip)
        {
            TreeNode plugin = new TreeNode();

            plugin.Text = "PLUGIN";

            foreach (IItem i in ip.Plugins)
            {
                plugin.Nodes.Add(_itemNodes[i]);
            }

            return(new TreeNode[] { plugin });
        }
Ejemplo n.º 3
0
 public bool CanAdd(ICustomizableItemPrenotation customizableItemPrenotation)
 {
     #region Precondizioni
     if (customizableItemPrenotation == null)
     {
         throw new ArgumentNullException("item prenotation null");
     }
     #endregion
     return(!_prenotations.Where(
                prenotation => prenotation.BookedItems.Where(
                    item => item.BaseItem.Sector == customizableItemPrenotation.BaseItem.Sector &&
                    item.BaseItem.Position.Row == customizableItemPrenotation.BaseItem.Position.Row &&
                    item.BaseItem.Position.Column == customizableItemPrenotation.BaseItem.Position.Column &&
                    item.RangeData.OverlapWith(customizableItemPrenotation.RangeData)
                    ).Any()
                ).Any());
 }
Ejemplo n.º 4
0
 public void AddBookableItemButtonHandler(Object obj, EventArgs e)
 {
     using (SelectBookableItemDialog sd = new SelectBookableItemDialog(_range))
     {
         sd.LoadStructures(_sCoord.Structures);
         if (sd.ShowDialog() == DialogResult.OK)
         {
             IBookableItem bookableItem = sd.SelectedItem;
             if (bookableItem != null)
             {
                 _itemPrenotation             = new CustomizableItemPrenotation(sd.Range, sd.SelectedItem);
                 _addBookableItemButton.Text  = "Cambia elemento prenotabile";
                 _addPluginItemButton.Enabled = true;
                 Sector        sector    = _itemPrenotation.BaseItem.Sector;
                 Structure     structure = null;
                 StructureArea area      = null;
                 foreach (Structure s in _sCoord.Structures)
                 {
                     foreach (StructureArea a in s.Areas)
                     {
                         if (a.Sectors.Contains(sector))
                         {
                             structure = s;
                             area      = a;
                             break;
                         }
                     }
                 }
                 _locationLabelValue.Text    = structure.ToString() + " - " + area.ToString() + " - " + sector.ToString();
                 _itemLabelValue.Text        = _itemPrenotation.BaseItem.ToString();
                 _positionLabelValue.Text    = _itemPrenotation.BaseItem.Position.ToString();
                 _rangeLabelValue.Text       = _itemPrenotation.RangeData.StartDate.ToShortDateString() + " - " + _itemPrenotation.RangeData.EndDate.ToShortDateString();
                 _fromDateTimePicker.Enabled = true;
                 _fromDateTimePicker.Value   = _itemPrenotation.RangeData.StartDate;
                 _toDateTimePicker.Enabled   = true;
                 _toDateTimePicker.Value     = _itemPrenotation.RangeData.EndDate;
             }
         }
         else
         {
             return;
         }
     }
 }