Esempio n. 1
0
    protected void gvItems_DataBinding(object sender, EventArgs e)
    {
        string    type     = Request["type"];
        TermTypes termType = TermTypes.Category;

        if (!String.IsNullOrEmpty(type))
        {
            termType = BSTerm.GetTermType(type);
        }

        List <BSTerm> categories = BSTerm.GetTermsBySubID(termType, 0);
        List <string> lstNames   = new List <string>();

        for (int i = 0; i < categories.Count; i++)
        {
            string strParents = string.Empty;
            BSTerm category   = categories[i];

            while (category.SubID != 0)
            {
                BSTerm subCategory = BSTerm.GetTerm(category.SubID);
                strParents = subCategory.Name + " > " + strParents;
            }
            lstNames.Add(strParents + category.Name);
        }

        ((GridView)sender).DataSource = categories;
        if (!IsPostBack)
        {
            ddlParentCategory.Items.Insert(0, new ListItem(Language.Admin["None"], "0"));
        }
    }
Esempio n. 2
0
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        if (txtName.Text.Trim() != "")
        {
            BSTerm bsTerm = new BSTerm();
            bsTerm.Name        = txtName.Text;
            bsTerm.Description = txtDescription.Text;
            bsTerm.Type        = BSTerm.GetTermType(CategoryType);
            bsTerm.Code        = BSHelper.CreateCode(bsTerm.Name);

            bsTerm.SubID = int.Parse(ddlParentCategory.SelectedValue);

            if (bsTerm.Save())
            {
                MessageBox1.Message = Language.Admin["CategorySaved"];
                MessageBox1.Type    = MessageBox.ShowType.Information;
                gvItems.DataBind();
                txtName.Text        = string.Empty;
                txtDescription.Text = string.Empty;
            }
            else
            {
                MessageBox1.Message = Language.Admin["CategoryError"];
            }
        }
    }