/// <summary>
        /// Generates company settings class instance from input provided by user.
        /// Displays error if input provided by user is incorrect
        /// </summary>
        /// <returns>True if user passed correct values and CompanySettings class instance was created.
        /// False otherwise</returns>
        private Company GenerateSettings()
        {
            Company newSettings = null;

            UInt64 REGON;
            UInt64 NIP;
            UInt16 houseNumber;
            UInt32 postalCode;

            //Postal code if combination of two text boxes values. Spaces should be removed in case user inserted some
            string postalCodeStr = (TextBoxAddressPostCode1.Text + TextBoxAddressPostCode2.Text).Replace(" ", string.Empty);

            ParseFailReason reason = InputParser.ParseCompanySettigns(TextBoxCompanyName.Text, TextBoxNIP.Text, out NIP,
                                                                      TextBoxREGON.Text, out REGON, TextBoxAddressStreet.Text, TextBoxAddressHouseNumber.Text, out houseNumber,
                                                                      TextBoxAddressCity.Text, postalCodeStr, out postalCode);

            if (ParseFailReason.None == reason)
            {
                newSettings = new Company(TextBoxCompanyName.Text, NIP, REGON, TextBoxAddressStreet.Text,
                                          houseNumber, TextBoxAddressCity.Text, postalCode, TextBoxBankAccountNumber.Text);
            }
            else
            {
                GUIInfoHelper.DisplayInputParseError(reason);
            }

            return(newSettings);
        }
        private bool ApplySettings()
        {
            bool result = false;

            if (null != InvSettings)
            {
                UInt32 vatRate;
                UInt32 paymentDays;

                string   vatRateStr     = TextBoxVATRate.Text;
                string   paymentDaysStr = TextBoxPaymentDays.Text;
                DateTime issueDate      = DatePickerIssueDate.SelectedDate ?? DateTime.Now;

                ParseFailReason reason = InputParser.ParseInvoiceSettings
                                             (vatRateStr, out vatRate, paymentDaysStr, out paymentDays);

                if (ParseFailReason.None != reason)
                {
                    GUIInfoHelper.DisplayInputParseError(reason);
                }
                else
                {
                    InvSettings.DaysForPayment = paymentDays;
                    InvSettings.VATRate        = vatRate;
                    InvSettings.IssueDate      = issueDate;
                    result = true;
                }
            }

            return(result);
        }
Esempio n. 3
0
        private void BeginAddItemToGridView()
        {
            UInt32 vatRate    = 0;
            double nettoPrice = 0.0f;
            UInt32 quantity   = 0;

            ParseFailReason parseFailReason = InputParser.ParseGridInvoiceItem
                                                  (TextBoxItemName.Text, TextBoxVATRate.Text, out vatRate, TextBoxNettoPrice.Text,
                                                  out nettoPrice, TextBoxQuantity.Text, out quantity);

            if (ParseFailReason.None == parseFailReason)
            {
                AddInvoiceItemToGridView(TextBoxItemName.Text, TextBoxComment.Text, nettoPrice, vatRate, quantity);
                DataGridInvoiceItems.Items.Refresh();
            }
            else
            {
                GUIInfoHelper.DisplayInputParseError(parseFailReason);
            }
        }