Example #1
0
        protected void LoadEditor(int taxRateId)
        {
            ToggleGrid(false);

            TaxRate taxRate = TaxRateManager.GetTaxRateById(taxRateId);

            if (taxRate != null)
            {
                lblTaxRateId.Text = taxRate.TaxRateId.ToString();

                FillTaxCategoryDropDown();
                CommonHelper.SelectListItem(this.ddlTaxCategory, taxRate.TaxCategoryId);
                FillCountryDropDowns();
                CommonHelper.SelectListItem(this.ddlCountry, taxRate.CountryId);
                FillStateProvinceDropDowns();
                CommonHelper.SelectListItem(this.ddlStateProvince, taxRate.StateProvinceId);
                this.txtZip.Text         = taxRate.Zip;
                this.txtPercentage.Value = taxRate.Percentage;
            }
            else
            {
                lblTaxRateId.Text = "0";

                FillTaxCategoryDropDown();
                FillCountryDropDowns();
                FillStateProvinceDropDowns();

                txtZip.Text         = string.Empty;
                txtPercentage.Value = decimal.Zero;
            }
        }
Example #2
0
        protected void SaveButton_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                try
                {
                    int taxRateId = 0;
                    int.TryParse(lblTaxRateId.Text, out taxRateId);
                    int     taxCategoryId   = int.Parse(this.ddlTaxCategory.SelectedItem.Value);
                    int     countryId       = int.Parse(this.ddlCountry.SelectedItem.Value);
                    int     stateProvinceId = int.Parse(this.ddlStateProvince.SelectedItem.Value);
                    string  zipPostalCode   = txtZip.Text;
                    decimal percentage      = txtPercentage.Value;

                    TaxRate taxRate = TaxRateManager.GetTaxRateById(taxRateId);

                    if (taxRate != null)
                    {
                        taxRate = TaxRateManager.UpdateTaxRate(taxRate.TaxRateId, taxCategoryId,
                                                               countryId, stateProvinceId, zipPostalCode, percentage);
                    }
                    else
                    {
                        taxRate = TaxRateManager.InsertTaxRate(taxCategoryId,
                                                               countryId, stateProvinceId, zipPostalCode, percentage);
                    }

                    BindGrid();
                    ToggleGrid(true);
                }
                catch (Exception exc)
                {
                    ProcessException(exc);
                }
            }
        }