Exemplo n.º 1
0
        private void btnAddTax_Click(object sender, EventArgs e)                                //Add Tax Button
        {
            string   SelectedTaxType   = lstTaxType.SelectedItem.ToString();                    //Sets selected tax type from list
            string   taxType           = SelectedTaxType.First().ToString();                    //Selects only First letter to make it combatible with DB
            DateTime selectedStartDate = dateTimePickerAddTax.Value.Date;                       //Finds selected date
            string   taxRate           = txtBoxAddNewTax.Text;                                  //Finds entered taxRate
            int      municipalityId    = int.Parse(lstMunicipalities.SelectedValue.ToString()); //Gets the Id of the selected municipality
            string   municipalityName  = lstMunicipalities.Text;

            if (ReplaceDublicate.SelectedValue == false)
            {
                MessageBox.Show("Can't add the new tax\n'Replace existing' is set to: 'Ignore All'\nChange to 'Replace All' or 'Always Ask'", "Ignore All Selected", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            else if (Validater.TaxRate(taxRate) && ReplaceDublicate.SelectedValue != false)               //Validates correct TaxRate
            {
                AddTaxToDb.AddTax(selectedStartDate, taxType, taxRate, municipalityId, municipalityName); //Sends info to AddTax method
            }
            taxsearch();                                                                                  //Refreshes TaxSearcher
        }
Exemplo n.º 2
0
        public TaxRule(string _municipality, string _startDate, string _type, string _taxRate, bool _error)
        {
            Error = _error;


            if (!Error)                            //Checks if there were any errors while sending data to the TaxRule member
            {
                if (Validater.Week(_type) == true) //Check for valid Week Type format
                {
                    Type = _type;
                }
                else
                {
                    Error = true;
                }

                _taxRate = _taxRate.Replace('.', ',');   //Replaces . with , to makes it compatible with both

                if (Validater.TaxRate(_taxRate) == true) //Check for valid TaxRate format
                {
                    TaxRate = _taxRate;
                }
                else
                {
                    Error = true;
                }

                MunicipalityName = _municipality;

                if (Validater.StartDate(_startDate) == true)//Check for valid DateTime format
                {
                    StartDate = DateTime.Parse(_startDate);
                }
                else
                {
                    Error = true;
                }

                MunicipalityId = MunicipalityIdGetter(_municipality);//Gets Municipality Id
            }
        }