protected void Page_Load(object sender, EventArgs e)
    {
        departmentId = QueryHelper.GetInteger("departmentId", 0);

        CMSMasterPage master = (CMSMasterPage)CurrentMaster;

        string         currentDepartmentName = string.Empty;
        DepartmentInfo di = DepartmentInfoProvider.GetDepartmentInfo(departmentId);

        if (di != null)
        {
            editedSiteId = di.DepartmentSiteID;

            // Check site id
            CheckEditedObjectSiteID(editedSiteId);
            currentDepartmentName = ResHelper.LocalizeString(di.DepartmentDisplayName);
        }

        // initializes page title
        string[,] breadcrumbs = new string[2, 3];
        breadcrumbs[0, 0]     = GetString("Department_Edit.ItemListLink");
        breadcrumbs[0, 1]     = "~/CMSModules/Ecommerce/Pages/Tools/Configuration/Departments/Department_List.aspx?siteId=" + SiteID;
        breadcrumbs[0, 2]     = "configEdit";
        breadcrumbs[1, 0]     = FormatBreadcrumbObjectName(currentDepartmentName, editedSiteId);
        breadcrumbs[1, 1]     = "";
        breadcrumbs[1, 2]     = "";

        master.Title.Breadcrumbs  = breadcrumbs;
        master.Tabs.OnTabCreated += Tabs_OnTabCreated;
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        lblAvialable.Text = GetString("com.discountlevel.departmentsavailable");
        mDiscountLevelId  = QueryHelper.GetInteger("discountLevelId", 0);
        editedSiteId      = ConfiguredSiteID;

        if (mDiscountLevelId > 0)
        {
            mDiscountLevelInfoObj = DiscountLevelInfoProvider.GetDiscountLevelInfo(mDiscountLevelId);
            EditedObject          = mDiscountLevelInfoObj;

            if (mDiscountLevelInfoObj != null)
            {
                editedSiteId = mDiscountLevelInfoObj.DiscountLevelSiteID;
                CheckEditedObjectSiteID(editedSiteId);

                // Get the active departments
                DataSet ds = DepartmentInfoProvider.GetDiscountLevelDepartments(mDiscountLevelId);
                if (!DataHelper.DataSourceIsEmpty(ds))
                {
                    mCurrentValues = TextHelper.Join(";", SystemDataHelper.GetStringValues(ds.Tables[0], "DepartmentID"));
                }

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

        uniSelector.IconPath            = GetObjectIconUrl("ecommerce.department", "object.png");
        uniSelector.OnSelectionChanged += uniSelector_OnSelectionChanged;
        uniSelector.WhereCondition      = GetWhereCondition();
    }
    /// <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("Department_Frameset.aspx?departmentId=" + Convert.ToString(actionArgument) + "&siteId=" + SelectSite.SiteID);
        }
        else if (actionName == "delete")
        {
            DepartmentInfo deptInfoObj = DepartmentInfoProvider.GetDepartmentInfo(ValidationHelper.GetInteger(actionArgument, 0));
            // Nothing to delete
            if (deptInfoObj == null)
            {
                return;
            }

            // Check permissions
            CheckConfigurationModification(deptInfoObj.DepartmentSiteID);

            if (DepartmentInfoProvider.CheckDependencies(deptInfoObj.DepartmentID))
            {
                // Show error message
                ShowError(GetString("Ecommerce.DeleteDisabledWithoutEnable"));

                return;
            }
            // Delete DepartmentInfo object from database
            DepartmentInfoProvider.DeleteDepartmentInfo(deptInfoObj);
        }
    }
示例#4
0
    /// <summary>
    /// Gets object from the specified column of the department with specific ID.
    /// </summary>
    /// <param name="Id">Department ID</param>
    /// <param name="column">Column name</param>
    public static object GetDepartment(object Id, string column)
    {
        int id = ValidationHelper.GetInteger(Id, 0);

        if (id > 0 && !DataHelper.IsEmpty(column))
        {
            // Get department
            DepartmentInfo di = DepartmentInfoProvider.GetDepartmentInfo(id);

            if (di != null)
            {
                // Return datarow value if specified column exists
                if (di.ContainsColumn(column))
                {
                    return(di.GetValue(column));
                }
                else
                {
                    return("");
                }
            }
        }

        return("");
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        // Field validator error messages initialization
        rfvDisplayName.ErrorMessage = GetString("Department_Edit.errorEmptyDisplayName");
        rfvCodeName.ErrorMessage    = GetString("Department_Edit.errorEmptyCodeName");

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

        // Get department id from querystring
        mDepartmentId = QueryHelper.GetInteger("departmentId", 0);
        mEditedSiteId = ConfiguredSiteID;
        if (mDepartmentId > 0)
        {
            DepartmentInfo departmentObj = DepartmentInfoProvider.GetDepartmentInfo(mDepartmentId);
            EditedObject = departmentObj;

            if (departmentObj != null)
            {
                mEditedSiteId = departmentObj.DepartmentSiteID;
                CheckEditedObjectSiteID(mEditedSiteId);

                // Fill editing form
                if (!RequestHelper.IsPostBack())
                {
                    LoadData(departmentObj);
                }
            }
        }
    }
示例#6
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();
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        lblAvialable.Text = GetString("com.department.usersavailable");
        mDepartmentId     = QueryHelper.GetInteger("departmentid", 0);
        if (mDepartmentId > 0)
        {
            mDepartmentInfoObj = DepartmentInfoProvider.GetDepartmentInfo(mDepartmentId);
            EditedObject       = mDepartmentInfoObj;

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

                // Get the active users
                string where = "UserID IN (SELECT UserID FROM COM_UserDepartment WHERE DepartmentID = " + mDepartmentId + ")";
                DataSet ds = UserInfoProvider.GetUsers(where, null, 0, "UserID");
                if (!DataHelper.DataSourceIsEmpty(ds))
                {
                    mCurrentValues = TextHelper.Join(";", SystemDataHelper.GetStringValues(ds.Tables[0], "UserID"));
                }

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

        uniSelector.IconPath            = GetObjectIconUrl("cms.user", "object.png");
        uniSelector.OnSelectionChanged += uniSelector_OnSelectionChanged;
        uniSelector.WhereCondition      = GetWhereCondition();
    }
    /// <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.Ecommerce.GlobalDepartments.Properties" : "Edit.DepartmentsProperties";
            URLHelper.Redirect(UIContextHelper.GetElementUrl(ModuleName.ECOMMERCE, editElementName, false, actionArgument.ToInteger(0)));
        }
        else if (actionName == "delete")
        {
            DepartmentInfo deptInfoObj = DepartmentInfoProvider.GetDepartmentInfo(ValidationHelper.GetInteger(actionArgument, 0));
            // Nothing to delete
            if (deptInfoObj == null)
            {
                return;
            }

            // Check permissions
            CheckConfigurationModification(deptInfoObj.DepartmentSiteID);

            if (deptInfoObj.Generalized.CheckDependencies())
            {
                // Show error message
                ShowError(GetString("Ecommerce.DeleteDisabledWithoutEnable"));

                return;
            }

            // Delete DepartmentInfo object from database
            DepartmentInfoProvider.DeleteDepartmentInfo(deptInfoObj);
        }
    }
示例#9
0
    /// <summary>
    /// Save changes in product allowed options
    /// </summary>
    private void SaveChanges()
    {
        SKUInfo product = SKUInfoProvider.GetSKUInfo(ProductID);

        if (product == null)
        {
            return;
        }

        // Check if user is authorized to modify product
        if (!ECommerceContext.IsUserAuthorizedToModifySKU(product))
        {
            RedirectToAccessDenied("CMS.Ecommerce", product.IsGlobal ? "EcommerceGlobalModify" : "EcommerceModify OR ModifyProducts");

            return;
        }

        if (!ECommerceContext.IsUserAuthorizedForDepartment(product.SKUDepartmentID))
        {
            DepartmentInfo departmentObj = DepartmentInfoProvider.GetDepartmentInfo(product.SKUDepartmentID);
            if (departmentObj != null)
            {
                RedirectToAccessDenied(String.Format(GetString("cmsdesk.notauthorizedtperdepartment"), departmentObj.DepartmentDisplayName));
                return;
            }
        }

        // Allow all option is enabled
        if (rbAllowAllOption.SelectedValue == ALLOW_ALL)
        {
            ProductHelper.AllowAllOptions(ProductID, CategoryID);
        }
        else
        {
            // Join users selection with previously selected items and options used in variants + remove deselected items
            var optionsToBeAllowedArray = ugOptions.SelectedItems.Union(SelectedOptionsIds).Except(ugOptions.DeselectedItems).ToArray();
            var optionsToBeAllowed      = ValidationHelper.GetIntegers(optionsToBeAllowedArray, 0);
            var optionsToBeRemoved      = ValidationHelper.GetIntegers(ugOptions.DeselectedItems.ToArray(), 0);

            // Add selected options to product
            if (optionsToBeAllowed.Count() > 0)
            {
                ProductHelper.AllowOptions(ProductID, CategoryID, optionsToBeAllowed);
            }
            // Disable allow all options if any option was deselected
            else
            {
                optionSKUCategoryInfo.AllowAllOptions = false;
                optionSKUCategoryInfo.Update();
            }

            // Remove deselected options from product
            if (optionsToBeRemoved.Count() > 0)
            {
                ProductHelper.RemoveOptions(ProductID, CategoryID, optionsToBeRemoved);
            }
        }
    }
示例#10
0
    /// <summary>
    /// Sets data to database.
    /// </summary>
    protected void btnOK_Click(object sender, EventArgs e)
    {
        // Check permissions
        CheckConfigurationModification(mEditedSiteId);

        // Check input values from textboxes and other controls - new Validator()
        string errorMessage = new Validator()
                              .NotEmpty(txtDepartmentDisplayName.Text.Trim(), GetString("Department_Edit.errorEmptyDisplayName"))
                              .NotEmpty(txtDepartmentName.Text.Trim(), GetString("Department_Edit.errorEmptyCodeName"))
                              .IsCodeName(txtDepartmentName.Text.Trim(), GetString("General.ErrorCodeNameInIdentificatorFormat")).Result;

        if (errorMessage == "")
        {
            // DepartmentName must be unique
            DepartmentInfo departmentObj = null;
            string         siteWhere     = (mEditedSiteId > 0) ? " AND (DepartmentSiteID = " + mEditedSiteId + " OR DepartmentSiteID IS NULL)" : "";
            DataSet        ds            = DepartmentInfoProvider.GetDepartments("DepartmentName = '" + txtDepartmentName.Text.Trim().Replace("'", "''") + "'" + siteWhere, null, 1, null);
            if (!DataHelper.DataSourceIsEmpty(ds))
            {
                departmentObj = new DepartmentInfo(ds.Tables[0].Rows[0]);
            }

            if ((departmentObj == null) || (departmentObj.DepartmentID == mDepartmentId))
            {
                // Get the object
                if (departmentObj == null)
                {
                    departmentObj = DepartmentInfoProvider.GetDepartmentInfo(mDepartmentId);
                    if (departmentObj == null)
                    {
                        departmentObj = new DepartmentInfo();
                        departmentObj.DepartmentSiteID = mEditedSiteId;
                    }
                }

                departmentObj.DepartmentID          = mDepartmentId;
                departmentObj.DepartmentName        = txtDepartmentName.Text.Trim();
                departmentObj.DepartmentDisplayName = txtDepartmentDisplayName.Text.Trim();

                // Save the object
                DepartmentInfoProvider.SetDepartmentInfo(departmentObj);

                lblInfo.Visible = true;
                lblInfo.Text    = GetString("General.ChangesSaved");
            }
            else
            {
                lblError.Visible = true;
                lblError.Text    = GetString("Department_Edit.DepartmentNameExists");
                lblInfo.Visible  = false;
            }
        }
        else
        {
            lblError.Visible = true;
            lblError.Text    = errorMessage;
        }
    }
示例#11
0
    /// <summary>
    /// Checks if current user has permissions for department.
    /// </summary>
    /// <param name="departmentID">ID of department</param>
    private void CheckDepartmentPermission(int departmentID)
    {
        // Check department permission for parent product
        if (!ECommerceContext.IsUserAuthorizedForDepartment(departmentID))
        {
            string departmentName = DepartmentInfoProvider.GetDepartmentInfo(departmentID).DepartmentDisplayName;

            RedirectToAccessDenied(string.Format(GetString("cmsdesk.notauthorizedtperdepartment"), departmentName));
        }
    }
示例#12
0
    /// <summary>
    /// Returns complete WHERE condition.
    /// </summary>
    protected WhereCondition GetCompleteWhereCondition()
    {
        var allRecords = UniSelector.US_ALL_RECORDS.ToString();

        var customWhere = ValidationHelper.GetString(GetValue("WhereCondition"), "");

        var where = new WhereCondition();

        // Do not select product options and select only enabled products
        where.WhereNull("SKUOptionCategoryID")
        .WhereTrue("SKUEnabled");

        // Get products only with specified public status
        if (!String.IsNullOrEmpty(ProductPublicStatusName) && (ProductPublicStatusName != allRecords))
        {
            var pStatusSiteID = ECommerceSettings.UseGlobalPublicStatus(SiteName) ? 0 : SiteInfoProvider.GetSiteID(SiteName);
            where.WhereEquals("SKUPublicStatusID",
                              new IDQuery <PublicStatusInfo>("PublicStatusID")
                              .WhereEquals("PublicStatusSiteID".AsColumn().IsNull(0), pStatusSiteID)
                              .WhereEquals("PublicStatusName", ProductPublicStatusName)
                              .TopN(1)
                              );
        }

        // Get products only with specified internal status
        if (!String.IsNullOrEmpty(ProductInternalStatusName) && (ProductInternalStatusName != allRecords))
        {
            var iStatusSiteID = ECommerceSettings.UseGlobalInternalStatus(SiteName) ? 0 : SiteInfoProvider.GetSiteID(SiteName);
            where.WhereEquals("SKUInternalStatusID",
                              new IDQuery <InternalStatusInfo>("InternalStatusID")
                              .WhereEquals("InternalStatusSiteID".AsColumn().IsNull(0), iStatusSiteID)
                              .WhereEquals("InternalStatusName", ProductInternalStatusName)
                              .TopN(1)
                              );
        }

        // Get products only from specified department
        if (!String.IsNullOrEmpty(ProductDepartmentName) && (ProductDepartmentName != allRecords))
        {
            var dept = DepartmentInfoProvider.GetDepartmentInfo(ProductDepartmentName, SiteName);

            var departmentID = (dept != null) ? dept.DepartmentID : 0;
            where.WhereEquals("SKUDepartmentID", departmentID);
        }

        // Include user custom WHERE condition
        if (customWhere.Trim() != "")
        {
            where.Where(customWhere);
        }

        return(where);
    }
    /// <summary>
    /// Checks department permissions in case option category should be assigned to the product
    /// </summary>
    protected void editOptionCategory_OnCheckPermissions(object sender, EventArgs e)
    {
        // Check department permission for product
        if (ParentProduct != null && !ECommerceContext.IsUserAuthorizedForDepartment(ParentProduct.SKUDepartmentID))
        {
            var departmentName = DepartmentInfoProvider.GetDepartmentInfo(ParentProduct.SKUDepartmentID).DepartmentDisplayName;

            RedirectToAccessDenied(string.Format(GetString("cmsdesk.notauthorizedtperdepartment"), departmentName));
        }
        // Raise also this control permission check
        RaiseOnCheckPermissions(string.Empty, this);
    }
示例#14
0
    /// <summary>
    /// Sets data to database.
    /// </summary>
    protected void btnOK_Click(object sender, EventArgs e)
    {
        // Check permissions
        CheckConfigurationModification(ConfiguredSiteID);

        // Check input values from textboxes and other controls
        string errorMessage = new Validator()
                              .NotEmpty(txtDepartmentDisplayName.Text.Trim(), GetString("Department_Edit.errorEmptyDisplayName"))
                              .NotEmpty(txtDepartmentName.Text.Trim(), GetString("Department_Edit.errorEmptyCodeName")).Result;

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

        if (errorMessage == "")
        {
            // DepartmentName must be unique
            DepartmentInfo departmentObj = null;
            string         siteWhere     = (ConfiguredSiteID > 0) ? " AND (DepartmentSiteID = " + ConfiguredSiteID + " OR DepartmentSiteID IS NULL)" : "";
            DataSet        ds            = DepartmentInfoProvider.GetDepartments("DepartmentName = '" + txtDepartmentName.Text.Trim().Replace("'", "''") + "'" + siteWhere, null, 1, null);
            if (!DataHelper.DataSourceIsEmpty(ds))
            {
                departmentObj = new DepartmentInfo(ds.Tables[0].Rows[0]);
            }

            // If departmentName value is unique
            if ((departmentObj == null) || (departmentObj.DepartmentID == mDepartmentId))
            {
                departmentObj = new DepartmentInfo();

                departmentObj.DepartmentID          = mDepartmentId;
                departmentObj.DepartmentName        = txtDepartmentName.Text.Trim();
                departmentObj.DepartmentDisplayName = txtDepartmentDisplayName.Text.Trim();
                departmentObj.DepartmentSiteID      = ConfiguredSiteID;

                DepartmentInfoProvider.SetDepartmentInfo(departmentObj);

                URLHelper.Redirect("Department_Frameset.aspx?departmentId=" + Convert.ToString(departmentObj.DepartmentID) + "&saved=1&siteId=" + SiteID);
            }
            else
            {
                lblError.Visible = true;
                lblError.Text    = GetString("Department_Edit.DepartmentNameExists");
            }
        }
        else
        {
            lblError.Visible = true;
            lblError.Text    = errorMessage;
        }
    }
示例#15
0
    /// <summary>
    /// Gets object from the specified column of the department with specific ID.
    /// </summary>
    /// <param name="Id">Department ID</param>
    /// <param name="column">Column name</param>
    public static object GetDepartment(object Id, string column)
    {
        int id = ValidationHelper.GetInteger(Id, 0);

        if (id > 0 && !DataHelper.IsEmpty(column))
        {
            // Get department
            DepartmentInfo di = DepartmentInfoProvider.GetDepartmentInfo(id);

            return(GetColumnValue(di, column));
        }

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

        // Field validator error messages initialization
        rfvDisplayName.ErrorMessage = GetString("Department_Edit.errorEmptyDisplayName");
        rfvCodeName.ErrorMessage    = GetString("Department_Edit.errorEmptyCodeName");

        // Control initializations
        lblDepartmentName.Text        = GetString("Department_Edit.DepartmentNameLabel");
        lblDepartmentDisplayName.Text = GetString("Department_Edit.DepartmentDisplayNameLabel");

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

        // Show that the department was created or updated successfully
        if (QueryHelper.GetString("saved", "") == "1")
        {
            lblInfo.Visible = true;
            lblInfo.Text    = GetString("General.ChangesSaved");
        }

        // Get department id from querystring
        mDepartmentId = QueryHelper.GetInteger("departmentId", 0);
        mEditedSiteId = ConfiguredSiteID;
        if (mDepartmentId > 0)
        {
            DepartmentInfo departmentObj = DepartmentInfoProvider.GetDepartmentInfo(mDepartmentId);
            EditedObject = departmentObj;

            if (departmentObj != null)
            {
                mEditedSiteId = departmentObj.DepartmentSiteID;
                CheckEditedObjectSiteID(mEditedSiteId);

                // Fill editing form
                if (!RequestHelper.IsPostBack())
                {
                    LoadData(departmentObj);
                }
            }
        }
    }
示例#17
0
    /// <summary>
    /// Convert given department name to its ID for specified site.
    /// </summary>
    /// <param name="name">Name of the department to be converted.</param>
    /// <param name="siteName">Name of the site of the department.</param>
    protected override int GetID(string name, string siteName)
    {
        DepartmentInfo dept;

        if (ShowAllSites)
        {
            // Take any department
            dept = DepartmentInfoProvider.GetDepartments()
                   .TopN(1)
                   .WithCodeName(name)
                   .OrderByAscending("DepartmentSiteID");
        }
        else
        {
            dept = DepartmentInfoProvider.GetDepartmentInfo(name, siteName);
        }

        return((dept != null) ? dept.DepartmentID : 0);
    }
    /// <summary>
    /// Returns complete WHERE condition.
    /// </summary>
    protected string GetCompleteWhereCondition()
    {
        string allRecords = UniSelector.US_ALL_RECORDS.ToString();

        string customWhere = ValidationHelper.GetString(GetValue("WhereCondition"), "");

        string where = "";

        // Include user custom WHERE condition
        if (customWhere.Trim() != "")
        {
            where = "(" + customWhere + ") AND";
        }

        // Do not select product options and select only enabled products
        where += " (SKUOptionCategoryID IS NULL) AND (SKUEnabled = 1)";

        // Get products only with specified public status
        if (ProductPublicStatusName != allRecords)
        {
            int pStatusSiteID = ECommerceSettings.UseGlobalPublicStatus(SiteName) ? 0 : SiteInfoProvider.GetSiteID(SiteName);
            where += " AND (SKUPublicStatusID = (SELECT TOP 1 PublicStatusID FROM COM_PublicStatus WHERE ISNULL(PublicStatusSiteID, 0) = " + pStatusSiteID + " AND PublicStatusName = '" + SqlHelper.GetSafeQueryString(ProductPublicStatusName, false) + "'))";
        }

        // Get products only with specified internal status
        if (ProductInternalStatusName != allRecords)
        {
            int iStatusSiteID = ECommerceSettings.UseGlobalInternalStatus(SiteName) ? 0 : SiteInfoProvider.GetSiteID(SiteName);
            where += " AND (SKUInternalStatusID = (SELECT TOP 1 InternalStatusID FROM COM_InternalStatus WHERE ISNULL(InternalStatusSiteID, 0) = " + iStatusSiteID + " AND InternalStatusName = '" + SqlHelper.GetSafeQueryString(ProductInternalStatusName, false) + "'))";
        }

        // Get products only from specified department
        if (!string.IsNullOrEmpty(ProductDepartmentName) && (ProductDepartmentName != allRecords))
        {
            DepartmentInfo dept = DepartmentInfoProvider.GetDepartmentInfo(ProductDepartmentName, SiteName);

            int departmentID = (dept != null) ? dept.DepartmentID : 0;
            where += " AND (SKUDepartmentID = " + departmentID + ")";
        }

        return(where);
    }
示例#19
0
    private void TryInitByForm()
    {
        if ((Value != null) || (Form == null) || !Form.AdditionalData.ContainsKey("DataClassID"))
        {
            return;
        }

        var dataClassId = ValidationHelper.GetInteger(Form.AdditionalData["DataClassID"], 0);
        var dataClass   = DataClassInfoProvider.GetDataClassInfo(dataClassId);

        if (dataClass != null)
        {
            var department = DepartmentInfoProvider.GetDepartmentInfo(dataClass.ClassSKUDefaultDepartmentName, SiteInfoProvider.GetSiteName(SiteID));
            if (department == null)
            {
                return;
            }

            Value = (UseNameForSelection) ? dataClass.ClassSKUDefaultDepartmentName : department.DepartmentID.ToString();
        }
    }
    private void TryInitByForm()
    {
        if (Form == null)
        {
            return;
        }

        if (Form.Data.ContainsColumn("SKUSiteID"))
        {
            SiteID = ValidationHelper.GetInteger(Form.Data.GetValue("SKUSiteID"), 0);
        }

        if (Form.Data.ContainsColumn("SKUID"))
        {
            int skuid = ValidationHelper.GetInteger(Form.Data.GetValue("SKUID"), -1);
            EnsureSelectedItem = skuid != -1;
        }

        if (Form.AdditionalData.ContainsKey("DataClassID"))
        {
            var dataClassId = ValidationHelper.GetInteger(Form.AdditionalData["DataClassID"], 0);
            var dataClass   = DataClassInfoProvider.GetDataClass(dataClassId);
            if (dataClass != null)
            {
                if (UseDepartmentNameForSelection)
                {
                    Value = dataClass.ClassSKUDefaultDepartmentName;
                }
                else
                {
                    DepartmentInfo department = DepartmentInfoProvider.GetDepartmentInfo(dataClass.ClassSKUDefaultDepartmentName, SiteInfoProvider.GetSiteName(SiteID));
                    if (department != null)
                    {
                        Value = department.DepartmentID;
                    }
                }
            }
        }
    }
示例#21
0
    protected void Page_Load(object sender, EventArgs e)
    {
        departmentId = QueryHelper.GetInteger("departmentId", 0);

        CMSMasterPage master = (CMSMasterPage)this.CurrentMaster;

        string         currentDepartmentName = string.Empty;
        DepartmentInfo di = DepartmentInfoProvider.GetDepartmentInfo(departmentId);

        if (di != null)
        {
            editedSiteId = di.DepartmentSiteID;

            // Check site id
            CheckEditedObjectSiteID(editedSiteId);
            currentDepartmentName = ResHelper.LocalizeString(di.DepartmentDisplayName);
        }

        // initializes page title
        string[,] breadcrumbs = new string[2, 3];
        breadcrumbs[0, 0]     = GetString("Department_Edit.ItemListLink");
        breadcrumbs[0, 1]     = "~/CMSModules/Ecommerce/Pages/Tools/Configuration/Departments/Department_List.aspx?siteId=" + SiteID;
        breadcrumbs[0, 2]     = "configEdit";
        breadcrumbs[1, 0]     = FormatBreadcrumbObjectName(currentDepartmentName, editedSiteId);
        breadcrumbs[1, 1]     = "";
        breadcrumbs[1, 2]     = "";

        master.Title.Breadcrumbs = breadcrumbs;
        master.Title.TitleText   = GetString("Department_Edit.HeaderCaption");
        master.Title.TitleImage  = GetImageUrl("Objects/Ecommerce_Department/object.png");

        master.Title.HelpTopicName = "new_department";
        master.Title.HelpName      = "helpTopic";

        master.Tabs.ModuleName    = "CMS.Ecommerce";
        master.Tabs.ElementName   = "Configuration.Departments";
        master.Tabs.UrlTarget     = "content";
        master.Tabs.OnTabCreated += new UITabs.TabCreatedEventHandler(Tabs_OnTabCreated);
    }
示例#22
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (IsMultiStoreConfiguration)
        {
            CheckUIElementAccessHierarchical(ModuleName.ECOMMERCE, "Ecommerce.GlobalDepartments.Users");
        }
        else
        {
            CheckUIElementAccessHierarchical(ModuleName.ECOMMERCE, "Configuration.Departments.Users");
        }

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

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

                // Get the active users
                string where = "UserID IN (SELECT UserID FROM COM_UserDepartment WHERE DepartmentID = " + mDepartmentId + ")";
                var data = UserInfoProvider.GetUsers().Where(where).Columns("UserID");
                if (data.Any())
                {
                    mCurrentValues = TextHelper.Join(";", DataHelper.GetStringValues(data.Tables[0], "UserID"));
                }

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

        uniSelector.OnSelectionChanged += uniSelector_OnSelectionChanged;
        uniSelector.WhereCondition      = GetWhereCondition();
    }
示例#23
0
        protected void CreateProduct(Object sender, EventArgs e)
        {
            // Gets a department
            DepartmentInfo department = DepartmentInfoProvider.GetDepartmentInfo("AutoCreated", SiteContext.CurrentSiteName);

            // Creates a new product object
            SKUInfo newProduct = new SKUInfo();

            // Sets the product properties
            newProduct.SKUName    = "NewProduct" + newProduct.SKUID;
            newProduct.SKUPrice   = 120;
            newProduct.SKUEnabled = true;
            if (department != null)
            {
                newProduct.SKUDepartmentID = department.DepartmentID;
            }
            newProduct.SKUSiteID = SiteContext.CurrentSiteID;

            // Saves the product to the database
            // Note: Only creates the SKU object. You also need to create a connected product page to add the product to the site.
            SKUInfoProvider.SetSKUInfo(newProduct);
        }
示例#24
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!CMSContext.CurrentUser.IsAuthorizedPerUIElement("CMS.Ecommerce", "DiscountLevels.Departments"))
        {
            RedirectToCMSDeskUIElementAccessDenied("CMS.Ecommerce", "DiscountLevels.Departments");
        }

        lblAvialable.Text = GetString("com.discountlevel.departmentsavailable");
        mDiscountLevelId  = QueryHelper.GetInteger("discountLevelId", 0);
        editedSiteId      = ConfiguredSiteID;

        if (mDiscountLevelId > 0)
        {
            mDiscountLevelInfoObj = DiscountLevelInfoProvider.GetDiscountLevelInfo(mDiscountLevelId);
            EditedObject          = mDiscountLevelInfoObj;

            if (mDiscountLevelInfoObj != null)
            {
                editedSiteId = mDiscountLevelInfoObj.DiscountLevelSiteID;
                CheckEditedObjectSiteID(editedSiteId);

                // Get the active departments
                DataSet ds = DepartmentInfoProvider.GetDiscountLevelDepartments(mDiscountLevelId);
                if (!DataHelper.DataSourceIsEmpty(ds))
                {
                    mCurrentValues = TextHelper.Join(";", SqlHelperClass.GetStringValues(ds.Tables[0], "DepartmentID"));
                }

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

        this.uniSelector.IconPath            = GetObjectIconUrl("ecommerce.department", "object.png");
        this.uniSelector.OnSelectionChanged += uniSelector_OnSelectionChanged;
        this.uniSelector.WhereCondition      = GetWhereCondition();
    }
示例#25
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();
    }
示例#26
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Check permissions for CMS Desk -> Ecommerce
        if (!CMSContext.CurrentUser.IsAuthorizedPerUIElement("CMS.Ecommerce", "Configuration.Departments.Users"))
        {
            RedirectToCMSDeskUIElementAccessDenied("CMS.Ecommerce", "Configuration.Departments.Users");
        }

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

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

                // Get the active users
                string where = "UserID IN (SELECT UserID FROM COM_UserDepartment WHERE DepartmentID = " + mDepartmentId + ")";
                DataSet ds = UserInfoProvider.GetUsers(where, null, 0, "UserID");
                if (!DataHelper.DataSourceIsEmpty(ds))
                {
                    mCurrentValues = TextHelper.Join(";", SqlHelperClass.GetStringValues(ds.Tables[0], "UserID"));
                }

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

        this.uniSelector.IconPath            = GetObjectIconUrl("cms.user", "object.png");
        this.uniSelector.OnSelectionChanged += uniSelector_OnSelectionChanged;
        this.uniSelector.WhereCondition      = GetWhereCondition();
    }
示例#27
0
    private void TryInitByForm()
    {
        if ((Form == null) || !Form.AdditionalData.ContainsKey("DataClassID"))
        {
            return;
        }

        var dataClassId = ValidationHelper.GetInteger(Form.AdditionalData["DataClassID"], 0);
        var dataClass   = DataClassInfoProvider.GetDataClassInfo(dataClassId);

        if (dataClass != null)
        {
            DepartmentInfo department = DepartmentInfoProvider.GetDepartmentInfo(dataClass.ClassSKUDefaultDepartmentName, SiteInfoProvider.GetSiteName(SiteID));

            // Do not preselect department if user is not authorized for this department
            if ((department == null) || !ECommerceContext.IsUserAuthorizedForDepartment(department.DepartmentID))
            {
                return;
            }

            Value = (UseNameForSelection) ? dataClass.ClassSKUDefaultDepartmentName : department.DepartmentID.ToString();
        }
    }
    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();
    }
    /// <summary>
    /// Returns where condition based on webpart fields.
    /// </summary>
    private string GetWhereCondition()
    {
        string where = null;

        // Show products only from current site or global too, based on setting
        if (ECommerceSettings.AllowGlobalProducts(CMSContext.CurrentSiteName))
        {
            where = "(SKUSiteID = " + CMSContext.CurrentSiteID + ") OR (SKUSiteID IS NULL)";
        }
        else
        {
            where = "SKUSiteID = " + CMSContext.CurrentSiteID;
        }

        // Product type filter
        if (!string.IsNullOrEmpty(ProductType) && (ProductType != FILTER_ALL))
        {
            if (ProductType == PRODUCT_TYPE_PRODUCTS)
            {
                where = SqlHelperClass.AddWhereCondition(where, "SKUOptionCategoryID IS NULL");
            }
            else if (ProductType == PRODUCT_TYPE_PRODUCT_OPTIONS)
            {
                where = SqlHelperClass.AddWhereCondition(where, "SKUOptionCategoryID IS NOT NULL");
            }
        }

        // Representing filter
        if (!string.IsNullOrEmpty(Representing) && (Representing != FILTER_ALL))
        {
            SKUProductTypeEnum productTypeEnum   = SKUInfoProvider.GetSKUProductTypeEnum(Representing);
            string             productTypeString = SKUInfoProvider.GetSKUProductTypeString(productTypeEnum);

            where = SqlHelperClass.AddWhereCondition(where, "SKUProductType = N'" + productTypeString + "'");
        }

        // Product number filter
        if (!string.IsNullOrEmpty(ProductNumber))
        {
            string safeProductNumber = SqlHelperClass.GetSafeQueryString(ProductNumber, true);
            where = SqlHelperClass.AddWhereCondition(where, "SKUNumber LIKE N'%" + safeProductNumber + "%'");
        }

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

        if (di != null)
        {
            where = SqlHelperClass.AddWhereCondition(where, "SKUDepartmentID = " + di.DepartmentID);
        }

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

        if (mi != null)
        {
            where = SqlHelperClass.AddWhereCondition(where, "SKUManufacturerID = " + mi.ManufacturerID);
        }

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

        if (si != null)
        {
            where = SqlHelperClass.AddWhereCondition(where, "SKUSupplierID = " + si.SupplierID);
        }

        // Needs shipping filter
        if (!string.IsNullOrEmpty(NeedsShipping) && (NeedsShipping != FILTER_ALL))
        {
            if (NeedsShipping == NEEDS_SHIPPING_YES)
            {
                where = SqlHelperClass.AddWhereCondition(where, "SKUNeedsShipping = 1");
            }
            else if (NeedsShipping == NEEDS_SHIPPING_NO)
            {
                where = SqlHelperClass.AddWhereCondition(where, "(SKUNeedsShipping = 0) OR (SKUNeedsShipping IS NULL)");
            }
        }

        // Price from filter
        if (PriceFrom > 0)
        {
            where = SqlHelperClass.AddWhereCondition(where, "SKUPrice >= " + PriceFrom);
        }

        // Price to filter
        if (PriceTo > 0)
        {
            where = SqlHelperClass.AddWhereCondition(where, "SKUPrice <= " + PriceTo);
        }

        // Public status filter
        PublicStatusInfo psi = PublicStatusInfoProvider.GetPublicStatusInfo(PublicStatus, CurrentSiteName);

        if (psi != null)
        {
            where = SqlHelperClass.AddWhereCondition(where, "SKUPublicStatusID = " + psi.PublicStatusID);
        }

        // Internal status filter
        InternalStatusInfo isi = InternalStatusInfoProvider.GetInternalStatusInfo(InternalStatus, CurrentSiteName);

        if (isi != null)
        {
            where = SqlHelperClass.AddWhereCondition(where, "SKUInternalStatusID = " + isi.InternalStatusID);
        }

        // Allow for sale filter
        if (!string.IsNullOrEmpty(AllowForSale) && (AllowForSale != FILTER_ALL))
        {
            if (AllowForSale == ALLOW_FOR_SALE_YES)
            {
                where = SqlHelperClass.AddWhereCondition(where, "SKUEnabled = 1");
            }
            else if (AllowForSale == ALLOW_FOR_SALE_NO)
            {
                where = SqlHelperClass.AddWhereCondition(where, "(SKUEnabled = 0) OR (SKUEnabled IS NULL)");
            }
        }

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

        // Needs to be reordered filter
        if (NeedsToBeReordered)
        {
            where = SqlHelperClass.AddWhereCondition(where, "((SKUReorderAt IS NULL) AND (SKUAvailableItems <= 0)) OR ((SKUReorderAt IS NOT NULL) AND (SKUAvailableItems <= SKUReorderAt))");
        }

        return(where);
    }
    private object gridElem_OnExternalDataBound(object sender, string sourceName, object parameter)
    {
        DataRowView row = parameter as DataRowView;

        switch (sourceName.ToLowerCSafe())
        {
        case "optioncategory":
            int optionCategoryId = ValidationHelper.GetInteger(row["SKUOptionCategoryID"], 0);
            OptionCategoryInfo optionCategory = OptionCategoryInfoProvider.GetOptionCategoryInfo(optionCategoryId);

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

        case "skunumber":
            string skuNumber = ValidationHelper.GetString(row["SKUNumber"], null);
            return(HTMLHelper.HTMLEncode(skuNumber ?? ""));

        case "skuprice":
            double value  = ValidationHelper.GetDouble(row["SKUPrice"], 0);
            int    siteId = ValidationHelper.GetInteger(row["SKUSiteID"], 0);

            // Format price
            return(CurrencyInfoProvider.GetFormattedPrice(value, siteId));

        case "skudepartmentid":
            // Tranform to display name and localize
            int            departmentId = ValidationHelper.GetInteger(row["SKUDepartmentID"], 0);
            DepartmentInfo department   = DepartmentInfoProvider.GetDepartmentInfo(departmentId);

            return((department != null) ? HTMLHelper.HTMLEncode(ResHelper.LocalizeString(department.DepartmentDisplayName)) : "");

        case "skumanufacturerid":
            // Tranform to display name and localize
            int manufacturerId            = ValidationHelper.GetInteger(row["SKUManufacturerID"], 0);
            ManufacturerInfo manufacturer = ManufacturerInfoProvider.GetManufacturerInfo(manufacturerId);

            return((manufacturer != null) ? HTMLHelper.HTMLEncode(ResHelper.LocalizeString(manufacturer.ManufacturerDisplayName)) : "");

        case "skusupplierid":
            // Tranform to display name and localize
            int          supplierId = ValidationHelper.GetInteger(row["SKUSupplierID"], 0);
            SupplierInfo supplier   = SupplierInfoProvider.GetSupplierInfo(supplierId);

            return((supplier != null) ? HTMLHelper.HTMLEncode(ResHelper.LocalizeString(supplier.SupplierDisplayName)) : "");

        case "skuavailableitems":
            int?count     = row["SKUAvailableItems"] as int?;
            int?reorderAt = row["SKUReorderAt"] as int?;

            // Emphasise 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
                string reorderMsg = string.Format(GetString("com.sku.reorderatTooltip"), reorderAt);
                return(string.Format("<span class=\"OperationFailed\">{0}</span>", count));
            }
            return(count);

        case "itemstobereordered":
            int skuReorderAt      = ValidationHelper.GetInteger(row["SKUReorderAt"], 0);
            int skuAvailableItems = ValidationHelper.GetInteger(row["SKUAvailableItems"], 0);
            int difference        = skuReorderAt - skuAvailableItems;

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

        case "skusiteid":
            return(UniGridFunctions.ColoredSpanYesNo(row["SKUSiteID"] == DBNull.Value));
        }

        return(parameter);
    }