Пример #1
0
    public void Delete(string id)
    {
        DbTask    db      = new DbTask();
        Publish   publish = null;
        Menus     menu    = null;
        News      news    = null;
        string    Sql     = string.Empty;
        DataTable dt      = GetChild(id);

        if (dt != null && dt.Rows.Count > 0)
        {
            foreach (DataRow dr in dt.Rows)
            {
                string vparentid = dr["pparentid"].ToString();
                string vid       = dr["pid"].ToString();
                bool   kiemtra   = CheckChild(id);
                if (kiemtra)
                {
                    Delete(vid);
                }
                else
                {
                    Sql = "DELETE FROM " + TableName + " WHERE parentid = '" + vparentid + "'";
                    db.ExecuteNonQuery(Sql);
                }
                //Xoa menu

                for (int i = 1; i <= 9; i++)
                {
                    menu = new Menus(i);
                    menu.RemoveFromMenu(vid);
                }
                //Xoa Tin
                news = new News();
                news.DeleteGroup(vid);

                //xoa publish
                publish = new Publish();
                publish.DeletePublish(id);
            }
        }
        Sql = "DELETE FROM " + TableName + " WHERE id = '" + id.Trim() + "'";
        db.ExecuteNonQuery(Sql);
        //Xoa menu
        for (int i = 1; i <= 9; i++)
        {
            menu = new Menus(i);
            menu.RemoveFromMenu(id);
        }
        //Xoa Tin
        news = new News();
        news.DeleteGroup(id);

        //xoa publish
        publish = new Publish();
        publish.DeletePublish(id);
    }