Esempio n. 1
0
        /// <summary>
        /// Adds errors if product prices are malformed
        /// </summary>
        /// <param name="numberOfProducts">number of poducts, used to loop througth all product prices</param>
        private void AddErrorsIfProductPricesInValid(int numberOfProducts)
        {
            int indexUnitPrice = indexNumberProducts + 3;

            for (int i = 0; i < numberOfProducts; i++)
            {
                int indexOfComma = numberValidator.AddSeparatorIfSeparatorNotExists(ref linesOfInvoiceToProcess[indexUnitPrice]);
                if (!numberValidator.IsNumberValid(linesOfInvoiceToProcess[indexUnitPrice], indexOfComma, out double result))
                {
                    InvoiceErrors.Add($"{ErrorMessages.productPriceError}, the error occured on product number {i + 1}");
                }
                // Increment indexes
                indexUnitPrice += 4;
            }
        }
Esempio n. 2
0
        /// <summary>
        /// On KeyUp handler for pressing a key in the priceDiscountTextBox, initiate check number on enter
        /// </summary>
        /// <param name="sender">object sending request</param>
        /// <param name="e">event arguments of request</param>
        private void PriceDiscountTextBox_KeyUp(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Enter)
            {
                TextBox discountTetBox = (TextBox)sender;
                string  inputString    = discountTetBox.Text;
                int     decimalIndex   = numberValidator.AddSeparatorIfSeparatorNotExists(ref inputString);

                bool numberOk = numberValidator.IsNumberValid(inputString, decimalIndex, out double result);
                if (numberOk)
                {
                    UpdatePrice(result);
                    discountTetBox.Text = result.ToString("N2");
                }
                else
                {
                    MessageBoxUtility.ShowErrorMessageBox(ErrorMessages.numberError);
                }
            }
        }