예제 #1
0
        private void buttonEditQuantity_Click(object sender, RoutedEventArgs e)
        {
            FormattedListBoxItem selectedItem = listBoxIncludedItems.SelectedItem as FormattedListBoxItem;

            if (selectedItem == null)
            {
                return;
            }
            ItemGroup itemGroup = selectedItem.ReferenceObject as ItemGroup;

            if (itemGroup == null)
            {
                return;
            }
            int?newQuantity = PosDialogWindow.PromptNumber(Strings.ItemEditorEditQuantity, null);

            if (newQuantity.HasValue)
            {
                itemGroup.SetTargetItemQuantity(newQuantity.Value);
                if (EditQuantityNeedsUpdating(itemGroup))
                {
                    _itemGroupsNeedingUpdate.Add(itemGroup);
                }

                InitializeListBoxes();
                DoValueChangedEvent();
            }
        }
예제 #2
0
        private void ApplyDiscount()
        {
            TicketDiscount result = null;

            FormattedListBoxItem selectedItem =
                (FormattedListBoxItem)listBoxAvailable.SelectedItem;
            Discount discount = (Discount)selectedItem.ReferenceObject;

            bool hasPermission = (!discount.RequiresPermission ||
                                  SessionManager.ActiveEmployee.HasPermission(Permissions.RegisterDiscounts));

            if (!hasPermission &&
                (PosHelper.GetPermission(Permissions.RegisterDiscounts) == null))
            {
                PosDialogWindow.ShowDialog(
                    Types.Strings.YouDoNotHavePermissionToApplyThisDiscount,
                    Types.Strings.PermissionDenied);
                return;
            }

            if (discount.Amount == null)
            {
                double?amount = discount.AmountIsPercentage ?
                                PosDialogWindow.PromptPercentage(this, Types.Strings.EnterDiscountPercentage, null) :
                                PosDialogWindow.PromptNumber(Types.Strings.EnterDiscountAmount, (double?)null);
                if (amount != null)
                {
                    result = TicketDiscount.Add(discount.Id, SelectedTicket.PrimaryKey,
                                                amount.Value, SessionManager.PseudoEmployeeId);
                }
            }
            else
            {
                result = TicketDiscount.Add(discount.Id, SelectedTicket.PrimaryKey,
                                            null, SessionManager.PseudoEmployeeId);
            }

            if (result != null)
            {
                listBoxAvailable.SelectedItem = null;
                listBoxAvailable.Items.Remove(selectedItem);

                listBoxApplied.Items.Add(selectedItem);
                listBoxApplied.SelectedItem = selectedItem;
            }
        }
        private void AdjustInventoryByRecipe(string windowTitle, int factor)
        {
            if (ActiveIngredient.ExtendedIngredientYield == null)
            {
                PosDialogWindow.ShowDialog(
                    Types.Strings.IngredientEditorNoYieldError,
                    Types.Strings.Error);
                return;
            }
            double?amount = PosDialogWindow.PromptNumber(windowTitle, (double)0);

            if ((amount != null) && (amount.Value > 0))
            {
                IsAdjustedByRecipe = true;
                if (ExtendedIngredientYieldAmount != null)
                {
                    InventoryAmount += (ExtendedIngredientYieldAmount.Value * amount.Value * factor);
                }
                textBoxInventoryAmount.Text = FormatDoubleToString(InventoryAmount);
                DoValueChangedEvent();
            }
        }
예제 #4
0
        private void AdjustInventoryByRecipe(string windowTitle, int factor)
        {
            if (ActiveIngredient.ExtendedIngredientYield == null)
            {
                PosDialogWindow.ShowDialog(Strings.InventoryError, Strings.Error);
                return;
            }
            double?amount = PosDialogWindow.PromptNumber(windowTitle, (double)0);

            if ((amount != null) && (amount.Value > 0))
            {
                double amountDelta = (ActiveIngredient.ExtendedIngredientYield.Value * amount.Value * factor);

                IngredientAdjustment.Add(SessionManager.ActiveEmployee.Id, ActiveIngredient.Id,
                                         ActiveIngredient.InventoryAmount,
                                         ActiveIngredient.InventoryAmount + amountDelta,
                                         ActiveIngredient.MeasurementUnit);

                ActiveIngredient.SetInventoryAmount(ActiveIngredient.InventoryAmount + amountDelta);
                ActiveIngredient.Update();

                AddIngredientPreparation(ActiveIngredient.Id, amountDelta);
            }
        }