Ejemplo n.º 1
0
    protected void Process_AddEdit()
    {
        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>();
        int page_data = _CurrentPageNumber;
        Ektron.Cms.Common.Criteria<TaxRateProperty> postalCriteria = new Ektron.Cms.Common.Criteria<TaxRateProperty>(TaxRateProperty.PostalCode, EkEnumeration.OrderByDirection.Ascending);
        string postalCode = "0";
        long id = 0;
        TaxApi taxApi = new TaxApi();

        TaxClassList = _TaxClassApi.GetList(TaxClasscriteria);

        if (Request.QueryString["postalid"] != "")
        {
            postalCode = Request.QueryString["postalid"];
        }

        if (Request.QueryString["id"] != "")
        {
            id = Convert.ToInt64(Request.QueryString["id"]);
        }
        postalCriteria.PagingInfo.CurrentPage = page_data;
        postalCriteria.AddFilter(TaxRateProperty.TaxTypeId, CriteriaFilterOperator.EqualTo, TaxRateType.PostalSalesTax);

        List<TaxRateData> postalRateList;
        postalRateList = taxApi.GetList(postalCriteria);

        if (this.m_iID > 0 && Page.IsPostBack)
        {
            try
            {
                for (int i = 0; i <= TaxClassList.Count - 1; i++)
                {
                    PostalCodeTaxRateData postalCodeData = new PostalCodeTaxRateData();
                    tTax = taxApi.GetItemByPostalId(TaxClassList[i].Id, id);

                    if (tTax == null)
                    {
                        tTax = new PostalCodeTaxRateData(postalCode, Convert.ToInt64(drp_region.SelectedValue), 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]))
                        {
                            postalCodeData = new PostalCodeTaxRateData(txt_name.Text, Convert.ToInt64(drp_region.SelectedValue), TaxClassList[i].Id, System.Convert.ToDecimal(Convert.ToDecimal(Request.Form["txtClassRate" + i]) / 100));
                            taxApi.Update(postalCodeData);
                        }
                    }
                }
                Response.Redirect(_PageName + "?action=view&id=" + m_iID.ToString() + "&postalid=" + postalCode, false);
            }
            catch (CmsException exc)
            {
                Utilities.ShowError(EkFunctions.GetAllValidationMessages(exc.ValidationResults));
            }
        }
        else
        {
            try
            {
                PostalCodeTaxRateData postalrate = new PostalCodeTaxRateData();

                for (int i = 0; i <= TaxClassList.Count - 1; i++)
                {
                    if (Information.IsNumeric(Request.Form["txtClassRate" + i]))
                    {
                        postalrate = new PostalCodeTaxRateData(txt_name.Text, Convert.ToInt64(drp_region.SelectedValue), TaxClassList[i].Id, System.Convert.ToDecimal(Convert.ToDecimal(Request.Form["txtClassRate" + i]) / 100));
                        taxApi.Add(postalrate);
                    }
                }
                Response.Redirect(_PageName, false);
            }
            catch (CmsException exc)
            {
                Utilities.ShowError(EkFunctions.GetAllValidationMessages(exc.ValidationResults));
            }
        }

        TotalPages.Visible = false;
        CurrentPage.Visible = false;
        lnkBtnPreviousPage.Visible = false;
        NextPage.Visible = false;
        LastPage.Visible = false;
        FirstPage.Visible = false;
        PageLabel.Visible = false;
        OfLabel.Visible = false;
    }
Ejemplo n.º 2
0
    protected void Display_AddEdit()
    {
        int page_data = _CurrentPageNumber;
        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.Common.Criteria<TaxRateProperty> postalCriteria = new Ektron.Cms.Common.Criteria<TaxRateProperty>(TaxRateProperty.PostalCode, EkEnumeration.OrderByDirection.Ascending);
        string postalCode = "0";
        long id = 0;
        TaxApi taxApi = new TaxApi();
        RegionData rRegion = new RegionData();
        Ektron.Cms.Common.Criteria<RegionProperty> criteria = new Ektron.Cms.Common.Criteria<RegionProperty>(RegionProperty.Name, Ektron.Cms.Common.EkEnumeration.OrderByDirection.Ascending);
        int cCountryId = 0;
        int txtClassList = 0;

        Util_BindCountries();

        if (Request.QueryString["postalid"] != "")
        {
            postalCode = Request.QueryString["postalid"];
        }

        if (Request.QueryString["id"] != "")
        {
            id = Convert.ToInt64(Request.QueryString["id"]);
        }

        postalCriteria.PagingInfo.CurrentPage = page_data;
        postalCriteria.AddFilter(TaxRateProperty.TaxTypeId, CriteriaFilterOperator.EqualTo, TaxRateType.PostalSalesTax);

        List<TaxRateData> postalRateList;
        postalRateList = taxApi.GetList(postalCriteria);

        TaxClassList = _TaxClassApi.GetList(TaxClasscriteria);

        txt_name.Text = postalCode;
        if (txt_name.Text == "0" || 0 == txt_name.Text.Length)
        {
            txt_name.Enabled = true;
        }
        else
        {
            txt_name.Enabled = false;
        }
        lbl_id.Text = id.ToString();

        _RegionList = _RegionApi.GetList(criteria);

        cCountryId = System.Convert.ToInt32(drp_country.SelectedValue);
        Util_BindRegions(cCountryId);

        ltr_txtClass.Text = "<table class=\"ektronGrid\">";
        for (txtClassList = 0; txtClassList <= TaxClassList.Count - 1; txtClassList++)
        {
            PostalCodeTaxRateData postalRegion = new PostalCodeTaxRateData();
            postalRegion = (PostalCodeTaxRateData)taxApi.GetItemByPostalId(TaxClassList[txtClassList].Id, id);
            if (postalRegion != null)
            {
                criteria.AddFilter(RegionProperty.Id, CriteriaFilterOperator.EqualTo, postalRegion.RegionId);
                _RegionList = _RegionApi.GetList(criteria);
                drp_region.SelectedValue = _RegionList[0].Id.ToString();
                cCountryId = System.Convert.ToInt32(_RegionList[0].CountryId);
                drp_country.SelectedValue = cCountryId.ToString();
                Util_BindRegions(cCountryId);
            }

            ltr_txtClass.Text += "<tr>";
            ltr_txtClass.Text += "   <td class=\"label\">" + TaxClassList[txtClassList].Name + "</td>";
            if (taxApi.GetItemByPostalId(TaxClassList[txtClassList].Id, id) == null)
            {
                ltr_txtClass.Text += "   <td class=\"value\">";
                ltr_txtClass.Text += "       <input type=\"text\" name=\"txtClassRate" + txtClassList + "\" id=\"txtClassRate" + txtClassList + "\" value=\"0\" />%";
                ltr_txtClass.Text += "   </td>";
            }
            else
            {
                ltr_txtClass.Text += "   <td class=\"value\">";
                ltr_txtClass.Text += "       <input type=\"text\" name=\"txtClassRate" + txtClassList + "\" id=\"txtClassRate" + txtClassList + "\" value=\"" + taxApi.GetItemByPostalId(TaxClassList[txtClassList].Id, id).Rate * 100 + "\"/>%";
                ltr_txtClass.Text += "   </td>";
            }
            ltr_txtClass.Text += "</tr>";
        }
        ltr_txtClass.Text += "</table>";

        tr_id.Visible = m_iID > 0;
        pnl_view.Visible = true;
        pnl_viewall.Visible = false;

        if (this.m_iID > 0)
        {
            drp_country.Enabled = false;
            drp_region.Enabled = 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;
    }