private void dgRoundingRules_PreviewKeyDown(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Delete)
            {
                if (IsEditable)
                {
                    //Get confirmation before deleting the rule.
                    var source = e.OriginalSource as DataGridCell;
                    if (source != null && source.DataContext is PriceRoundingRule)
                    {
                        PriceRoundingRule rule   = source.DataContext as PriceRoundingRule;
                        object[]          values = { rule.DollarRangeLower, rule.DollarRangeUpper, rule.ValueChange };
                        string            prompt = String.Format("Delete this rounding rule (Min={0}, Max={1}, Rounding Value={2})?", values);

                        MessageBoxResult result = MessageBox.Show(prompt, "PRICEXPERT", MessageBoxButton.YesNoCancel, MessageBoxImage.Question);

                        //Cancel unless the user confirms.
                        e.Handled = (result != MessageBoxResult.Yes);
                    }
                }
                else
                {
                    e.Handled = true;
                }
            }
        }
Beispiel #2
0
        public static PriceRoundingRule Copy(this PriceRoundingRule source)
        {
            var copy = new PriceRoundingRule();

            copy.DollarRangeLower = source.DollarRangeLower;
            copy.DollarRangeUpper = source.DollarRangeUpper;
            copy.Type             = source.Type;
            copy.ValueChange      = source.ValueChange;

            foreach (SQLEnumeration roundingType in source.RoundingTypes)
            {
                SQLEnumeration valueCopy = roundingType.Copy();
                copy.RoundingTypes.Add(valueCopy);
            }

            return(copy);
        }
Beispiel #3
0
        private object ApplyTemplateExecuted(object parameter)
        {
            var template = parameter as PricingRoundingTemplate;

            if (template != null && SelectedPriceList != null)
            {
                string prompt      = String.Format("Copy the rounding rules\nfrom \"{0}\"\nto \"{1}\"?", SelectedTemplate.Name, SelectedPriceList.Name);
                bool   okToProceed = base.ShowPrompt(prompt) ?? false;

                if (okToProceed)
                {
                    //Copy the rules from the template to the price list.
                    List <PriceRoundingRule> copiedRules = new List <PriceRoundingRule>();
                    foreach (PriceRoundingRule rule in template.Rules)
                    {
                        PriceRoundingRule copy = rule.Copy();
                        copiedRules.Add(copy);
                    }
                    SelectedPriceList.LinkedPriceListRule.RoundingRules = copiedRules;
                }
            }
            return(null);
        }