protected void btnDelete_Click(object sender, EventArgs e)
    {
        bool bRemoved = false;

        for (int i = 0; i < gvItems.Rows.Count; i++)
        {
            CheckBox cb = gvItems.Rows[i].FindControl("cb") as CheckBox;
            if (cb.Checked)
            {
                Literal literal = gvItems.Rows[i].FindControl("TermID") as Literal;
                if (literal != null)
                {
                    int iTermID = 0;
                    int.TryParse(literal.Text, out iTermID);

                    BSTerm bsTerm = BSTerm.GetTerm(iTermID);
                    if (bsTerm != null)
                    {
                        bRemoved = bsTerm.Remove();
                    }
                }
            }
        }
        if (bRemoved)
        {
            MessageBox1.Message = Language.Admin["TagDeleted"];
            MessageBox1.Type    = MessageBox.ShowType.Information;
            MessageBox1.Visible = true;
            gvItems.DataBind();
        }
    }
Пример #2
0
    protected void btnDelete_Click(object sender, EventArgs e)
    {
        bool bSomeOne           = false;
        bool bCategoriesRemoved = false;

        for (int i = 0; i < gvItems.Rows.Count; i++)
        {
            CheckBox cb = gvItems.Rows[i].FindControl("cb") as CheckBox;
            if (cb.Checked)
            {
                string TermID  = (gvItems.Rows[i].FindControl("TermID") as Literal).Text;
                int    iTermID = int.Parse(TermID);

                List <BSTerm> categories = BSTerm.GetTermsBySubID(TermTypes.Category, iTermID);

                if (categories.Count == 0)
                {
                    BSTerm bsTerm = BSTerm.GetTerm(iTermID);
                    if (bsTerm != null)
                    {
                        bsTerm.Remove();
                    }
                    bCategoriesRemoved = true;
                }
                else
                {
                    bSomeOne = true;
                }
            }
        }
        if (bSomeOne)
        {
            MessageBox1.Message = Language.Admin["CategoryHaveSub"];
            MessageBox1.Type    = MessageBox.ShowType.Information;
        }
        else if (bCategoriesRemoved)
        {
            MessageBox1.Message = Language.Admin["CategoryDeleted"];
            MessageBox1.Type    = MessageBox.ShowType.Information;
            MessageBox1.Visible = true;
            gvItems.DataBind();
        }
    }