Пример #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Check UI element
        CheckUIElementAccessHierarchical(ModuleName.ECOMMERCE, IsMultiStoreConfiguration ? "Tools.Ecommerce.CountriesTaxClasses" : "Configuration.TaxClasses.Countries");

        taxClassId = QueryHelper.GetInteger("objectid", 0);

        TaxClassInfo taxClassObj = TaxClassInfo.Provider.Get(taxClassId);

        EditedObject = taxClassObj;
        // Check if configured tax class belongs to configured site
        if (taxClassObj != null)
        {
            CheckEditedObjectSiteID(taxClassObj.TaxClassSiteID);
        }

        GridViewCountries.Columns[0].HeaderText = GetString("TaxClass_Country.Country");
        GridViewCountries.Columns[1].HeaderText = GetString("TaxClass_Country.Value");

        var ds = GetCountriesAndTaxRates();

        // Bounded CountryID field
        GridViewCountries.Columns[2].Visible = true;
        GridViewCountries.DataSource         = ds.Tables[0];
        GridViewCountries.DataBind();

        // After id is copied, the CountryID column it's not needed anymore
        GridViewCountries.Columns[2].Visible = false;

        // Set header actions
        CurrentMaster.HeaderActions.AddAction(new SaveAction());
        CurrentMaster.HeaderActions.ActionPerformed += HeaderActions_ActionPerformed;
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        mTaxClassId = QueryHelper.GetInteger("objectid", 0);
        if (mTaxClassId > 0)
        {
            mTaxClassInfoObj = TaxClassInfoProvider.GetTaxClassInfo(mTaxClassId);
            EditedObject = mTaxClassInfoObj;

            if (mTaxClassInfoObj != null)
            {
                int editedSiteId = mTaxClassInfoObj.TaxClassSiteID;
                // Check object's site id
                CheckEditedObjectSiteID(editedSiteId);

                // Offer global products when allowed
                bool offerGlobalProducts;
                if (editedSiteId != 0)
                {
                    offerGlobalProducts = ECommerceSettings.AllowGlobalProducts(editedSiteId);
                }
                // Configuring global products
                else
                {
                    offerGlobalProducts = ECommerceSettings.AllowGlobalProducts(CurrentSiteName);
                }

                PreloadUniSelector(offerGlobalProducts);
                uniSelector.WhereCondition = GetSelectorWhereCondition(offerGlobalProducts);
            }
        }
    }
Пример #3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        mTaxClassId = QueryHelper.GetInteger("objectid", 0);
        if (mTaxClassId > 0)
        {
            mTaxClassInfoObj = TaxClassInfoProvider.GetTaxClassInfo(mTaxClassId);
            EditedObject     = mTaxClassInfoObj;

            if (mTaxClassInfoObj != null)
            {
                int editedSiteId = mTaxClassInfoObj.TaxClassSiteID;
                // Check object's site id
                CheckEditedObjectSiteID(editedSiteId);

                // Offer global products when allowed
                bool offerGlobalProducts;
                if (editedSiteId != 0)
                {
                    offerGlobalProducts = ECommerceSettings.AllowGlobalProducts(editedSiteId);
                }
                // Configuring global products
                else
                {
                    offerGlobalProducts = ECommerceSettings.AllowGlobalProducts(CurrentSiteName);
                }

                PreloadUniSelector(offerGlobalProducts);
                uniSelector.WhereCondition = GetSelectorWhereCondition(offerGlobalProducts);
            }
        }
    }
Пример #4
0
    protected void AddTaxClassToProduct()
    {
        // Prepare the parameters
        //  string where = "SKUName LIKE '%%'";
        SKUInfo product = null;

        // Get the product
        DataSet products = SKUInfoProvider.GetSKUs(null, null);

        if (!DataHelper.DataSourceIsEmpty(products))
        {
            int nb = products.Tables[0].Rows.Count;
            for (int i = 0; i < nb; i++)
            {
                //product = new SKUInfo(products.Tables[0].Rows[0]);
                DataRow row = products.Tables[0].Rows[i];
                product = new SKUInfo(row);
                // Get the tax class
                TaxClassInfo taxClass  = TaxClassInfoProvider.GetTaxClassInfo("TVA_EU21", SiteContext.CurrentSiteName);
                TaxClassInfo taxClass1 = TaxClassInfoProvider.GetTaxClassInfo("VAT", SiteContext.CurrentSiteName);

                if ((product != null) && (taxClass != null))
                {
                    // Add tax class to product
                    SKUTaxClassInfoProvider.AddTaxClassToSKU(taxClass.TaxClassID, product.SKUID);

                    SKUTaxClassInfoProvider.AddTaxClassToSKU(taxClass1.TaxClassID, product.SKUID);
                }
            }
        }
    }
Пример #5
0
    protected void Page_Load(object sender, EventArgs e)
    {
        taxClassId = QueryHelper.GetInteger("taxclassid", 0);
        bool hideBreadcrumbs = QueryHelper.GetBoolean("hidebreadcrumbs", false);

        string       taxClassName = "";
        TaxClassInfo tc           = TaxClassInfoProvider.GetTaxClassInfo(taxClassId);

        if (tc != null)
        {
            CheckEditedObjectSiteID(tc.TaxClassSiteID);
            taxClassName = ResHelper.LocalizeString(tc.TaxClassDisplayName);
        }

        // initializes page title
        string[,] pageTitleTabs = new string[2, 3];
        pageTitleTabs[0, 0]     = GetString("TaxClass_Edit.ItemListLink");
        pageTitleTabs[0, 1]     = "~/CMSModules/Ecommerce/Pages/Tools/Configuration/TaxClasses/TaxClass_List.aspx?siteId=" + SiteID;
        pageTitleTabs[0, 2]     = "_parent";
        pageTitleTabs[1, 0]     = taxClassName;
        pageTitleTabs[1, 1]     = "";
        pageTitleTabs[1, 2]     = "";

        CMSMasterPage master = (CMSMasterPage)CurrentMaster;

        if (!hideBreadcrumbs)
        {
            master.Title.Breadcrumbs = pageTitleTabs;
        }

        master.Tabs.OnTabCreated += Tabs_OnTabCreated;
    }
Пример #6
0
 internal IEnumerable <TaxClassInfo> InitTaxClasses()
 {
     return(new[]
     {
         TaxClassDefault = new TaxClassInfo
         {
             TaxClassDisplayName = "DefaultTaxClass",
             TaxClassName = "DefaultTaxClass",
             TaxClassSiteID = SiteInfo.SiteID
         }
     });
 }
Пример #7
0
    protected void Page_Load(object sender, EventArgs e)
    {
        ScriptHelper.RegisterJQuery(this);

        // Check UI element
        CheckUIElementAccessHierarchical(ModuleName.ECOMMERCE, IsMultiStoreConfiguration ? "Tools.Ecommerce.CountriesTaxClasses" : "Configuration.TaxClasses.Countries");

        taxClassId = QueryHelper.GetInteger("objectid", 0);

        TaxClassInfo taxClassObj = TaxClassInfoProvider.GetTaxClassInfo(taxClassId);

        EditedObject = taxClassObj;
        // Check if configured tax class belongs to configured site
        if (taxClassObj != null)
        {
            CheckEditedObjectSiteID(taxClassObj.TaxClassSiteID);

            currencyCode = CurrencyInfoProvider.GetMainCurrencyCode(taxClassObj.TaxClassSiteID);

            // Check presence of main currency
            CheckMainCurrency(taxClassObj.TaxClassSiteID);
        }

        GridViewCountries.Columns[0].HeaderText = GetString("TaxClass_Country.Country");
        GridViewCountries.Columns[1].HeaderText = GetString("TaxClass_Country.Value");
        GridViewCountries.Columns[2].HeaderText = GetString("TaxClass_Country.IsFlat");

        DataSet ds = TaxClassCountryInfoProvider.GetCountriesAndTaxValues(taxClassId);

        GridViewCountries.Columns[3].Visible = true;
        GridViewCountries.DataSource         = ds.Tables[0];
        GridViewCountries.DataBind();
        // After id is copied, the 4th column it's not needed anymore
        GridViewCountries.Columns[3].Visible = false;

        // Init scripts
        string currencySwitchScript = string.Format(@"
function switchCurrency(isFlatValue, labelId){{
  if(isFlatValue)
  {{
    $cmsj('#' + labelId).html('{0}');
  }}else{{
    $cmsj('#' + labelId).html('%');
  }}
}}", ScriptHelper.GetString(HTMLHelper.HTMLEncode(currencyCode), false));

        ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "CurrencySwitch", currencySwitchScript, true);
        ScriptHelper.RegisterStartupScript(this, typeof(string), "InitializeGrid", "$cmsj('input[id*=\"chkIsFlatValue\"]').change();", true);

        // Set header actions
        CurrentMaster.HeaderActions.AddAction(new SaveAction(this));
        CurrentMaster.HeaderActions.ActionPerformed += HeaderActions_ActionPerformed;
    }
Пример #8
0
    /// <summary>
    /// Sets data to database.
    /// </summary>
    protected void btnOK_Click(object sender, EventArgs e)
    {
        CheckConfigurationModification();

        string errorMessage = new Validator()
                              .NotEmpty(txtTaxClassDisplayName.Text.Trim(), GetString("general.requiresdisplayname"))
                              .NotEmpty(txtTaxClassName.Text.Trim(), GetString("general.requirescodename")).Result;

        if (!ValidationHelper.IsCodeName(txtTaxClassName.Text.Trim()))
        {
            errorMessage = GetString("General.ErrorCodeNameInIdentificatorFormat");
        }

        if (errorMessage == "")
        {
            // TaxClassName must be unique
            TaxClassInfo taxClassObj = TaxClassInfoProvider.GetTaxClassInfo(txtTaxClassName.Text.Trim(), SiteInfoProvider.GetSiteName(ConfiguredSiteID));

            // If taxClassName value is unique
            if ((taxClassObj == null) || (taxClassObj.TaxClassID == taxclassid))
            {
                // If taxClassName value is unique -> determine whether it is update or insert
                if (taxClassObj == null)
                {
                    // Get TaxClassInfo object by primary key
                    taxClassObj = TaxClassInfoProvider.GetTaxClassInfo(taxclassid);
                }
                if (taxClassObj != null)
                {
                    taxClassObj.TaxClassDisplayName      = txtTaxClassDisplayName.Text.Trim();
                    taxClassObj.TaxClassName             = txtTaxClassName.Text.Trim();
                    taxClassObj.TaxClassZeroIfIDSupplied = chkTaxZero.Checked;

                    TaxClassInfoProvider.SetTaxClassInfo(taxClassObj);

                    lblInfo.Visible = true;
                    lblInfo.Text    = GetString("General.ChangesSaved");
                }
            }
            else
            {
                lblError.Visible = true;
                lblError.Text    = GetString("TaxClass_Edit.TaxClassNameExists");
            }
        }
        else
        {
            lblError.Visible = true;
            lblError.Text    = errorMessage;
        }
    }
Пример #9
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Check permissions for CMS Desk -> Ecommerce
        if (!CMSContext.CurrentUser.IsAuthorizedPerUIElement("CMS.Ecommerce", "Configuration.TaxClasses.General"))
        {
            RedirectToCMSDeskUIElementAccessDenied("CMS.Ecommerce", "Configuration.TaxClasses.General");
        }

        rfvTaxClassDisplayName.ErrorMessage = GetString("general.requiresdisplayname");
        rfvTaxClassName.ErrorMessage        = GetString("general.requirescodename");

        // Control initializations
        lblTaxClassDisplayName.Text = GetString("TaxClass_Edit.TaxClassDisplayNameLabel");
        lblTaxClassName.Text        = GetString("TaxClass_Edit.TaxClassNameLabel");
        lblTaxZero.Text             = GetString("TaxClass_Edit.lblTaxZero");

        btnOk.Text = GetString("General.OK");

        // Get taxClass id from querystring
        taxclassid = QueryHelper.GetInteger("taxclassid", 0);
        if (taxclassid > 0)
        {
            TaxClassInfo taxClassObj = TaxClassInfoProvider.GetTaxClassInfo(taxclassid);
            EditedObject = taxClassObj;

            if (taxClassObj != null)
            {
                CheckEditedObjectSiteID(taxClassObj.TaxClassSiteID);
                // Fill editing form
                if (!RequestHelper.IsPostBack())
                {
                    LoadData(taxClassObj);

                    // Show that the taxClass was created or updated successfully
                    if (QueryHelper.GetString("saved", "") == "1")
                    {
                        lblInfo.Visible = true;
                        lblInfo.Text    = GetString("General.ChangesSaved");
                    }
                }
            }
            else
            {
                btnOk.Enabled    = false;
                lblError.Visible = true;
                lblError.Text    = GetString("TaxClass_Edit.TaxClassDoesNotExists");
                return;
            }
        }
    }
Пример #10
0
    /// <summary>
    /// Sets data to database.
    /// </summary>
    protected void btnOK_Click(object sender, EventArgs e)
    {
        CheckConfigurationModification();

        string errorMessage = new Validator()
                              .NotEmpty(txtTaxClassDisplayName.Text.Trim(), GetString("general.requiresdisplayname"))
                              .NotEmpty(txtTaxClassName.Text.Trim(), GetString("general.requirescodename")).Result;

        if (!ValidationHelper.IsCodeName(txtTaxClassName.Text.Trim()))
        {
            errorMessage = GetString("General.ErrorCodeNameInIdentificatorFormat");
        }

        if (errorMessage == "")
        {
            TaxClassInfo taxClassObj = TaxClassInfoProvider.GetTaxClassInfo(txtTaxClassName.Text.Trim(), SiteInfoProvider.GetSiteName(ConfiguredSiteID));

            if (taxClassObj == null)
            {
                // If taxClassName value is unique for configured site
                taxClassObj = new TaxClassInfo();

                taxClassObj.TaxClassDisplayName      = txtTaxClassDisplayName.Text.Trim();
                taxClassObj.TaxClassName             = txtTaxClassName.Text.Trim();
                taxClassObj.TaxClassZeroIfIDSupplied = chkTaxZero.Checked;
                taxClassObj.TaxClassSiteID           = ConfiguredSiteID;

                TaxClassInfoProvider.SetTaxClassInfo(taxClassObj);

                URLHelper.Redirect("TaxClass_Frameset.aspx?taxclassid=" + Convert.ToString(taxClassObj.TaxClassID) + "&saved=1&siteId=" + SiteID);
            }
            else
            {
                lblError.Visible = true;
                lblError.Text    = GetString("TaxClass_Edit.TaxClassNameExists");
            }
        }
        else
        {
            lblError.Visible = true;
            lblError.Text    = errorMessage;
        }
    }
Пример #11
0
    /// <summary>
    /// Sets data to database.
    /// </summary>
    protected void btnOK_Click(object sender, EventArgs e)
    {
        CheckConfigurationModification();

        string errorMessage = new Validator()
            .NotEmpty(txtTaxClassDisplayName.Text.Trim(), GetString("general.requiresdisplayname"))
            .NotEmpty(txtTaxClassName.Text.Trim(), GetString("general.requirescodename")).Result;

        if (!ValidationHelper.IsCodeName(txtTaxClassName.Text.Trim()))
        {
            errorMessage = GetString("General.ErrorCodeNameInIdentificatorFormat");
        }

        if (errorMessage == "")
        {
            TaxClassInfo taxClassObj = TaxClassInfoProvider.GetTaxClassInfo(txtTaxClassName.Text.Trim(), SiteInfoProvider.GetSiteName(ConfiguredSiteID));

            if (taxClassObj == null)
            {
                // If taxClassName value is unique for configured site
                taxClassObj = new TaxClassInfo();

                taxClassObj.TaxClassDisplayName = txtTaxClassDisplayName.Text.Trim();
                taxClassObj.TaxClassName = txtTaxClassName.Text.Trim();
                taxClassObj.TaxClassZeroIfIDSupplied = chkTaxZero.Checked;
                taxClassObj.TaxClassSiteID = ConfiguredSiteID;

                TaxClassInfoProvider.SetTaxClassInfo(taxClassObj);

                URLHelper.Redirect("TaxClass_Frameset.aspx?taxclassid=" + Convert.ToString(taxClassObj.TaxClassID) + "&saved=1&siteId="+SiteID);
            }
            else
            {
                lblError.Visible = true;
                lblError.Text = GetString("TaxClass_Edit.TaxClassNameExists");
            }
        }
        else
        {
            lblError.Visible = true;
            lblError.Text = errorMessage;
        }
    }
Пример #12
0
    protected void Page_Load(object sender, EventArgs e)
    {
        rfvTaxClassDisplayName.ErrorMessage = GetString("general.requiresdisplayname");
        rfvTaxClassName.ErrorMessage        = GetString("general.requirescodename");

        // Get taxClass id from querystring
        taxclassid = QueryHelper.GetInteger("taxclassid", 0);
        if (taxclassid > 0)
        {
            TaxClassInfo taxClassObj = TaxClassInfoProvider.GetTaxClassInfo(taxclassid);
            EditedObject = taxClassObj;

            if (taxClassObj != null)
            {
                CheckEditedObjectSiteID(taxClassObj.TaxClassSiteID);
                // Fill editing form
                if (!RequestHelper.IsPostBack())
                {
                    LoadData(taxClassObj);

                    // Show that the taxClass was created or updated successfully
                    if (QueryHelper.GetString("saved", "") == "1")
                    {
                        // Show message
                        ShowChangesSaved();
                    }
                }
            }
            else
            {
                btnOk.Enabled = false;

                // Show error message
                ShowError(GetString("TaxClass_Edit.TaxClassDoesNotExists"));

                return;
            }
        }
    }
Пример #13
0
    protected void Page_Load(object sender, EventArgs e)
    {
        taxClassId = QueryHelper.GetInteger("taxclassid", 0);
        bool hideBreadcrumbs = QueryHelper.GetBoolean("hidebreadcrumbs", false);

        string       taxClassName = "";
        TaxClassInfo tc           = TaxClassInfoProvider.GetTaxClassInfo(taxClassId);

        if (tc != null)
        {
            CheckEditedObjectSiteID(tc.TaxClassSiteID);
            taxClassName = ResHelper.LocalizeString(tc.TaxClassDisplayName);
        }

        // initializes page title
        string[,] pageTitleTabs = new string[2, 3];
        pageTitleTabs[0, 0]     = GetString("TaxClass_Edit.ItemListLink");
        pageTitleTabs[0, 1]     = "~/CMSModules/Ecommerce/Pages/Tools/Configuration/TaxClasses/TaxClass_List.aspx?siteId=" + SiteID;
        pageTitleTabs[0, 2]     = "configEdit";
        pageTitleTabs[1, 0]     = taxClassName;
        pageTitleTabs[1, 1]     = "";
        pageTitleTabs[1, 2]     = "";

        CMSMasterPage master = (CMSMasterPage)this.CurrentMaster;

        if (!hideBreadcrumbs)
        {
            master.Title.Breadcrumbs = pageTitleTabs;
        }
        master.Title.TitleText     = GetString("TaxClass_Edit.HeaderCaption-Properties");
        master.Title.TitleImage    = GetImageUrl("Objects/Ecommerce_TaxClass/object.png");
        master.Title.HelpTopicName = "new_classgeneral_tab";
        master.Title.HelpName      = "helpTopic";

        master.Tabs.ModuleName    = "CMS.Ecommerce";
        master.Tabs.ElementName   = "Configuration.TaxClasses";
        master.Tabs.UrlTarget     = "taxClassContent";
        master.Tabs.OnTabCreated += new UITabs.TabCreatedEventHandler(Tabs_OnTabCreated);
    }
Пример #14
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Check UI element
        CheckUIElementAccessHierarchical(ModuleName.ECOMMERCE, IsMultiStoreConfiguration ? "Tools.Ecommerce.StatesTaxClasses" : "Configuration.TaxClasses.States");

        // Get tax class Id from URL
        taxClassId = QueryHelper.GetInteger("objectid", 0);

        TaxClassInfo taxClass = TaxClassInfo.Provider.Get(taxClassId);

        EditedObject = taxClass;
        // Check if configured tax class belongs to configured site
        if (taxClass != null)
        {
            // Check site id of tax class
            CheckEditedObjectSiteID(taxClass.TaxClassSiteID);
        }

        if (!RequestHelper.IsPostBack())
        {
            // Fill the drpCountry with countries which have some states or colonies
            drpCountry.DataSource     = CountryInfoProvider.GetCountriesWithStates();
            drpCountry.DataValueField = "CountryID";
            drpCountry.DataTextField  = "CountryDisplayName";
            drpCountry.DataBind();
        }
        // Set grid view properties
        gvStates.Columns[0].HeaderText = GetString("taxclass_state.gvstates.state");
        gvStates.Columns[1].HeaderText = GetString("Code");
        gvStates.Columns[2].HeaderText = GetString("taxclass_state.gvstates.value");
        gvStates.Columns[3].HeaderText = GetString("StateId");

        LoadGridViewData();

        // Set header actions
        CurrentMaster.HeaderActions.AddAction(new SaveAction());
        CurrentMaster.HeaderActions.ActionPerformed += HeaderActions_ActionPerformed;
        CurrentMaster.DisplaySiteSelectorPanel       = true;
    }
Пример #15
0
    protected void RemoveTaxClassFromProduct()
    {
        // Prepare the parameters
        //  string where = "SKUName LIKE N'MyNew%'";
        SKUInfo product = null;

        // Get the tax class
        TaxClassInfo taxClass = TaxClassInfoProvider.GetTaxClassInfo("VAT", SiteContext.CurrentSiteName);
        // TaxClassInfo taxClass1 = TaxClassInfoProvider.GetTaxClassInfo("VAT", CMSContext.CurrentSiteName);

        // Get the product
        DataSet products = SKUInfoProvider.GetSKUs(null, null);

        if (!DataHelper.DataSourceIsEmpty(products))
        {
            // product = new SKUInfo(products.Tables[0].Rows[0]);
            // }
            int nb = products.Tables[0].Rows.Count;
            for (int i = 0; i < nb; i++)
            {
                DataRow row = products.Tables[0].Rows[i];
                product = new SKUInfo(row);
                if ((product != null) && (taxClass != null))
                {
                    // Get the tax class added to product
                    SKUTaxClassInfo skuTaxClass = SKUTaxClassInfoProvider.GetSKUTaxClassInfo(taxClass.TaxClassID, product.SKUID);

                    // Remove tax class from product
                    SKUTaxClassInfoProvider.DeleteSKUTaxClassInfo(skuTaxClass);
                }


                // }
            }
        }
    }
Пример #16
0
    protected void Page_Load(object sender, EventArgs e)
    {
        ScriptHelper.RegisterJQuery(this);

        // Check permissions for CMS Desk -> Ecommerce
        if (!CMSContext.CurrentUser.IsAuthorizedPerUIElement("CMS.Ecommerce", "Configuration.TaxClasses.States"))
        {
            RedirectToCMSDeskUIElementAccessDenied("CMS.Ecommerce", "Configuration.TaxClasses.States");
        }

        // Get tax class Id from URL
        mTaxClassId = QueryHelper.GetInteger("taxclassid", 0);

        mTaxClassObj = TaxClassInfoProvider.GetTaxClassInfo(mTaxClassId);
        EditedObject = mTaxClassObj;
        // Check if configured tax class belongs to configured site
        if (mTaxClassObj != null)
        {
            // Check site id of tax class
            CheckEditedObjectSiteID(mTaxClassObj.TaxClassSiteID);

            currencyCode = CurrencyInfoProvider.GetMainCurrencyCode(mTaxClassObj.TaxClassSiteID);

            // Check presence of main currency
            string currencyErr = CheckMainCurrency(mTaxClassObj.TaxClassSiteID);
            if (!string.IsNullOrEmpty(currencyErr))
            {
                // Show message
                lblError.Text = currencyErr;
                lblError.Visible = true;
            }
        }

        if (!RequestHelper.IsPostBack())
        {
            // Fill the drpCountry with countries which have some states or colonies
            drpCountry.DataSource = CountryInfoProvider.GetCountriesWithStates();
            drpCountry.DataValueField = "CountryID";
            drpCountry.DataTextField = "CountryDisplayName";
            drpCountry.DataBind();
        }
        // Set grid view properties
        gvStates.Columns[0].HeaderText = GetString("taxclass_state.gvstates.state");
        gvStates.Columns[1].HeaderText = GetString("Code");
        gvStates.Columns[2].HeaderText = GetString("taxclass_state.gvstates.value");
        gvStates.Columns[3].HeaderText = GetString("taxclass_state.gvstates.isflat");
        gvStates.Columns[4].HeaderText = GetString("StateId");

        gvStates.GridLines = GridLines.Horizontal;

        LoadGridViewData();

        // Init scripts
        string currencySwitchScript = string.Format(@"
        function switchCurrency(isFlatValue, labelId){{
          if(isFlatValue)
          {{
        jQuery('#'+labelId).html('({0})');
          }}else{{
        jQuery('#'+labelId).html('(%)');
          }}
        }}", ScriptHelper.GetString(currencyCode, false));
        ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "CurrencySwitch", currencySwitchScript, true);
        ScriptHelper.RegisterStartupScript(this, typeof(string), "InitializeGrid", "jQuery('input[id*=\"chkIsFlatValue\"]').change();", true);

        mSave = GetString("general.save");

        // Set header actions
        string[,] actions = new string[1, 10];

        actions[0, 0] = HeaderActions.TYPE_SAVEBUTTON;
        actions[0, 1] = this.GetString("Header.Settings.SaveChanged");
        actions[0, 2] = String.Empty;
        actions[0, 3] = String.Empty;
        actions[0, 4] = String.Empty;
        actions[0, 5] = this.GetImageUrl("CMSModules/CMS_Content/EditMenu/save.png");
        actions[0, 6] = "save";
        actions[0, 8] = true.ToString();

        this.CurrentMaster.HeaderActions.Actions = actions;
        this.CurrentMaster.HeaderActions.ActionPerformed += this.HeaderActions_ActionPerformed;
        this.CurrentMaster.DisplaySiteSelectorPanel = true;
    }
Пример #17
0
    protected void Page_Load(object sender, EventArgs e)
    {
        ScriptHelper.RegisterJQuery(this);

        // Check permissions for CMS Desk -> Ecommerce
        if (!CMSContext.CurrentUser.IsAuthorizedPerUIElement("CMS.Ecommerce", "Configuration.TaxClasses.States"))
        {
            RedirectToCMSDeskUIElementAccessDenied("CMS.Ecommerce", "Configuration.TaxClasses.States");
        }

        // Get tax class Id from URL
        mTaxClassId = QueryHelper.GetInteger("taxclassid", 0);

        mTaxClassObj = TaxClassInfoProvider.GetTaxClassInfo(mTaxClassId);
        EditedObject = mTaxClassObj;
        // Check if configured tax class belongs to configured site
        if (mTaxClassObj != null)
        {
            // Check site id of tax class
            CheckEditedObjectSiteID(mTaxClassObj.TaxClassSiteID);

            currencyCode = CurrencyInfoProvider.GetMainCurrencyCode(mTaxClassObj.TaxClassSiteID);

            // Check presence of main currency
            string currencyErr = CheckMainCurrency(mTaxClassObj.TaxClassSiteID);
            if (!string.IsNullOrEmpty(currencyErr))
            {
                // Show message
                lblError.Text    = currencyErr;
                lblError.Visible = true;
            }
        }

        if (!RequestHelper.IsPostBack())
        {
            // Fill the drpCountry with countries which have some states or colonies
            drpCountry.DataSource     = CountryInfoProvider.GetCountriesWithStates();
            drpCountry.DataValueField = "CountryID";
            drpCountry.DataTextField  = "CountryDisplayName";
            drpCountry.DataBind();
        }
        // Set grid view properties
        gvStates.Columns[0].HeaderText = GetString("taxclass_state.gvstates.state");
        gvStates.Columns[1].HeaderText = GetString("Code");
        gvStates.Columns[2].HeaderText = GetString("taxclass_state.gvstates.value");
        gvStates.Columns[3].HeaderText = GetString("taxclass_state.gvstates.isflat");
        gvStates.Columns[4].HeaderText = GetString("StateId");

        gvStates.GridLines = GridLines.Horizontal;

        LoadGridViewData();

        // Init scripts
        string currencySwitchScript = string.Format(@"
function switchCurrency(isFlatValue, labelId){{
  if(isFlatValue)
  {{
    jQuery('#'+labelId).html('({0})');
  }}else{{
    jQuery('#'+labelId).html('(%)');
  }}
}}", ScriptHelper.GetString(currencyCode, false));

        ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "CurrencySwitch", currencySwitchScript, true);
        ScriptHelper.RegisterStartupScript(this, typeof(string), "InitializeGrid", "jQuery('input[id*=\"chkIsFlatValue\"]').change();", true);

        mSave = GetString("general.save");

        // Set header actions
        string[,] actions = new string[1, 10];

        actions[0, 0] = HeaderActions.TYPE_SAVEBUTTON;
        actions[0, 1] = this.GetString("Header.Settings.SaveChanged");
        actions[0, 2] = String.Empty;
        actions[0, 3] = String.Empty;
        actions[0, 4] = String.Empty;
        actions[0, 5] = this.GetImageUrl("CMSModules/CMS_Content/EditMenu/save.png");
        actions[0, 6] = "save";
        actions[0, 8] = true.ToString();

        this.CurrentMaster.HeaderActions.Actions          = actions;
        this.CurrentMaster.HeaderActions.ActionPerformed += this.HeaderActions_ActionPerformed;
        this.CurrentMaster.DisplaySiteSelectorPanel       = true;
    }
    /// <summary>
    /// Gets and bulk updates tax classes. Called when the "Get and bulk update classes" button is pressed.
    /// Expects the CreateTaxClass method to be run first.
    /// </summary>
    private bool GetAndBulkUpdateTaxClasses()
    {
        // Prepare the parameters
        string where = "TaxClassName LIKE N'MyNewClass%'";

        // Get the data
        DataSet classes = TaxClassInfoProvider.GetTaxClasses(where, null);
        if (!DataHelper.DataSourceIsEmpty(classes))
        {
            // Loop through the individual items
            foreach (DataRow classDr in classes.Tables[0].Rows)
            {
                // Create object from DataRow
                TaxClassInfo modifyClass = new TaxClassInfo(classDr);

                // Update the properties
                modifyClass.TaxClassDisplayName = modifyClass.TaxClassDisplayName.ToUpper();

                // Update the tax class
                TaxClassInfoProvider.SetTaxClassInfo(modifyClass);
            }

            return true;
        }

        return false;
    }
    /// <summary>
    /// Creates tax class. Called when the "Create class" button is pressed.
    /// </summary>
    private bool CreateTaxClass()
    {
        // Create new tax class
        TaxClassInfo newClass = new TaxClassInfo();

        // Set the properties
        newClass.TaxClassDisplayName = "My new class";
        newClass.TaxClassName = "MyNewClass";
        newClass.TaxClassSiteID = CMSContext.CurrentSiteID;

        // Create the tax class
        TaxClassInfoProvider.SetTaxClassInfo(newClass);

        return true;
    }
 /// <summary>
 /// Load data from edited taxClass object to form.
 /// </summary>
 /// <param name="taxClassObj">TaxClass object</param>
 protected void LoadData(TaxClassInfo taxClassObj)
 {
     txtTaxClassDisplayName.Text = taxClassObj.TaxClassDisplayName;
     txtTaxClassName.Text = taxClassObj.TaxClassName;
     chkTaxZero.Checked = taxClassObj.TaxClassZeroIfIDSupplied;
 }
Пример #21
0
 /// <summary>
 /// Load data from edited taxClass object to form.
 /// </summary>
 /// <param name="taxClassObj">TaxClass object</param>
 protected void LoadData(TaxClassInfo taxClassObj)
 {
     txtTaxClassDisplayName.Text = taxClassObj.TaxClassDisplayName;
     txtTaxClassName.Text        = taxClassObj.TaxClassName;
     chkTaxZero.Checked          = taxClassObj.TaxClassZeroIfIDSupplied;
 }
Пример #22
0
    private object gridElem_OnExternalDataBound(object sender, string sourceName, object parameter)
    {
        DataRowView rowView = parameter as DataRowView;

        if (rowView != null)
        {
            SKUInfo sku = new SKUInfo(rowView.Row);
            switch (sourceName.ToLowerCSafe())
            {
            case "skuname":
                string fullName = sku.SKUName;

                // For variant, add name from parent SKU
                if (sku.SKUParentSKUID != 0)
                {
                    SKUInfo parentSku = SKUInfo.Provider.Get(sku.SKUParentSKUID);
                    fullName = string.Format("{0}: {1}", parentSku.SKUName, sku.SKUName);
                }
                return(HTMLHelper.HTMLEncode(fullName));

            case "optioncategory":
                OptionCategoryInfo optionCategory = OptionCategoryInfo.Provider.Get(sku.SKUOptionCategoryID);

                // Return option category display name for product option or '-' for product
                if (optionCategory != null)
                {
                    return(HTMLHelper.HTMLEncode(optionCategory.CategoryDisplayName ?? ""));
                }
                return("-");

            case "skunumber":
                return(ResHelper.LocalizeString(sku.SKUNumber, null, true));

            case "skuprice":
                // Format price
                return(CurrencyInfoProvider.GetFormattedPrice(sku.SKUPrice, sku.SKUSiteID));

            case "skudepartmentid":
                // Transform to display name and localize
                DepartmentInfo department = DepartmentInfo.Provider.Get(sku.SKUDepartmentID);
                return((department != null) ? HTMLHelper.HTMLEncode(ResHelper.LocalizeString(department.DepartmentDisplayName)) : "");

            case "skumanufacturerid":
                // Transform to display name and localize
                ManufacturerInfo manufacturer = ManufacturerInfo.Provider.Get(sku.SKUManufacturerID);
                return((manufacturer != null) ? HTMLHelper.HTMLEncode(ResHelper.LocalizeString(manufacturer.ManufacturerDisplayName)) : "");

            case "skubrandid":
                // Transform to display name and localize
                BrandInfo brand = BrandInfo.Provider.Get(sku.SKUBrandID);
                return((brand != null) ? HTMLHelper.HTMLEncode(ResHelper.LocalizeString(brand.BrandDisplayName)) : "");

            case "skucollectionid":
                // Transform to display name and localize
                CollectionInfo collection = CollectionInfo.Provider.Get(sku.SKUCollectionID);
                return((collection != null) ? HTMLHelper.HTMLEncode(ResHelper.LocalizeString(collection.CollectionDisplayName)) : "");

            case "skutaxclassid":
                // Transform to display name and localize
                TaxClassInfo taxClass = TaxClassInfo.Provider.Get(sku.SKUTaxClassID);
                return((taxClass != null) ? HTMLHelper.HTMLEncode(ResHelper.LocalizeString(taxClass.TaxClassDisplayName)) : "");

            case "skusupplierid":
                // Transform to display name and localize
                SupplierInfo supplier = SupplierInfoProvider.ProviderObject.Get(sku.SKUSupplierID);
                return((supplier != null) ? HTMLHelper.HTMLEncode(ResHelper.LocalizeString(supplier.SupplierDisplayName)) : "");

            case "skupublicstatusid":
                // Transform to display name and localize
                PublicStatusInfo publicStatus = PublicStatusInfo.Provider.Get(sku.SKUPublicStatusID);
                return((publicStatus != null) ? HTMLHelper.HTMLEncode(ResHelper.LocalizeString(publicStatus.PublicStatusDisplayName)) : "");

            case "skuinternalstatusid":
                // Transform to display name and localize
                InternalStatusInfo internalStatus = InternalStatusInfo.Provider.Get(sku.SKUInternalStatusID);
                return((internalStatus != null) ? HTMLHelper.HTMLEncode(ResHelper.LocalizeString(internalStatus.InternalStatusDisplayName)) : "");

            case "skuavailableitems":
                int?count     = sku.SKUAvailableItems as int?;
                int?reorderAt = sku.SKUReorderAt as int?;

                // Emphasize the number when product needs to be reordered
                if (count.HasValue && ((reorderAt.HasValue && (count <= reorderAt)) || (!reorderAt.HasValue && (count <= 0))))
                {
                    // Format message informing about insufficient stock level
                    return(String.Format("<span class=\"OperationFailed\">{0}</span>", count));
                }
                return(count);

            case "itemstobereordered":
                int difference = sku.SKUReorderAt - sku.SKUAvailableItems;

                // Return difference, or '-'
                return((difference > 0) ? difference.ToString() : "-");

            case "skusiteid":
                return(UniGridFunctions.ColoredSpanYesNo(sku.SKUSiteID == 0));
            }
        }

        return(parameter);
    }
Пример #23
0
    /// <summary>
    /// Returns where condition based on webpart fields.
    /// </summary>
    private WhereCondition GetWhereCondition()
    {
        var where = new WhereCondition().WhereEquals("SKUSiteID", SiteContext.CurrentSiteID);

        // Show products only from current site or global too, based on setting
        if (ECommerceSettings.AllowGlobalProducts(SiteContext.CurrentSiteName))
        {
            where.Where(w => w.WhereEquals("SKUSiteID", SiteContext.CurrentSiteID).Or().WhereNull("SKUSiteID"));
        }

        // Show/hide product variants - it is based on type of inventory tracking for parent product
        string trackByVariants = TrackInventoryTypeEnum.ByVariants.ToStringRepresentation();

        where.Where(v => v.Where(w => w.WhereNull("SKUParentSKUID").And().WhereNotEquals("SKUTrackInventory", trackByVariants))
                    .Or()
                    .Where(GetParentProductWhereCondition(new WhereCondition().WhereEquals("SKUTrackInventory", trackByVariants))));

        // Product type filter
        if (!string.IsNullOrEmpty(ProductType) && (ProductType != FILTER_ALL))
        {
            if (ProductType == PRODUCT_TYPE_PRODUCTS)
            {
                where.WhereNull("SKUOptionCategoryID");
            }
            else if (ProductType == PRODUCT_TYPE_PRODUCT_OPTIONS)
            {
                where.WhereNotNull("SKUOptionCategoryID");
            }
        }

        // Representing filter
        if (!string.IsNullOrEmpty(Representing) && (Representing != FILTER_ALL))
        {
            SKUProductTypeEnum productTypeEnum   = EnumStringRepresentationExtensions.ToEnum <SKUProductTypeEnum>(Representing);
            string             productTypeString = productTypeEnum.ToStringRepresentation();

            where.WhereEquals("SKUProductType", productTypeString);
        }

        // Product number filter
        if (!string.IsNullOrEmpty(ProductNumber))
        {
            where.WhereContains("SKUNumber", ProductNumber);
        }

        // Department filter
        DepartmentInfo di = DepartmentInfo.Provider.Get(Department, SiteInfoProvider.GetSiteID(CurrentSiteName));

        di = di ?? DepartmentInfo.Provider.Get(Department, 0);

        if (di != null)
        {
            where.Where(GetColumnWhereCondition("SKUDepartmentID", new WhereCondition().WhereEquals("SKUDepartmentID", di.DepartmentID)));
        }

        // Manufacturer filter
        ManufacturerInfo mi = ManufacturerInfo.Provider.Get(Manufacturer, SiteInfoProvider.GetSiteID(CurrentSiteName));

        mi = mi ?? ManufacturerInfo.Provider.Get(Manufacturer, 0);
        if (mi != null)
        {
            where.Where(GetColumnWhereCondition("SKUManufacturerID", new WhereCondition().WhereEquals("SKUManufacturerID", mi.ManufacturerID)));
        }

        // Brand filter
        BrandInfo bi = BrandInfoProvider.ProviderObject.Get(Brand, SiteInfoProvider.GetSiteID(CurrentSiteName));

        if (bi != null)
        {
            where.Where(GetColumnWhereCondition("SKUBrandID", new WhereCondition().WhereEquals("SKUBrandID", bi.BrandID)));
        }

        // Collection filter
        CollectionInfo ci = CollectionInfo.Provider.Get(Collection, SiteInfoProvider.GetSiteID(CurrentSiteName));

        if (ci != null)
        {
            where.Where(GetColumnWhereCondition("SKUCollectionID", new WhereCondition().WhereEquals("SKUCollectionID", ci.CollectionID)));
        }

        // Tax class filter
        TaxClassInfo tci = TaxClassInfo.Provider.Get(TaxClass, SiteInfoProvider.GetSiteID(CurrentSiteName));

        if (tci != null)
        {
            where.Where(GetColumnWhereCondition("SKUTaxClassID", new WhereCondition().WhereEquals("SKUTaxClassID", tci.TaxClassID)));
        }

        // Supplier filter
        SupplierInfo si = SupplierInfoProvider.GetSupplierInfo(Supplier, CurrentSiteName);

        si = si ?? SupplierInfoProvider.GetSupplierInfo(Supplier, null);
        if (si != null)
        {
            where.Where(GetColumnWhereCondition("SKUSupplierID", new WhereCondition().WhereEquals("SKUSupplierID", si.SupplierID)));
        }

        // Needs shipping filter
        if (!string.IsNullOrEmpty(NeedsShipping) && (NeedsShipping != FILTER_ALL))
        {
            if (NeedsShipping == NEEDS_SHIPPING_YES)
            {
                where.Where(GetColumnWhereCondition("SKUNeedsShipping", new WhereCondition().WhereTrue("SKUNeedsShipping")));
            }
            else if (NeedsShipping == NEEDS_SHIPPING_NO)
            {
                where.Where(GetColumnWhereCondition("SKUNeedsShipping", new WhereCondition().WhereFalse("SKUNeedsShipping").Or().WhereNull("SKUNeedsShipping")));
            }
        }

        // Price from filter
        if (PriceFrom > 0)
        {
            where.WhereGreaterOrEquals("SKUPrice", PriceFrom);
        }

        // Price to filter
        if (PriceTo > 0)
        {
            where.WhereLessOrEquals("SKUPrice", PriceTo);
        }

        // Public status filter
        PublicStatusInfo psi = PublicStatusInfo.Provider.Get(PublicStatus, SiteInfoProvider.GetSiteID(CurrentSiteName));

        if (psi != null)
        {
            where.Where(GetColumnWhereCondition("SKUPublicStatusID", new WhereCondition().WhereEquals("SKUPublicStatusID", psi.PublicStatusID)));
        }

        // Internal status filter
        InternalStatusInfo isi = InternalStatusInfo.Provider.Get(InternalStatus, SiteInfoProvider.GetSiteID(CurrentSiteName));

        if (isi != null)
        {
            where.Where(GetColumnWhereCondition("SKUInternalStatusID", new WhereCondition().WhereEquals("SKUInternalStatusID", isi.InternalStatusID)));
        }

        // Allow for sale filter
        if (!string.IsNullOrEmpty(AllowForSale) && (AllowForSale != FILTER_ALL))
        {
            if (AllowForSale == ALLOW_FOR_SALE_YES)
            {
                where.WhereTrue("SKUEnabled");
            }
            else if (AllowForSale == ALLOW_FOR_SALE_NO)
            {
                where.WhereEqualsOrNull("SKUEnabled", false);
            }
        }

        // Available items filter
        if (!string.IsNullOrEmpty(AvailableItems))
        {
            int value = ValidationHelper.GetInteger(AvailableItems, int.MaxValue);
            where.WhereLessOrEquals("SKUAvailableItems", value);
        }

        // Needs to be reordered filter
        if (NeedsToBeReordered)
        {
            where.Where(w => w.Where(v => v.WhereNull("SKUReorderAt").And().WhereLessOrEquals("SKUAvailableItems", 0))
                        .Or()
                        .Where(z => z.WhereNotNull("SKUReorderAt").And().WhereLessOrEquals("SKUAvailableItems".AsColumn(), "SKUReorderAt".AsColumn())));
        }

        return(where);
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        ScriptHelper.RegisterJQuery(this);

        // Check UI element
        CheckUIElementAccessHierarchical(ModuleName.ECOMMERCE, IsMultiStoreConfiguration ? "Tools.Ecommerce.StatesTaxClasses" : "Configuration.TaxClasses.States");

        // Get tax class Id from URL
        taxClassId = QueryHelper.GetInteger("objectid", 0);

        TaxClassInfo taxClass = TaxClassInfoProvider.GetTaxClassInfo(taxClassId);

        EditedObject = taxClass;
        // Check if configured tax class belongs to configured site
        if (taxClass != null)
        {
            // Check site id of tax class
            CheckEditedObjectSiteID(taxClass.TaxClassSiteID);

            currencyCode = CurrencyInfoProvider.GetMainCurrencyCode(taxClass.TaxClassSiteID);

            // Check presence of main currency
            CheckMainCurrency(taxClass.TaxClassSiteID);
        }

        if (!RequestHelper.IsPostBack())
        {
            // Fill the drpCountry with countries which have some states or colonies
            drpCountry.DataSource     = CountryInfoProvider.GetCountriesWithStates();
            drpCountry.DataValueField = "CountryID";
            drpCountry.DataTextField  = "CountryDisplayName";
            drpCountry.DataBind();
        }
        // Set grid view properties
        gvStates.Columns[0].HeaderText = GetString("taxclass_state.gvstates.state");
        gvStates.Columns[1].HeaderText = GetString("Code");
        gvStates.Columns[2].HeaderText = GetString("taxclass_state.gvstates.value");
        gvStates.Columns[3].HeaderText = GetString("taxclass_state.gvstates.isflat");
        gvStates.Columns[4].HeaderText = GetString("StateId");

        LoadGridViewData();

        // Init scripts
        string currencySwitchScript = string.Format(@"
function switchCurrency(isFlatValue, labelId){{
  if(isFlatValue)
  {{
    jQuery('#' + labelId).html('{0}');
  }}else{{
    jQuery('#' + labelId).html('%');
  }}
}}", ScriptHelper.GetString(HTMLHelper.HTMLEncode(currencyCode), false));

        ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "CurrencySwitch", currencySwitchScript, true);
        ScriptHelper.RegisterStartupScript(this, typeof(string), "InitializeGrid", "jQuery('input[id*=\"chkIsFlatValue\"]').change();", true);

        // Set header actions
        CurrentMaster.HeaderActions.AddAction(new SaveAction(this));
        CurrentMaster.HeaderActions.ActionPerformed += HeaderActions_ActionPerformed;
        CurrentMaster.DisplaySiteSelectorPanel       = true;
    }
Пример #25
0
    protected void Page_Load(object sender, EventArgs e)
    {
        ScriptHelper.RegisterJQuery(this);

        // Check permissions for CMS Desk -> Ecommerce
        if (!CMSContext.CurrentUser.IsAuthorizedPerUIElement("CMS.Ecommerce", "Configuration.TaxClasses.Countries"))
        {
            RedirectToCMSDeskUIElementAccessDenied("CMS.Ecommerce", "Configuration.TaxClasses.Countries");
        }

        mTaxClassId = QueryHelper.GetInteger("taxclassid", 0);

        mTaxClassObj = TaxClassInfoProvider.GetTaxClassInfo(mTaxClassId);
        EditedObject = mTaxClassObj;
        // Check if configured tax class belongs to configured site
        if (mTaxClassObj != null)
        {
            CheckEditedObjectSiteID(mTaxClassObj.TaxClassSiteID);

            currencyCode = CurrencyInfoProvider.GetMainCurrencyCode(mTaxClassObj.TaxClassSiteID);

            // Check presence of main currency
            string currencyErr = CheckMainCurrency(mTaxClassObj.TaxClassSiteID);
            if (!string.IsNullOrEmpty(currencyErr))
            {
                // Show message
                lblError.Text = currencyErr;
                lblError.Visible = true;
            }
        }

        GridViewCountries.Columns[0].HeaderText = GetString("TaxClass_Country.Country");
        GridViewCountries.Columns[1].HeaderText = GetString("TaxClass_Country.Value");
        GridViewCountries.Columns[2].HeaderText = GetString("TaxClass_Country.IsFlat");
        DataSet ds = TaxClassCountryInfoProvider.GetCountriesAndTaxValues(mTaxClassId);
        GridViewCountries.Columns[3].Visible = true;
        GridViewCountries.DataSource = ds.Tables[0];
        GridViewCountries.DataBind();
        // After id is copied, the 4th column it's not needed anymore
        GridViewCountries.Columns[3].Visible = false;
        GridViewCountries.GridLines = GridLines.Horizontal;

        // Init scripts
        string currencySwitchScript = string.Format(@"
        function switchCurrency(isFlatValue, labelId){{
          if(isFlatValue)
          {{
        jQuery('#'+labelId).html('({0})');
          }}else{{
        jQuery('#'+labelId).html('(%)');
          }}
        }}", ScriptHelper.GetString(currencyCode, false));

        ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "CurrencySwitch", currencySwitchScript, true);
        ScriptHelper.RegisterStartupScript(this, typeof(string), "InitializeGrid", "jQuery('input[id*=\"chkIsFlatValue\"]').change();", true);

        mSave = GetString("general.save");

        // Set header actions
        string[,] actions = new string[1, 10];

        actions[0, 0] = HeaderActions.TYPE_SAVEBUTTON;
        actions[0, 1] = this.GetString("Header.Settings.SaveChanged");
        actions[0, 2] = String.Empty;
        actions[0, 3] = String.Empty;
        actions[0, 4] = String.Empty;
        actions[0, 5] = this.GetImageUrl("CMSModules/CMS_Content/EditMenu/save.png");
        actions[0, 6] = "save";
        actions[0, 8] = true.ToString();

        this.CurrentMaster.HeaderActions.Actions = actions;
        this.CurrentMaster.HeaderActions.ActionPerformed += this.HeaderActions_ActionPerformed;
    }
Пример #26
0
    protected void Page_Load(object sender, EventArgs e)
    {
        ScriptHelper.RegisterJQuery(this);

        // Check permissions for CMS Desk -> Ecommerce
        if (!CMSContext.CurrentUser.IsAuthorizedPerUIElement("CMS.Ecommerce", "Configuration.TaxClasses.Countries"))
        {
            RedirectToCMSDeskUIElementAccessDenied("CMS.Ecommerce", "Configuration.TaxClasses.Countries");
        }

        mTaxClassId = QueryHelper.GetInteger("taxclassid", 0);

        mTaxClassObj = TaxClassInfoProvider.GetTaxClassInfo(mTaxClassId);
        EditedObject = mTaxClassObj;
        // Check if configured tax class belongs to configured site
        if (mTaxClassObj != null)
        {
            CheckEditedObjectSiteID(mTaxClassObj.TaxClassSiteID);

            currencyCode = CurrencyInfoProvider.GetMainCurrencyCode(mTaxClassObj.TaxClassSiteID);

            // Check presence of main currency
            string currencyErr = CheckMainCurrency(mTaxClassObj.TaxClassSiteID);
            if (!string.IsNullOrEmpty(currencyErr))
            {
                // Show message
                lblError.Text    = currencyErr;
                lblError.Visible = true;
            }
        }

        GridViewCountries.Columns[0].HeaderText = GetString("TaxClass_Country.Country");
        GridViewCountries.Columns[1].HeaderText = GetString("TaxClass_Country.Value");
        GridViewCountries.Columns[2].HeaderText = GetString("TaxClass_Country.IsFlat");
        DataSet ds = TaxClassCountryInfoProvider.GetCountriesAndTaxValues(mTaxClassId);

        GridViewCountries.Columns[3].Visible = true;
        GridViewCountries.DataSource         = ds.Tables[0];
        GridViewCountries.DataBind();
        // After id is copied, the 4th column it's not needed anymore
        GridViewCountries.Columns[3].Visible = false;
        GridViewCountries.GridLines          = GridLines.Horizontal;

        // Init scripts
        string currencySwitchScript = string.Format(@"
function switchCurrency(isFlatValue, labelId){{
  if(isFlatValue)
  {{
    jQuery('#'+labelId).html('({0})');
  }}else{{
    jQuery('#'+labelId).html('(%)');
  }}
}}", ScriptHelper.GetString(currencyCode, false));

        ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "CurrencySwitch", currencySwitchScript, true);
        ScriptHelper.RegisterStartupScript(this, typeof(string), "InitializeGrid", "jQuery('input[id*=\"chkIsFlatValue\"]').change();", true);

        mSave = GetString("general.save");

        // Set header actions
        string[,] actions = new string[1, 10];

        actions[0, 0] = HeaderActions.TYPE_SAVEBUTTON;
        actions[0, 1] = this.GetString("Header.Settings.SaveChanged");
        actions[0, 2] = String.Empty;
        actions[0, 3] = String.Empty;
        actions[0, 4] = String.Empty;
        actions[0, 5] = this.GetImageUrl("CMSModules/CMS_Content/EditMenu/save.png");
        actions[0, 6] = "save";
        actions[0, 8] = true.ToString();

        this.CurrentMaster.HeaderActions.Actions          = actions;
        this.CurrentMaster.HeaderActions.ActionPerformed += this.HeaderActions_ActionPerformed;
    }