Example #1
0
    protected void Process_Delete()
    {
        _TaxApi = new TaxApi();
        Ektron.Cms.Common.Criteria<TaxClassProperty> TaxClasscriteria = new Ektron.Cms.Common.Criteria<TaxClassProperty>(TaxClassProperty.Name, Ektron.Cms.Common.EkEnumeration.OrderByDirection.Ascending);
        System.Collections.Generic.List<TaxClassData> TaxClassList = new System.Collections.Generic.List<TaxClassData>();
        Ektron.Cms.Commerce.CountryTaxRateData m_CountryTax = new Ektron.Cms.Commerce.CountryTaxRateData();
        TaxClasscriteria.PagingInfo.RecordsPerPage = 10;
        TaxClassList = _TaxClassApi.GetList(TaxClasscriteria);

        if (this.m_iID > 0)
        {
            for (int j = 0; j <= TaxClassList.Count - 1; j++)
            {
                long tTax = new long();
                tTax = _TaxApi.GetItemByPostalId(TaxClassList[j].Id, m_iID).Id;
                _TaxApi.Delete(tTax);
            }
        }

        Response.Redirect(_PageName, false);
    }
Example #2
0
    protected void Process_AddEdit()
    {
        CountryData cCountry = null;
        TaxRateData tTax = null;
        Ektron.Cms.Common.Criteria<TaxClassProperty> TaxClasscriteria = new Ektron.Cms.Common.Criteria<TaxClassProperty>(TaxClassProperty.Name, Ektron.Cms.Common.EkEnumeration.OrderByDirection.Ascending);
        System.Collections.Generic.List<TaxClassData> TaxClassList = new System.Collections.Generic.List<TaxClassData>();
        Ektron.Cms.Commerce.CountryTaxRateData m_CountryTax = new Ektron.Cms.Commerce.CountryTaxRateData();
        TaxClassList = _TaxClassApi.GetList(TaxClasscriteria);
        m_CountryTax = new CountryTaxRateData();
        _TaxApi = new TaxApi();

        if (this.m_iID > 0)
        {
            cCountry = _CountryApi.GetItem(Convert.ToInt32(this.m_iID));
            cCountry.Name = (string)txt_name.Text;
            cCountry.LongIsoCode = (string)txt_long.Text;
            cCountry.ShortIsoCode = (string)txt_short.Text;
            cCountry.Enabled = System.Convert.ToBoolean(chk_enabled.Checked);
            _CountryApi.Update(cCountry);

            for (int i = 0; i <= TaxClassList.Count - 1; i++)
            {
                tTax = _TaxApi.GetItemByCountryId(TaxClassList[i].Id, cCountry.Id);
                if (tTax == null)
                {
                    tTax = new CountryTaxRateData(cCountry.Id, TaxClassList[i].Id, 0);
                    if (Information.IsNumeric(Request.Form["txtClassRate" + i]))
                    {
                        tTax.Rate = System.Convert.ToDecimal(Convert.ToDecimal(Request.Form["txtClassRate" + i]) / 100);
                        _TaxApi.Add(tTax);
                    }
                }
                else
                {
                    if (Information.IsNumeric(Request.Form["txtClassRate" + i]))
                    {
                        tTax.Rate = System.Convert.ToDecimal(Convert.ToDecimal(Request.Form["txtClassRate" + i]) / 100);
                        _TaxApi.Update(tTax);
                    }
                }
            }

            Response.Redirect(_PageName + "?action=view&id=" + m_iID.ToString(), false);
        }
        else
        {
            cCountry = new CountryData(Convert.ToInt32(txt_numeric.Text), txt_name.Text, txt_short.Text, txt_long.Text, chk_enabled.Checked);
            _CountryApi.Add(cCountry);

            for (int i = 0; i <= TaxClassList.Count - 1; i++)
            {
                tTax = new CountryTaxRateData(cCountry.Id, TaxClassList[i].Id, 0);
                if (Information.IsNumeric(Request.Form["txtClassRate" + i]))
                {
                    tTax.Rate = System.Convert.ToDecimal(Convert.ToDecimal(Request.Form["txtClassRate" + i]) / 100);
                    _TaxApi.Add(tTax);
                }
            }

            Response.Redirect(_PageName, false);
        }

        TotalPages.Visible = false;
        CurrentPage.Visible = false;
        lnkBtnPreviousPage.Visible = false;
        NextPage.Visible = false;
        LastPage.Visible = false;
        FirstPage.Visible = false;
        PageLabel.Visible = false;
        OfLabel.Visible = false;
    }