示例#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;
            }
        }
示例#2
0
        protected void gvTaxRates_RowDeleting(object source, GridViewDeleteEventArgs e)
        {
            HiddenField hfTaxRateID = gvTaxRates.Rows[e.RowIndex].Cells[0].FindControl("hfTaxRateID") as HiddenField;
            int         taxRateID   = int.Parse(hfTaxRateID.Value);

            TaxRateManager.DeleteTaxRate(taxRateID);
            BindGrid();
        }
示例#3
0
        protected void BindGrid()
        {
            TaxRateCollection taxRates = TaxRateManager.GetAllTaxRates();

            gvTaxRates.DataSource = taxRates;
            gvTaxRates.DataBind();
            if (taxRates.Count > 10)
            {
                btnAddNew1.Visible = true;
                btnAddNew2.Visible = true;
            }
            else
            {
                btnAddNew1.Visible = true;
                btnAddNew2.Visible = false;
            }
        }
示例#4
0
        /// <summary>
        /// Gets a tax rate
        /// </summary>
        /// <param name="address">Address</param>
        /// <param name="taxCategoryID">The tax category identifier</param>
        /// <returns>Tax rate</returns>
        protected decimal GetTaxRate(Address address, int taxCategoryID)
        {
            int CountryID       = 0;
            int StateProvinceID = 0;

            if (address.Country != null)
            {
                CountryID = address.Country.CountryId;
            }
            if (address.StateProvince != null)
            {
                StateProvinceID = address.StateProvince.StateProvinceId;
            }
            decimal tr       = decimal.Zero;
            var     taxRates = TaxRateManager.GetAllTaxRates(taxCategoryID, CountryID, StateProvinceID, address.ZipPostalCode);

            if (taxRates.Count > 0)
            {
                tr += taxRates[0].Percentage;
            }
            return(tr);
        }
示例#5
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);
                }
            }
        }
 public RemoveOrder(ProductManager pMgr, OrderManager oMgr, TaxRateManager tMgr)
 {
     _myProductManager = pMgr;
     _myTaxManager     = tMgr;
     _myOrderManager   = oMgr;
 }
示例#7
0
 public TaxRateManagerTests()
 {
     _productVariantService = A.Fake <IProductVariantService>();
     _getDefaultTaxRate     = A.Fake <IGetDefaultTaxRate>();
     _taxRateManager        = new TaxRateManager(Session, _productVariantService, _getDefaultTaxRate);
 }