Beispiel #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        lblAvialable.Text = GetString("com.department.defaulttaxes");
        mDepartmentId     = QueryHelper.GetInteger("departmentid", 0);
        if (mDepartmentId > 0)
        {
            mDepartmentInfoObj = DepartmentInfoProvider.GetDepartmentInfo(mDepartmentId);
            EditedObject       = mDepartmentInfoObj;

            if (mDepartmentInfoObj != null)
            {
                CheckEditedObjectSiteID(mDepartmentInfoObj.DepartmentSiteID);

                // Get tax classes assigned to department
                DataSet ds = TaxClassInfoProvider.GetDepartmentTaxClasses(mDepartmentId);
                if (!DataHelper.DataSourceIsEmpty(ds))
                {
                    mCurrentValues = TextHelper.Join(";", SystemDataHelper.GetStringValues(ds.Tables[0], "TaxClassID"));
                }

                if (!RequestHelper.IsPostBack())
                {
                    uniSelector.Value = mCurrentValues;
                }
            }
        }

        uniSelector.IconPath            = GetObjectIconUrl("ecommerce.taxclass", "object.png");
        uniSelector.OnSelectionChanged += uniSelector_OnSelectionChanged;
        uniSelector.WhereCondition      = GetSelectorWhereCondition();
    }
Beispiel #2
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;
    }
Beispiel #3
0
    /// <summary>
    /// Returns product total tax in site main currency.
    /// </summary>
    /// <param name="skuPrice">SKU price</param>
    /// <param name="skuId">SKU ID</param>
    /// <param name="stateId">Customer billing address state ID</param>
    /// <param name="countryId">Customer billing addres country ID</param>
    /// <param name="isTaxIDSupplied">Indicates if customer tax registration ID is supplied</param>
    private static double GetSKUTotalTax(double skuPrice, int skuId, int stateId, int countryId, bool isTaxIDSupplied)
    {
        double totalTax     = 0;
        int    cacheMinutes = 0;

        // Try to get data from cache
        using (CachedSection <double> cs = new CachedSection <double>(ref totalTax, cacheMinutes, true, null, "skutotaltax|", skuId, skuPrice, stateId, countryId, isTaxIDSupplied))
        {
            if (cs.LoadData)
            {
                // Get all the taxes and their values which are applied to the specified product
                DataSet ds = TaxClassInfoProvider.GetTaxes(skuId, countryId, stateId, null);
                if (!DataHelper.DataSourceIsEmpty(ds))
                {
                    foreach (DataRow dr in ds.Tables[0].Rows)
                    {
                        bool zeroTax = ValidationHelper.GetBoolean(dr["TaxClassZeroIfIDSupplied"], false);
                        if (!(isTaxIDSupplied && zeroTax))
                        {
                            double taxValue = ValidationHelper.GetDouble(dr["TaxValue"], 0);
                            bool   isFlat   = ValidationHelper.GetBoolean(dr["TaxIsFlat"], false);

                            // Add tax value
                            totalTax += TaxClassInfoProvider.GetTaxValue(skuPrice, taxValue, isFlat);
                        }
                    }
                }

                // Cache the data
                cs.Data = totalTax;
            }
        }

        return(totalTax);
    }
    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 = TaxClassInfoProvider.GetTaxClassInfo(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");

        DataSet ds = TaxClassCountryInfoProvider.GetCountriesAndTaxValues(taxClassId);

        // 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;
    }
Beispiel #5
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);
            }
        }
    }
Beispiel #6
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);
                }
            }
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        EditedObject = Product;

        if (ProductID > 0)
        {
            DataSet ds = TaxClassInfoProvider.GetSKUTaxClasses(ProductID);
            if (!DataHelper.DataSourceIsEmpty(ds))
            {
                currentValues = TextHelper.Join(";", DataHelper.GetStringValues(ds.Tables[0], "TaxClassID"));
            }

            uniSelector.WhereCondition = GetWhereCondition();

            if (!RequestHelper.IsPostBack())
            {
                uniSelector.Value = currentValues;
            }

            headTitle.Text = GetString("product_edit_tax.taxtitle");
        }

        // Get category of product
        OptionCategoryInfo category = OptionCategoryInfoProvider.GetOptionCategoryInfo(Product.SKUOptionCategoryID);

        // Ensure correct info label for Attribute and Text product option
        if (category != null)
        {
            if (category.CategoryType != OptionCategoryTypeEnum.Products)
            {
                headTitle.Text = GetString("product_edit_tax.taxtitleforoption");
            }
        }
    }
Beispiel #8
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Init header actions
        HeaderActions actions = CurrentMaster.HeaderActions;

        actions.ActionPerformed += HeaderActions_ActionPerformed;

        string newElementName;

        if (IsMultiStoreConfiguration)
        {
            newElementName = "new.configuration.globaltaxclass";
            CheckUIElementAccessHierarchical(ModuleName.ECOMMERCE, "Tools.Ecommerce.TaxClasses");
        }
        else
        {
            newElementName = "new.configuration.taxclass";
            CheckUIElementAccessHierarchical(ModuleName.ECOMMERCE, "Configuration.TaxClasses");
        }

        // Prepare the new tax class header element
        actions.ActionsList.Add(new HeaderAction
        {
            Text        = GetString("TaxClass_List.NewItemCaption"),
            RedirectUrl = GetRedirectURL(newElementName),
        });

        // Show copy from global link when not configuring global tax classes
        if (ConfiguredSiteID != 0)
        {
            // Show "Copy from global" link only if there is at least one global tax class
            DataSet ds = TaxClassInfoProvider.GetTaxClasses().TopN(1).OnSite(0).Column("TaxClassID");
            if (!DataHelper.DataSourceIsEmpty(ds))
            {
                actions.ActionsList.Add(new HeaderAction
                {
                    Text          = GetString("general.copyfromglobal"),
                    OnClientClick = "return ConfirmCopyFromGlobal();",
                    CommandName   = "copyFromGlobal",
                    ButtonStyle   = ButtonStyle.Default
                });

                // Register javascript to confirm action
                string script = "function ConfirmCopyFromGlobal() {return confirm(" + ScriptHelper.GetString(GetString("com.ConfirmTaxClassFromGlobal")) + ");}";
                ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "ConfirmCopyFromGlobal", ScriptHelper.GetScript(script));
            }
        }

        // Show information about usage of global objects when used on site
        HandleGlobalObjectInformation(UniGrid.ObjectType);

        // Filter records by site
        UniGrid.WhereCondition = "ISNULL(TaxClassSiteID, 0) = " + ConfiguredSiteID;
    }
Beispiel #9
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;
    }
Beispiel #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 == "")
        {
            // 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;
        }
    }
Beispiel #11
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;
            }
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        // Init header actions
        HeaderActions actions = CurrentMaster.HeaderActions;

        actions.ActionPerformed += new CommandEventHandler(HeaderActions_ActionPerformed);

        // Prepare the new tax class header element
        actions.ActionsList.Add(new HeaderAction()
        {
            Text        = GetString("TaxClass_List.NewItemCaption"),
            RedirectUrl = ResolveUrl("TaxClass_New.aspx?siteId=" + SiteID),
            ImageUrl    = GetImageUrl("Objects/Ecommerce_TaxClass/add.png"),
            ControlType = HeaderActionTypeEnum.Hyperlink
        });

        // Show copy from global link when not configuring global tax classes
        if (ConfiguredSiteID != 0)
        {
            // Show "Copy from global" link only if there is at least one global tax class
            DataSet ds = TaxClassInfoProvider.GetTaxClasses("TaxClassSiteID IS NULL", null, 1, "TaxClassID");
            if (!DataHelper.DataSourceIsEmpty(ds))
            {
                actions.ActionsList.Add(new HeaderAction()
                {
                    Text          = GetString("general.copyfromglobal"),
                    OnClientClick = "return ConfirmCopyFromGlobal();",
                    ImageUrl      = GetImageUrl("Objects/Ecommerce_TaxClass/fromglobal.png"),
                    CommandName   = "copyFromGlobal",
                    ControlType   = HeaderActionTypeEnum.LinkButton
                });

                // Register javascript to confirm action
                string script = "function ConfirmCopyFromGlobal() {return confirm(" + ScriptHelper.GetString(GetString("com.ConfirmTaxClassFromGlobal")) + ");}";
                ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "ConfirmCopyFromGlobal", ScriptHelper.GetScript(script));
            }
        }

        UniGrid.OnAction    += new OnActionEventHandler(uniGrid_OnAction);
        UniGrid.ZeroRowsText = GetString("general.nodatafound");

        // Configuring global records from specific site
        if ((ConfiguredSiteID == 0) && (SiteID != 0))
        {
            ShowInformation(GetString("com.UsingGlobalSettings"));
        }

        // Filter records by site
        UniGrid.WhereCondition = "ISNULL(TaxClassSiteID, 0) = " + ConfiguredSiteID;
    }
    /// <summary>
    /// Handles the UniGrid's OnAction event.
    /// </summary>
    /// <param name="actionName">Name of item (button) that throws event</param>
    /// <param name="actionArgument">ID (value of Primary key) of corresponding data row</param>
    protected void uniGrid_OnAction(string actionName, object actionArgument)
    {
        if (actionName == "edit")
        {
            URLHelper.Redirect("TaxClass_Frameset.aspx?taxclassid=" + Convert.ToString(actionArgument) + "&siteId=" + SiteID);
        }
        else if (actionName == "delete")
        {
            // Check permissions
            CheckConfigurationModification();

            TaxClassInfoProvider.DeleteTaxClassInfo(ValidationHelper.GetInteger(actionArgument, 0));
        }
    }
Beispiel #14
0
    protected void Page_Load(object sender, EventArgs e)
    {
        var taxClassId      = QueryHelper.GetInteger("objectid", 0);
        var taxClassInfoObj = TaxClassInfoProvider.GetTaxClassInfo(taxClassId);

        EditedObject = taxClassInfoObj;

        if (taxClassInfoObj != null)
        {
            editedSiteId = taxClassInfoObj.TaxClassSiteID;

            // Check object's site id
            CheckEditedObjectSiteID(editedSiteId);

            uniGrid.WhereCondition = new WhereCondition().WhereEquals("SKUTaxClassID", taxClassId).ToString(true);
        }
    }
Beispiel #15
0
    /// <summary>
    /// Handles the UniGrid's OnAction event.
    /// </summary>
    /// <param name="actionName">Name of item (button) that throws event</param>
    /// <param name="actionArgument">ID (value of Primary key) of corresponding data row</param>
    protected void uniGrid_OnAction(string actionName, object actionArgument)
    {
        if (actionName == "edit")
        {
            var    editElementName = IsMultiStoreConfiguration ? "edit.Tools.Ecommerce.TaxProperties" : "edit.Configuration.TaxClasses";
            string url             = GetRedirectURL(editElementName);
            url = URLHelper.AddParameterToUrl(url, "objectid", ValidationHelper.GetInteger(actionArgument, 0).ToString("0"));

            URLHelper.Redirect(url);
        }
        else if (actionName == "delete")
        {
            // Check permissions
            CheckConfigurationModification();

            TaxClassInfoProvider.DeleteTaxClassInfo(ValidationHelper.GetInteger(actionArgument, 0));
        }
    }
Beispiel #16
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;
        }
    }
Beispiel #17
0
    protected void Page_Load(object sender, EventArgs e)
    {
        lblSiteTitle.Text = GetString("product_edit_tax.taxtitle");
        if (ProductID > 0)
        {
            DataSet ds = TaxClassInfoProvider.GetSKUTaxClasses(ProductID);
            if (!DataHelper.DataSourceIsEmpty(ds))
            {
                currentValues = TextHelper.Join(";", SqlHelperClass.GetStringValues(ds.Tables[0], "TaxClassID"));
            }

            this.uniSelector.WhereCondition = GetWhereCondition(currentValues);

            if (!RequestHelper.IsPostBack())
            {
                this.uniSelector.Value = currentValues;
            }
        }

        this.uniSelector.IconPath = GetObjectIconUrl("ecommerce.taxclass", "object.png");
    }
    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;
            }
        }
    }
Beispiel #19
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 = 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);
        }

        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;
    }
    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);
    }
Beispiel #21
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (IsMultiStoreConfiguration)
        {
            CheckUIElementAccessHierarchical(ModuleName.ECOMMERCE, "Ecommerce.GlobalDepartments.DefaultTaxClasses");
        }
        else
        {
            CheckUIElementAccessHierarchical(ModuleName.ECOMMERCE, "Configuration.Departments.TaxClasses");
        }

        mDepartmentId = QueryHelper.GetInteger("objectId", 0);
        if (mDepartmentId > 0)
        {
            mDepartmentInfoObj = DepartmentInfoProvider.GetDepartmentInfo(mDepartmentId);
            EditedObject       = mDepartmentInfoObj;

            if (mDepartmentInfoObj != null)
            {
                CheckEditedObjectSiteID(mDepartmentInfoObj.DepartmentSiteID);

                // Get tax classes assigned to department
                DataSet ds = TaxClassInfoProvider.GetDepartmentTaxClasses(mDepartmentId);
                if (!DataHelper.DataSourceIsEmpty(ds))
                {
                    mCurrentValues = TextHelper.Join(";", DataHelper.GetStringValues(ds.Tables[0], "TaxClassID"));
                }

                if (!RequestHelper.IsPostBack())
                {
                    uniSelector.Value = mCurrentValues;
                }
            }
        }

        uniSelector.OnSelectionChanged += uniSelector_OnSelectionChanged;
        uniSelector.WhereCondition      = GetSelectorWhereCondition();
    }
Beispiel #22
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);
                }


                // }
            }
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        // Check permissions for CMS Desk -> Ecommerce
        if (!CMSContext.CurrentUser.IsAuthorizedPerUIElement("CMS.Ecommerce", "Configuration.Departments.TaxClasses"))
        {
            RedirectToCMSDeskUIElementAccessDenied("CMS.Ecommerce", "Configuration.Departments.TaxClasses");
        }

        lblAvialable.Text = GetString("com.department.defaulttaxes");
        mDepartmentId     = QueryHelper.GetInteger("departmentid", 0);
        if (mDepartmentId > 0)
        {
            mDepartmentInfoObj = DepartmentInfoProvider.GetDepartmentInfo(mDepartmentId);
            EditedObject       = mDepartmentInfoObj;

            if (mDepartmentInfoObj != null)
            {
                CheckEditedObjectSiteID(mDepartmentInfoObj.DepartmentSiteID);

                DataSet ds = TaxClassInfoProvider.GetDepartmentTaxClasses(mDepartmentId);
                if (!DataHelper.DataSourceIsEmpty(ds))
                {
                    mCurrentValues = TextHelper.Join(";", SqlHelperClass.GetStringValues(ds.Tables[0], "TaxClassID"));
                }

                if (!RequestHelper.IsPostBack())
                {
                    uniSelector.Value = mCurrentValues;
                }
            }
        }

        uniSelector.IconPath            = GetObjectIconUrl("ecommerce.taxclass", "object.png");
        uniSelector.OnSelectionChanged += uniSelector_OnSelectionChanged;
        uniSelector.WhereCondition      = GetSelectorWhereCondition();
    }
    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;
    }
Beispiel #25
0
    protected void Page_Load(object sender, EventArgs e)
    {
        this.CurrentMaster.Title.TitleText     = GetString("TaxClass_List.HeaderCaption");
        this.CurrentMaster.Title.TitleImage    = GetImageUrl("Objects/Ecommerce_TaxClass/object.png");
        this.CurrentMaster.Title.HelpTopicName = "tax_classes_list";
        this.CurrentMaster.Title.HelpName      = "helpTopic";

        // Prepare the new payment option header element
        string[,] actions = new string[2, 9];
        actions[0, 0]     = "HyperLink";
        actions[0, 1]     = GetString("TaxClass_List.NewItemCaption");
        actions[0, 3]     = "~/CMSModules/Ecommerce/Pages/Tools/Configuration/TaxClasses/TaxClass_New.aspx?siteId=" + SiteID;
        actions[0, 5]     = GetImageUrl("Objects/Ecommerce_TaxClass/add.png");

        // Show copy from global link when not configuring global tax classes
        if (ConfiguredSiteID != 0)
        {
            // Show "Copy from global" link only if there is at least one global tax class
            DataSet ds = TaxClassInfoProvider.GetTaxClasses("TaxClassSiteID IS NULL", null, 1, "TaxClassID");
            if (!DataHelper.DataSourceIsEmpty(ds))
            {
                actions[1, 0] = HeaderActions.TYPE_SAVEBUTTON;
                actions[1, 1] = GetString("general.copyfromglobal");
                actions[1, 2] = "return ConfirmCopyFromGlobal();";
                actions[1, 3] = null;
                actions[1, 4] = null;
                actions[1, 5] = GetImageUrl("Objects/Ecommerce_TaxClass/fromglobal.png");
                actions[1, 6] = "copyFromGlobal";
                actions[1, 7] = String.Empty;
                actions[1, 8] = true.ToString();

                // Register javascript to confirm action
                string script = "function ConfirmCopyFromGlobal() {return confirm(" + ScriptHelper.GetString(GetString("com.ConfirmTaxClassFromGlobal")) + ");}";
                ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "ConfirmCopyFromGlobal", ScriptHelper.GetScript(script));
            }
        }

        this.CurrentMaster.HeaderActions.Actions          = actions;
        this.CurrentMaster.HeaderActions.ActionPerformed += new CommandEventHandler(HeaderActions_ActionPerformed);

        UniGrid.OnAction    += new OnActionEventHandler(uniGrid_OnAction);
        UniGrid.ZeroRowsText = GetString("general.nodatafound");

        // Configuring global records
        if (ConfiguredSiteID == 0)
        {
            // Select only global records
            UniGrid.WhereCondition = "TaxClassSiteID IS NULL";
            // Show "using global settings" info message only if showing global store settings
            if (SiteID != 0)
            {
                lblGlobalInfo.Visible = true;
                lblGlobalInfo.Text    = GetString("com.UsingGlobalSettings");
            }
        }
        else
        {
            // Select only site-specific records
            UniGrid.WhereCondition = "TaxClassSiteID = " + ConfiguredSiteID;
        }
    }
Beispiel #26
0
 /// <summary>
 ///  Copies site-specific tax classes from global list.
 /// </summary>
 protected void CopyFromGlobal()
 {
     CheckConfigurationModification();
     TaxClassInfoProvider.CopyFromGlobal(ConfiguredSiteID);
 }
    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;
    }
Beispiel #28
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 = SKUInfoProvider.GetSKUInfo(sku.SKUParentSKUID);
                    fullName = string.Format("{0}: {1}", parentSku.SKUName, sku.SKUName);
                }
                return(HTMLHelper.HTMLEncode(fullName));

            case "optioncategory":
                OptionCategoryInfo optionCategory = OptionCategoryInfoProvider.GetOptionCategoryInfo(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 = DepartmentInfoProvider.GetDepartmentInfo(sku.SKUDepartmentID);
                return((department != null) ? HTMLHelper.HTMLEncode(ResHelper.LocalizeString(department.DepartmentDisplayName)) : "");

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

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

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

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

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

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

            case "skuinternalstatusid":
                // Transform to display name and localize
                InternalStatusInfo internalStatus = InternalStatusInfoProvider.GetInternalStatusInfo(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);
    }
Beispiel #29
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   = Representing.ToEnum <SKUProductTypeEnum>();
            string             productTypeString = productTypeEnum.ToStringRepresentation();

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

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

        // Department filter
        DepartmentInfo di = DepartmentInfoProvider.GetDepartmentInfo(Department, CurrentSiteName);

        di = di ?? DepartmentInfoProvider.GetDepartmentInfo(Department, null);

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

        // Manufacturer filter
        ManufacturerInfo mi = ManufacturerInfoProvider.GetManufacturerInfo(Manufacturer, CurrentSiteName);

        mi = mi ?? ManufacturerInfoProvider.GetManufacturerInfo(Manufacturer, null);
        if (mi != null)
        {
            where.Where(GetColumnWhereCondition("SKUManufacturerID", new WhereCondition().WhereEquals("SKUManufacturerID", mi.ManufacturerID)));
        }

        // Brand filter
        BrandInfo bi = BrandInfoProvider.GetBrandInfo(Brand, CurrentSiteName);

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

        // Collection filter
        CollectionInfo ci = CollectionInfoProvider.GetCollectionInfo(Collection, CurrentSiteName);

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

        // Tax class filter
        TaxClassInfo tci = TaxClassInfoProvider.GetTaxClassInfo(TaxClass, 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 = PublicStatusInfoProvider.GetPublicStatusInfo(PublicStatus, CurrentSiteName);

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

        // Internal status filter
        InternalStatusInfo isi = InternalStatusInfoProvider.GetInternalStatusInfo(InternalStatus, 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);
    }
Beispiel #30
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;
    }