Ejemplo n.º 1
0
    /// <summary>
    /// Gets object from the specified column of the internal status with specific ID.
    /// </summary>
    /// <param name="Id">Internal status ID</param>
    /// <param name="column">Column name</param>
    public static object GetInternalStatus(object Id, string column)
    {
        int id = ValidationHelper.GetInteger(Id, 0);

        if ((id > 0) && !DataHelper.IsEmpty(column))
        {
            // Get internal status
            InternalStatusInfo isi = InternalStatusInfoProvider.GetInternalStatusInfo(id);

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

        return("");
    }
Ejemplo n.º 2
0
    /// <summary>
    /// Sets data to database.
    /// </summary>
    protected void btnOK_Click(object sender, EventArgs e)
    {
        CheckConfigurationModification();

        string errorMessage = new Validator()
            .NotEmpty(txtInternalStatusDisplayName.Text.Trim(), GetString("InternalStatus_Edit.errorDisplayName"))
            .NotEmpty(txtInternalStatusName.Text.Trim(), GetString("InternalStatus_Edit.errorCodeName")).Result;

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

        if (errorMessage == "")
        {

            // Check unique name for configured site
            DataSet ds = InternalStatusInfoProvider.GetInternalStatuses("InternalStatusName = '" + txtInternalStatusName.Text.Trim().Replace("'", "''") + "' AND ISNULL(InternalStatusSiteID, 0) = " + ConfiguredSiteID, null);
            InternalStatusInfo internalStatusObj = null;
            if (!DataHelper.DataSourceIsEmpty(ds))
            {
                internalStatusObj = new InternalStatusInfo(ds.Tables[0].Rows[0]);
            }

            // if internalStatusName value is unique
            if ((internalStatusObj == null) || (internalStatusObj.InternalStatusID == mStatusid))
            {
                // if internalStatusName value is unique -> determine whether it is update or insert
                if ((internalStatusObj == null))
                {
                    // get InternalStatusInfo object by primary key
                    internalStatusObj = InternalStatusInfoProvider.GetInternalStatusInfo(mStatusid);
                    if (internalStatusObj == null)
                    {
                        // create new item -> insert
                        internalStatusObj = new InternalStatusInfo();
                        internalStatusObj.InternalStatusSiteID = ConfiguredSiteID;
                    }
                }

                internalStatusObj.InternalStatusEnabled = chkInternalStatusEnabled.Checked;
                internalStatusObj.InternalStatusName = txtInternalStatusName.Text.Trim();
                internalStatusObj.InternalStatusDisplayName = txtInternalStatusDisplayName.Text.Trim();

                InternalStatusInfoProvider.SetInternalStatusInfo(internalStatusObj);

                URLHelper.Redirect("InternalStatus_Edit.aspx?statusid=" + Convert.ToString(internalStatusObj.InternalStatusID) + "&saved=1&siteId=" + SiteID);
            }
            else
            {
                lblError.Visible = true;
                lblError.Text = GetString("InternalStatus_Edit.InternalStatusNameExists");
            }
        }
        else
        {
            lblError.Visible = true;
            lblError.Text = errorMessage;
        }
    }
Ejemplo n.º 3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        rfvCodeName.ErrorMessage    = GetString("InternalStatus_Edit.errorCodeName");
        rfvDisplayName.ErrorMessage = GetString("InternalStatus_Edit.errorDisplayName");

        // control initializations
        lblInternalStatusName.Text        = GetString("InternalStatus_Edit.InternalStatusNameLabel");
        lblInternalStatusDisplayName.Text = GetString("InternalStatus_Edit.InternalStatusDisplayNameLabel");

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

        string currentInternalStatus = GetString("InternalStatus_Edit.NewItemCaption");

        // get internalStatus id from querystring
        mStatusid = QueryHelper.GetInteger("statusid", 0);
        if (mStatusid > 0)
        {
            InternalStatusInfo internalStatusObj = InternalStatusInfoProvider.GetInternalStatusInfo(mStatusid);
            EditedObject = internalStatusObj;

            if (internalStatusObj != null)
            {
                CheckEditedObjectSiteID(internalStatusObj.InternalStatusSiteID);
                currentInternalStatus = internalStatusObj.InternalStatusDisplayName;

                // fill editing form
                if (!RequestHelper.IsPostBack())
                {
                    LoadData(internalStatusObj);

                    // show that the internalStatus was created or updated successfully
                    if (QueryHelper.GetString("saved", "") == "1")
                    {
                        lblInfo.Visible = true;
                        lblInfo.Text    = GetString("General.ChangesSaved");
                    }
                }
            }
            this.CurrentMaster.Title.TitleText  = GetString("InternalStatus_Edit.HeaderCaption");
            this.CurrentMaster.Title.TitleImage = GetImageUrl("Objects/Ecommerce_InternalStatus/object.png");
        }
        else
        {
            this.CurrentMaster.Title.TitleText  = GetString("InternalStatus_New.HeaderCaption");
            this.CurrentMaster.Title.TitleImage = GetImageUrl("Objects/Ecommerce_InternalStatus/new.png");
        }

        this.CurrentMaster.Title.HelpTopicName = "newedit_internal_status";
        this.CurrentMaster.Title.HelpName      = "helpTopic";

        // Initializes page title breadcrumbs control
        string[,] pageTitleTabs = new string[2, 3];
        pageTitleTabs[0, 0]     = GetString("InternalStatus_Edit.ItemListLink");
        pageTitleTabs[0, 1]     = "~/CMSModules/Ecommerce/Pages/Tools/Configuration/InternalStatus/InternalStatus_List.aspx?siteId=" + SiteID;
        pageTitleTabs[0, 2]     = "";
        pageTitleTabs[1, 0]     = currentInternalStatus;
        pageTitleTabs[1, 1]     = "";
        pageTitleTabs[1, 2]     = "";
        this.CurrentMaster.Title.Breadcrumbs = pageTitleTabs;
    }
    /// <summary>
    /// Sets data to database.
    /// </summary>
    protected void btnOK_Click(object sender, EventArgs e)
    {
        CheckConfigurationModification();

        string errorMessage = new Validator()
                              .NotEmpty(txtInternalStatusDisplayName.Text.Trim(), GetString("InternalStatus_Edit.errorDisplayName"))
                              .NotEmpty(txtInternalStatusName.Text.Trim(), GetString("InternalStatus_Edit.errorCodeName")).Result;

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

        if (errorMessage == "")
        {
            // Check unique name for configured site
            DataSet            ds = InternalStatusInfoProvider.GetInternalStatuses("InternalStatusName = '" + txtInternalStatusName.Text.Trim().Replace("'", "''") + "' AND ISNULL(InternalStatusSiteID, 0) = " + ConfiguredSiteID, null);
            InternalStatusInfo internalStatusObj = null;
            if (!DataHelper.DataSourceIsEmpty(ds))
            {
                internalStatusObj = new InternalStatusInfo(ds.Tables[0].Rows[0]);
            }

            // if internalStatusName value is unique
            if ((internalStatusObj == null) || (internalStatusObj.InternalStatusID == mStatusId))
            {
                // if internalStatusName value is unique -> determine whether it is update or insert
                if ((internalStatusObj == null))
                {
                    // get InternalStatusInfo object by primary key
                    internalStatusObj = InternalStatusInfoProvider.GetInternalStatusInfo(mStatusId);
                    if (internalStatusObj == null)
                    {
                        // create new item -> insert
                        internalStatusObj = new InternalStatusInfo();
                        internalStatusObj.InternalStatusSiteID = ConfiguredSiteID;
                    }
                }

                internalStatusObj.InternalStatusEnabled     = chkInternalStatusEnabled.Checked;
                internalStatusObj.InternalStatusName        = txtInternalStatusName.Text.Trim();
                internalStatusObj.InternalStatusDisplayName = txtInternalStatusDisplayName.Text.Trim();

                InternalStatusInfoProvider.SetInternalStatusInfo(internalStatusObj);

                URLHelper.Redirect("InternalStatus_Edit.aspx?statusid=" + Convert.ToString(internalStatusObj.InternalStatusID) + "&saved=1&siteId=" + SiteID);
            }
            else
            {
                // Show error message
                ShowError(GetString("InternalStatus_Edit.InternalStatusNameExists"));
            }
        }
        else
        {
            // Show error message
            ShowError(errorMessage);
        }
    }
Ejemplo n.º 5
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Check if not editing object from another site
        InternalStatusInfo internalStatusObj = EditedObject as InternalStatusInfo;

        if ((internalStatusObj != null) && (internalStatusObj.InternalStatusID > 0))
        {
            CheckEditedObjectSiteID(internalStatusObj.InternalStatusSiteID);
        }

        // Register check permissions
        EditForm.OnCheckPermissions += (s, args) => CheckConfigurationModification();
    }
Ejemplo n.º 6
0
    /// <summary>
    /// Gets object from the specified column of the internal status with specific ID.
    /// </summary>
    /// <param name="Id">Internal status ID</param>
    /// <param name="column">Column name</param>
    public static object GetInternalStatus(object Id, string column)
    {
        int id = ValidationHelper.GetInteger(Id, 0);

        if ((id > 0) && !DataHelper.IsEmpty(column))
        {
            // Get internal status
            InternalStatusInfo status = InternalStatusInfoProvider.GetInternalStatusInfo(id);

            return(GetColumnValue(status, column));
        }

        return("");
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        rfvCodeName.ErrorMessage    = GetString("InternalStatus_Edit.errorCodeName");
        rfvDisplayName.ErrorMessage = GetString("InternalStatus_Edit.errorDisplayName");

        // Control initializations
        lblInternalStatusName.Text        = GetString("InternalStatus_Edit.InternalStatusNameLabel");
        lblInternalStatusDisplayName.Text = GetString("InternalStatus_Edit.InternalStatusDisplayNameLabel");

        string currentInternalStatus = GetString("InternalStatus_Edit.NewItemCaption");

        // Get internalStatus id from querystring
        mStatusId = QueryHelper.GetInteger("statusid", 0);
        if (mStatusId > 0)
        {
            InternalStatusInfo internalStatusObj = EditedObject as InternalStatusInfo;

            if (internalStatusObj != null)
            {
                CheckEditedObjectSiteID(internalStatusObj.InternalStatusSiteID);
                currentInternalStatus = internalStatusObj.InternalStatusDisplayName;

                // fill editing form
                if (!RequestHelper.IsPostBack())
                {
                    LoadData(internalStatusObj);

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

        // Initializes page title breadcrumbs control
        string[,] pageTitleTabs         = new string[2, 3];
        pageTitleTabs[0, 0]             = GetString("InternalStatus_Edit.ItemListLink");
        pageTitleTabs[0, 1]             = "~/CMSModules/Ecommerce/Pages/Tools/Configuration/InternalStatus/InternalStatus_List.aspx?siteId=" + SiteID;
        pageTitleTabs[0, 2]             = "";
        pageTitleTabs[1, 0]             = currentInternalStatus;
        pageTitleTabs[1, 1]             = "";
        pageTitleTabs[1, 2]             = "";
        CurrentMaster.Title.Breadcrumbs = pageTitleTabs;
    }
Ejemplo n.º 8
0
    /// <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);
    }
    /// <summary>
    /// Gets and bulk updates internal statuses. Called when the "Get and bulk update statuses" button is pressed.
    /// Expects the CreateInternalStatus method to be run first.
    /// </summary>
    private bool GetAndBulkUpdateInternalStatuses()
    {
        // Prepare the parameters
        string where = "InternalStatusName LIKE N'MyNewStatus%'";
        where = SqlHelperClass.AddWhereCondition(where, "InternalStatusSiteID = " + CMSContext.CurrentSiteID, "AND");

        // Get the data
        DataSet statuses = InternalStatusInfoProvider.GetInternalStatuses(where, null, 0, null);
        if (!DataHelper.DataSourceIsEmpty(statuses))
        {
            // Loop through the individual items
            foreach (DataRow statusDr in statuses.Tables[0].Rows)
            {
                // Create object from DataRow
                InternalStatusInfo modifyStatus = new InternalStatusInfo(statusDr);

                // Update the properties
                modifyStatus.InternalStatusDisplayName = modifyStatus.InternalStatusDisplayName.ToUpper();

                // Update the internal status
                InternalStatusInfoProvider.SetInternalStatusInfo(modifyStatus);
            }

            return true;
        }

        return false;
    }
Ejemplo n.º 10
0
    /// <summary>
    /// Creates internal status. Called when the "Create status" button is pressed.
    /// </summary>
    private bool CreateInternalStatus()
    {
        // Create new internal status object
        InternalStatusInfo newStatus = new InternalStatusInfo();

        // Set the properties
        newStatus.InternalStatusDisplayName = "My new status";
        newStatus.InternalStatusName = "MyNewStatus";
        newStatus.InternalStatusEnabled = true;
        newStatus.InternalStatusSiteID = CMSContext.CurrentSiteID;

        // Create the internal status
        InternalStatusInfoProvider.SetInternalStatusInfo(newStatus);

        return true;
    }
    /// <summary>
    /// Convert given status name to its ID for specified site.
    /// </summary>
    /// <param name="name">Code name of the internal status to be converted.</param>
    /// <param name="siteName">Name of the site to translate code name for.</param>
    protected override int GetID(string name, string siteName)
    {
        InternalStatusInfo status = InternalStatusInfoProvider.GetInternalStatusInfo(name, siteName);

        return((status != null) ? status.InternalStatusID : 0);
    }
 /// <summary>
 /// Load data of editing internalStatus.
 /// </summary>
 /// <param name="internalStatusObj">InternalStatus object</param>
 protected void LoadData(InternalStatusInfo internalStatusObj)
 {
     chkInternalStatusEnabled.Checked = internalStatusObj.InternalStatusEnabled;
     txtInternalStatusName.Text = internalStatusObj.InternalStatusName;
     txtInternalStatusDisplayName.Text = internalStatusObj.InternalStatusDisplayName;
 }
Ejemplo n.º 13
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)));
        }

        // 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);
    }
Ejemplo n.º 14
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 "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);
    }
Ejemplo n.º 15
0
    /// <summary>
    /// Returns where condition based on webpart fields.
    /// </summary>
    private string GetWhereCondition()
    {
        string where = "SKUSiteID = " + SiteContext.CurrentSiteID;

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

        // Show/hide product variants - it is based on type of inventory tracking for parent product
        string trackByVariants = TrackInventoryTypeEnum.ByVariants.ToStringRepresentation();
        string parentSkuWhere  = "(SKUParentSKUID IS NULL) AND (SKUTrackInventory != '" + trackByVariants + "')";
        string variantWhere    = GetParentProductWhereCondition("SKUTrackInventory = '" + trackByVariants + "'");

        where = SqlHelper.AddWhereCondition(where, string.Format("({0}) OR ({1})", parentSkuWhere, variantWhere));

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

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

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

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

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

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

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

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

        mi = mi ?? ManufacturerInfoProvider.GetManufacturerInfo(Manufacturer, null);
        if (mi != null)
        {
            where = SqlHelper.AddWhereCondition(where, GetColumnWhereCondition("SKUManufacturerID", "SKUManufacturerID = " + mi.ManufacturerID));
        }

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

        si = si ?? SupplierInfoProvider.GetSupplierInfo(Supplier, null);
        if (si != null)
        {
            where = SqlHelper.AddWhereCondition(where, GetColumnWhereCondition("SKUSupplierID", "SKUSupplierID = " + si.SupplierID));
        }

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

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

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

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

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

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

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

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

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

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

        return(where);
    }
 /// <summary>
 /// Load data of editing internalStatus.
 /// </summary>
 /// <param name="internalStatusObj">InternalStatus object</param>
 protected void LoadData(InternalStatusInfo internalStatusObj)
 {
     chkInternalStatusEnabled.Checked  = internalStatusObj.InternalStatusEnabled;
     txtInternalStatusName.Text        = internalStatusObj.InternalStatusName;
     txtInternalStatusDisplayName.Text = internalStatusObj.InternalStatusDisplayName;
 }