コード例 #1
0
ファイル: postaltaxtables.aspx.cs プロジェクト: jaytem/minGit
    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;
    }
コード例 #2
0
ファイル: postaltaxtables.aspx.cs プロジェクト: jaytem/minGit
    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;
    }
コード例 #3
0
ファイル: postaltaxtables.aspx.cs プロジェクト: jaytem/minGit
    protected void Display_All()
    {
        System.Collections.Generic.List<TaxClassData> TaxClassList = new System.Collections.Generic.List<TaxClassData>();
        Ektron.Cms.Common.Criteria<TaxClassProperty> TaxClasscriteria = new Ektron.Cms.Common.Criteria<TaxClassProperty>(TaxClassProperty.Name, Ektron.Cms.Common.EkEnumeration.OrderByDirection.Ascending);
        Ektron.Cms.Common.Criteria<TaxRateProperty> taxCriteria = new Ektron.Cms.Common.Criteria<TaxRateProperty>(TaxRateProperty.TaxClassName, Ektron.Cms.Common.EkEnumeration.OrderByDirection.Ascending);
        Ektron.Cms.Common.Criteria<TaxRateProperty> postalCriteria = new Ektron.Cms.Common.Criteria<TaxRateProperty>(TaxRateProperty.PostalCode, EkEnumeration.OrderByDirection.Ascending);
        CountryApi m_refCountryTaxRate = new CountryApi();
        int page_Data = _CurrentPageNumber;
        int i = 0;
        TaxApi taxApi = new TaxApi();
        List<TaxRateData> postalRateList;
        int iCount = 0;
        int k = 0;
        int p = 0;
        int q = 0;
        int r = 0;

        dg_viewall.AutoGenerateColumns = false;
        dg_viewall.Columns.Clear();

        _Criteria.PagingInfo.RecordsPerPage = 10;
        taxCriteria.PagingInfo.RecordsPerPage = 10;
        taxCriteria.Filters.Capacity = 1000;

        ///''

        postalCriteria.AddFilter(TaxRateProperty.TaxTypeId, CriteriaFilterOperator.EqualTo, TaxRateType.PostalSalesTax);

        TaxClassList = _TaxClassApi.GetList(TaxClasscriteria);

        int iCount1 = System.Convert.ToInt32(taxApi.GetList(postalCriteria).Count() / TaxClassList.Count);
        int totalPages = postalCriteria.PagingInfo.TotalPages;

        postalCriteria.PagingInfo.CurrentPage = _CurrentPageNumber;

        postalRateList = taxApi.GetList(postalCriteria);

        iCount = System.Convert.ToInt32(postalRateList.Count / TaxClassList.Count);

        string[] Postal = new string[postalRateList.Count - 1 + 1];
        long[] Region = new long[postalRateList.Count - 1 + 1];

        foreach (PostalCodeTaxRateData PostalRate in postalRateList)
        {
            Postal[k] = PostalRate.PostalCode;
            Region[k] = PostalRate.TypeItemId;
            k++;
        }

        string[] zipcode = new string[iCount + 1];
        long[] regionId = new long[iCount + 1];

        if (Region.Length > 0)
        {
            regionId[p] = Region[r];
        }
        if (Postal.Length > 0)
        {
            zipcode[q] = Postal[p];
        }
        q++;
        r++;

        for (p = 1; p <= postalRateList.Count - 1; p++)
        {
            if (Postal[p] != Postal[p - 1])
            {
                zipcode[q] = Postal[p];
                q++;
            }
        }

        for (p = 1; p <= postalRateList.Count - 1; p++)
        {
            if (Region[p] != Region[p - 1])
            {
                regionId[r] = Region[p];
                r++;
            }
        }
        ///'

        //_TotalPagesNumber = System.Convert.ToInt32(System.Math.Ceiling(Convert.ToDouble(iCount1 / 10)));

        if (totalPages <= 1)
        {
            TotalPages.Visible = false;
            CurrentPage.Visible = false;
            lnkBtnPreviousPage.Visible = false;
            NextPage.Visible = false;
            LastPage.Visible = false;
            FirstPage.Visible = false;
            PageLabel.Visible = false;
            OfLabel.Visible = false;
        }
        else
        {
            lnkBtnPreviousPage.Enabled = true;
            FirstPage.Enabled = true;
            LastPage.Enabled = true;
            NextPage.Enabled = true;
            TotalPages.Visible = true;
            CurrentPage.Visible = true;
            lnkBtnPreviousPage.Visible = true;
            NextPage.Visible = true;
            LastPage.Visible = true;
            FirstPage.Visible = true;
            PageLabel.Visible = true;
            OfLabel.Visible = true;
            //TotalPages.Text = (System.Math.Ceiling(Convert.ToDouble(_TotalPagesNumber))).ToString();

            TotalPages.Text = totalPages.ToString();
            TotalPages.ToolTip = TotalPages.Text;

            CurrentPage.Text = _CurrentPageNumber.ToString();
            CurrentPage.ToolTip = CurrentPage.Text;

            if (_CurrentPageNumber == 1)
            {
                lnkBtnPreviousPage.Enabled = false;
                FirstPage.Enabled = false;
            }
            else if (_CurrentPageNumber == _TotalPagesNumber)
            {
                NextPage.Enabled = false;
                LastPage.Enabled = false;
            }
        }

        System.Web.UI.WebControls.BoundColumn colBound = new System.Web.UI.WebControls.BoundColumn();
        colBound.DataField = "Id";
        colBound.HeaderText = m_refMsg.GetMessage("generic id");
        colBound.ItemStyle.Wrap = false;
        colBound.ItemStyle.VerticalAlign = VerticalAlign.Top;
        colBound.ItemStyle.HorizontalAlign = HorizontalAlign.Left;
        dg_viewall.Columns.Add(colBound);

        colBound = new System.Web.UI.WebControls.BoundColumn();
        colBound.DataField = "Postal Code";
        colBound.HeaderText = m_refMsg.GetMessage("lbl address postal"); // + "(" + m_refMsg.GetMessage("lbl view tax rate for region") + ")";
        colBound.ItemStyle.Wrap = false;
        colBound.ItemStyle.VerticalAlign = VerticalAlign.Top;
        colBound.ItemStyle.HorizontalAlign = HorizontalAlign.Left;
        dg_viewall.Columns.Add(colBound);

        dg_viewall.BorderColor = System.Drawing.Color.White;

        DataTable dt = new DataTable();
        DataRow dr;

        dt.Columns.Add(new DataColumn("Id", typeof(string)));
        dt.Columns.Add(new DataColumn("Postal Code", typeof(string)));

        if (!(postalRateList == null))
        {

            for (i = 0; i <= (zipcode.Length - 1); i++)
            {
                if (!string.IsNullOrEmpty(zipcode[i]))
                {
                    dr = dt.NewRow();
                    dr[0] = "<a href=\"postaltaxtables.aspx?action=View&postalid=" + zipcode[i].ToString() + "&id=" + regionId[i] + "\">" + regionId[i] + "</a>";
                    dr[1] = "<a onmouseover=\"expandcontent(\'sc" + i + "\')\" onmouseout=\"expandcontent(\'sc" + i + "\')\" href=\"postaltaxtables.aspx?action=View&postalid=" + zipcode[i].ToString() + "&id=" + regionId[i] + "\">" + zipcode[i] + "</a>";
                    dr[1] += "<div class=\"switchcontent\" style=\"position:absolute;\" id=\"sc" + i + "\">";
                    dr[1] += "<table>";
                    foreach (TaxClassData taxClass in TaxClassList)
                    {
                        dr[1] += "<tr><td width=\"50%\"><label id=\"" + taxClass.Name + "\">" + taxClass.Name + "</label></td>";
                        dr[1] += "<td width=\"20px\"><label id=\"value\">" + GetRate(taxClass.Id, regionId[i]) * 100 + "</label>" + "<label id=\"lblPercentage\">" + "&nbsp;%" + "</label></td></tr>";
                    }
                    dr[1] += "</table></div>";
                    dt.Rows.Add(dr);
                }
            }
        }
        DataView dv = new DataView(dt);

        dg_viewall.DataSource = dv;
        dg_viewall.DataBind();
    }