Exemple #1
0
    protected void BtnSave_Click(object sender, EventArgs e)
    {
        LblErr.Text = "";
        LblOk.Text = "";

        try
        {
            var o1 = new AttributeSet();
            var man = new AttributeSetsManager();
            if (base.CurrentId == 0)
            {
                form2obj(o1);
                o1 = man.Insert(o1);
            }
            else
            {
                o1 = man.GetByKey(base.CurrentId);  //precarico i campi esistenti e nn gestiti dal form
                form2obj(o1);
                man.Update(o1);
            }
            Grid1.DataBind();
            Grid2.DataBind();
            LblOk.Text = RenderSuccess(Utility.GetLabel("RECORD_SAVED_MSG"));
            MultiView1.ActiveViewIndex = 0;
        }
        catch (Exception e1)
        {
            LblErr.Text = RenderError(Utility.GetLabel("RECORD_ERR_MSG") + "<br />" + e1.ToString());
        }
        finally
        {
        }
    }
Exemple #2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        int.TryParse(Request["productId"], out ProductId);
        var man = new AttributeSetsManager();
        var parentsAttributes = new List<int>();
        var parentsAttributesValues = new List<int>();

        var prodProv = new PigeonCms.Shop.ProductsProvider.CurrentProduct<ProductItem, ProductItemsManager, ProductItemFilter>(ProductId);

        PanelDropVariants.Attributes.Add("data-product-id", ProductId.ToString());

        // variants
        for (int i = 0; i < prodProv.Product.Attributes.Count; i++)
        {
            DropDownList d = new DropDownList();
            d.ID = "DropDown" + prodProv.Product.Attributes[i].Name;
            d.ClientIDMode = System.Web.UI.ClientIDMode.Static;
            d.Attributes.Add("data-select-id", prodProv.Product.Attributes[i].Id.ToString());
            if (i == 0)
            {
                d.Attributes.Add("data-select-parent", "");
                foreach (var v in prodProv.GetDefaultAttribute())
                {
                    d.Items.Add(new ListItem(v.Value, v.Id.ToString()));
                }
            }
            else
            {
                parentsAttributes.Add(prodProv.Product.Attributes[i - 1].Id);
                parentsAttributesValues.Add(prodProv.Product.AttributeValues[i - 1].Id);
                d.Attributes.Add("data-select-parent", string.Join(",", parentsAttributes.Select(parent => parent.ToString()).ToArray()));
                foreach (var v in prodProv.GetNextAttribute(parentsAttributesValues))
                {
                    d.Items.Add(new ListItem(v.Value, v.Id.ToString()));
                }
            }

            if (i == prodProv.Product.Attributes.Count - 1)
            {
                d.Attributes.Add("data-last", "");
            }

            var selected = prodProv.Product.AttributeValues.Find(x => x.AttributeId == prodProv.Product.Attributes[i].Id);
            d.SelectedValue = selected.Id.ToString();

            PanelDropVariants.Controls.Add(d);
        }

        LitTitle.Text = prodProv.Product.Title;
        LitDescription.Text = prodProv.Product.Description;
        LitRegPrice.Text = prodProv.Product.RegularPrice.ToString("C");
        LitSalePrice.Text = prodProv.Product.SalePrice.ToString("C");
    }
Exemple #3
0
 private void deleteRow(int recordId)
 {
     LblOk.Text = "";
     LblErr.Text = "";
     var man = new AttributeSetsManager();
     try
     {
         man.DeleteById(recordId);
     }
     catch (Exception e)
     {
         LblErr.Text = RenderError(e.Message);
     }
     Grid1.DataBind();
 }
Exemple #4
0
    private void editRow(int recordId)
    {
        LblOk.Text = "";
        LblErr.Text = "";

        clearForm();
        base.CurrentId = recordId;
        var man = new AttributeSetsManager();
        if (base.CurrentId > 0)
        {
            var obj = new AttributeSet();
            obj = man.GetByKey(base.CurrentId);
            obj2form(obj);
        }
        MultiView1.ActiveViewIndex = 1;
    }
Exemple #5
0
 protected void ObjDs1_ObjectCreating(object sender, ObjectDataSourceEventArgs e)
 {
     var typename = new AttributeSetsManager();
     e.ObjectInstance = typename;
 }