示例#1
0
        public void ConfirmProduct()
        {
            Product product = new Product()
            {
                Amount     = Amount,
                NetPrice   = NetPrice * Amount,
                Name       = ProductName,
                GrossPrice = NetPrice * Amount * (decimal)1.23
            };

            List <(string, bool)> validators = DataValidation.CheckProductFields(product);

            foreach (var validator in validators)
            {
                if (!validator.Item2)
                {
                    MessageBox.Show(validator.Item1, "Warning", MessageBoxButton.OK, MessageBoxImage.Warning);
                    break;
                }
            }

            if (validators.TrueForAll(x => x.Item2))
            {
                products.Items.Add(product);
            }
        }