Exemplo n.º 1
0
        private void InitializeFields(ItemPricingModel item)
        {
            _haltEvents               = true;
            textBoxPrice.Text         = item.Price.ToString("C2");
            comboBoxDay.SelectedIndex = (int)item.DayOfWeek;
            if (item.StartTime.HasValue)
            {
                timePickerStart.Hour   = item.StartTime.Value.Hours;
                timePickerStart.Minute = item.StartTime.Value.Minutes;
            }
            else
            {
                timePickerStart.Hour   = 0;
                timePickerStart.Minute = 0;
            }
            timePickerStart.UpdateLayout();

            if (item.EndTime.HasValue)
            {
                timePickerEnd.Hour   = item.EndTime.Value.Hours;
                timePickerEnd.Minute = item.EndTime.Value.Minutes;
            }
            else
            {
                timePickerEnd.Hour   = 23;
                timePickerEnd.Minute = 59;
                timePickerEnd.UpdateLayout();
            }
            //textBoxDiscountMin.Text = "" + (item.AdditionalDiscountMin.HasValue ? "" + item.AdditionalDiscountMin.Value : "");
            //textBoxDiscountMax.Text = "" + (item.AdditionalDiscountMax.HasValue ? "" + item.AdditionalDiscountMax.Value : "");
            //textBoxDiscountPrice.Text = "" + (item.AdditionalDiscountPrice.HasValue ? "" + item.AdditionalDiscountPrice.Value : "");
            _haltEvents = false;
        }
Exemplo n.º 2
0
        private void listBox1_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if ((e.AddedItems == null) || (e.AddedItems.Count == 0))
            {
                return;
            }
            FormattedListBoxItem item  = (FormattedListBoxItem)e.AddedItems[0];
            ItemPricingModel     model = (ItemPricingModel)item.ReferenceObject;

            InitializeFields(model);
            buttonRemove.IsEnabled = true;
            //SetReadOnly(false);
        }
Exemplo n.º 3
0
        private void AddItemPricingToListBox(ItemPricingModel price)
        {
            if (price == null)
            {
                return;
            }
            string description        = GenerateListBoxDescription(price);
            FormattedListBoxItem item =
                new FormattedListBoxItem(price, description, true);

            listBox1.Items.Add(item);
            listBox1.SelectedItem = item;
            listBox1.ScrollIntoView(listBox1.SelectedItem);
        }
Exemplo n.º 4
0
        private static string GenerateListBoxDescription(ItemPricingModel price)
        {
            string description = price.DayOfWeek.ToString();

            if (price.StartTime.HasValue && price.EndTime.HasValue)
            {
                description += Strings.ItemEditorListboxText1 +
                               price.StartTime.Value.Hours + ":" +
                               price.StartTime.Value.Minutes.ToString("D2") +
                               Strings.ItemEditorListboxText2 +
                               price.EndTime.Value.Hours + ":" +
                               price.EndTime.Value.Minutes.ToString("D2");
            }
            description += " (" + String.Format("{0:C}", price.Price) + ")";
            return(description);
        }
Exemplo n.º 5
0
        private void timePickerStart_TimeChanged(object sender, EventArgs e)
        {
            if (_haltEvents || (listBox1.SelectedItem == null))
            {
                return;
            }
            FormattedListBoxItem itemPricing = (FormattedListBoxItem)listBox1.SelectedItem;
            ItemPricingModel     pricing     = ((ItemPricingModel)itemPricing.ReferenceObject);

            pricing.StartTime = GetStartTime();
            if ((itemPricing.Id > 0) && (GetChangedItem(pricing) == null) && (pricing != null))
            {
                ChangedItems.Add(pricing);
            }
            itemPricing.Text = GenerateListBoxDescription(pricing);
            DoChangedValueEvent();
        }
Exemplo n.º 6
0
        private void pushComboBoxDayOfWeek_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (_haltEvents || (listBox1.SelectedItem == null))
            {
                return;
            }
            FormattedListBoxItem itemPricing = (FormattedListBoxItem)listBox1.SelectedItem;
            ItemPricingModel     pricing     = ((ItemPricingModel)itemPricing.ReferenceObject);

            pricing.DayOfWeek = GetDayOfWeek();
            if ((itemPricing.Id > 0) && (GetChangedItem(pricing) == null) && (pricing != null))
            {
                ChangedItems.Add(pricing);
            }
            itemPricing.Text = GenerateListBoxDescription(pricing);
            DoChangedValueEvent();
        }
Exemplo n.º 7
0
        private void InsertItemPricingInListBox(int index, ItemPricingModel price)
        {
            string description = GenerateListBoxDescription(price);

            if (price.Id > 0)
            {
                listBox1.Items.Insert(index,
                                      new FormattedListBoxItem(price, description, true));
            }
            else
            {
                listBox1.Items.Insert(index,
                                      new FormattedListBoxItem(price, description, true));
            }
            listBox1.SelectedItem = listBox1.Items[index];
            listBox1.ScrollIntoView(listBox1.SelectedItem);
        }
Exemplo n.º 8
0
        private void AddItemPricing()
        {
            //ItemPricing dummy = new ItemPricing(0, ItemId, Types.Days.Any, 0f, null, null, null, false);
            //ItemPricing newItem = ItemPricing.Add(ItemId, Types.Days.Any, 0f, null, null, null, false);
            ItemPricingModel newItem = new ItemPricingModel(ItemId, Days.Any, null, null, 0f);

            AddItemPricingToListBox(newItem);
            NewItems.Add(newItem);
            foreach (FormattedListBoxItem item in listBox1.Items)
            {
                item.IsSelected = Equals(item, listBox1.SelectedItem);
            }
            listBox1.ScrollIntoView(listBox1.SelectedItem);
            InitializeFields(newItem);
            SetReadOnly(false);
            buttonRemove.IsEnabled = true;
            DoChangedValueEvent();
            //InitializeListBox();
        }
Exemplo n.º 9
0
 private void RemoveItemPricing()
 {
     if (listBox1.SelectedItem != null)
     {
         int index = listBox1.SelectedIndex;
         FormattedListBoxItem pricing = (FormattedListBoxItem)listBox1.SelectedItem;
         ItemPricingModel     model   = (ItemPricingModel)pricing.ReferenceObject;
         if (model.Id == 0)
         {
             NewItems.Remove(model);
         }
         else
         {
             RemovedItems.Add(model);
         }
         listBox1.Items.Remove(pricing);
         ClearFields();
         DoChangedValueEvent();
         InitializeListBox(index);
     }
 }
Exemplo n.º 10
0
 private ItemPricingModel GetChangedItem(ItemPricingModel changedItem)
 {
     return((ChangedItems == null) ? null :
            ChangedItems.FirstOrDefault(pricing => pricing.Id == changedItem.Id));
 }