Ejemplo n.º 1
0
    private void deleteValue(int recordId)
    {
        LblOk.Text = "";
        LblErr.Text = "";

        try
        {
            // have to check if is used by some products
            var ifilter = new ItemAttributeValueFilter();
            var iman = new ItemAttributesValuesManager();
            var vman = new AttributeValuesManager();
            ifilter.AttributeValueId = recordId;
            bool isUsed = (iman.GetByFilter(ifilter, "").Count > 0);
            if (!isUsed)
            {
                vman.DeleteById(recordId);
            }
            else
            {
                LblErr.Text = RenderError("value assigned to a product. delete the product before the attribute.");
            }
        }
        catch (Exception e)
        {
            LblErr.Text = RenderError(e.Message);
        }
        GridValues.DataBind();
    }
Ejemplo n.º 2
0
    private bool checkQuickAdd()
    {
        LblErr.Text = RenderError("");
        LblOk.Text = RenderSuccess("");
        bool res = true;
        string err = "";
        var pfilter = new ProductItemFilter();
        var filter = new ItemAttributeValueFilter();
        pfilter.ThreadId = CurrentId;
        pfilter.ShowOnlyRootItems = false;
        var pChilds = new ProductItemsManager(true, true).GetByFilter(pfilter, "");
        foreach (var pChild in pChilds)
        {
            int pId = pChild.Id;
            filter.ItemId = pId;
            var values = man.GetByFilter(filter, "");
            int foundIn = 0,
                presentAttributes = 0;

            // QUI salvo gli attributi quick edit

            foreach (var attribute in attributes)
            {
                if (!attribute.AllowCustomValue)
                {
                    DropDownList d1 = new DropDownList();
                    d1 = (DropDownList)PanelAttributes.FindControl("DropAttributeValuesQuick" + attribute.Name);
                    int attributeValueId = 0;
                    int.TryParse(d1.SelectedValue, out attributeValueId);
                    if (attributeValueId > 0)
                    {
                        presentAttributes++;
                        var exist = values.Exists(x => x.AttributeId == attribute.Id && x.AttributeValueId == attributeValueId);
                        if (exist)
                        {
                            foundIn++;
                        }
                    }
                }
            }
            if (foundIn == presentAttributes)
            {
                res = false;
                err += "Existing variant<br />";
            }
        }
        LblErr.Text = RenderError(err);
        return res;
    }