/// <summary> /// Find records /// </summary> /// <param name="CountryID">Country identifier</param> /// <param name="TaxCategoryID">Tax category identifier</param> /// <returns>Tax rates</returns> public TaxRateCollection FindTaxRates(int CountryID, int TaxCategoryID) { TaxRateCollection result = new TaxRateCollection(); foreach (TaxRate taxRate in this) { if (taxRate.CountryID == CountryID && taxRate.TaxCategoryID == TaxCategoryID) { result.Add(taxRate); } } return(result); }
private static TaxRateCollection DBMapping(DBTaxRateCollection dbCollection) { if (dbCollection == null) return null; TaxRateCollection collection = new TaxRateCollection(); foreach (DBTaxRate dbItem in dbCollection) { TaxRate item = DBMapping(dbItem); collection.Add(item); } return collection; }
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; } }
/// <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; TaxRateCollection taxRates = TaxRateManager.GetAllTaxRates(TaxCategoryID, CountryID, StateProvinceID, address.ZipPostalCode); if (taxRates.Count > 0) { tr += taxRates[0].Percentage; } return(tr); }
/// <summary> /// Gets all tax rates by params /// </summary> /// <param name="TaxCategoryID">The tax category identifier</param> /// <param name="CountryID">The country identifier</param> /// <param name="StateProvinceID">The state/province identifier</param> /// <param name="Zip">The zip</param> /// <returns>Tax rate collection</returns> public static TaxRateCollection GetAllTaxRates(int TaxCategoryID, int CountryID, int StateProvinceID, string Zip) { if (Zip == null) Zip = string.Empty; if (!String.IsNullOrEmpty(Zip)) Zip = Zip.Trim(); TaxRateCollection existingRates = GetAllTaxRates().FindTaxRates(CountryID, TaxCategoryID); //filter by state/province TaxRateCollection matchedByStateProvince = new TaxRateCollection(); foreach (TaxRate taxRate in existingRates) { if (StateProvinceID == taxRate.StateProvinceID) matchedByStateProvince.Add(taxRate); } if (matchedByStateProvince.Count == 0) { foreach (TaxRate taxRate in existingRates) { if (taxRate.StateProvinceID == 0) matchedByStateProvince.Add(taxRate); } } //filter by zip TaxRateCollection matchedByZip = new TaxRateCollection(); foreach (TaxRate taxRate in matchedByStateProvince) { if (Zip.ToLower() == taxRate.Zip.ToLower()) matchedByZip.Add(taxRate); } if (matchedByZip.Count == 0) { foreach (TaxRate taxRate in matchedByStateProvince) { if (taxRate.Zip.Trim() == string.Empty) matchedByZip.Add(taxRate); } } return matchedByZip; }