⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 admin_classdelete.aspx.cs

📁 新闻网站
💻 CS
字号:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using BLL.System;
using Common.Entities;

public partial class Admin_Admin_ClassDelete : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            //绑定数据到Tree中
            this.treeClass.Nodes.Clear();
            BindTree(this.treeClass.Nodes, 0);

        }
    }
    //绑定数据到Tree中
    private void BindTree(TreeNodeCollection treeCol, int superID)
    {
        ArrayList arrayList = new ArrayList();
        ClassSystem classSystem = new ClassSystem();
        arrayList = classSystem.GetClassData(superID);

        TreeNode node;
        foreach (ClassData classData in arrayList)
        {
            node = new TreeNode();
            node.Text = classData.ClassName + "(" + classData.Child + ")";
            node.Value = classData.ClassID.ToString();
            treeCol.Add(node);
            BindTree(node.ChildNodes, int.Parse(node.Value));
        }


    }
    protected void treeClass_SelectedNodeChanged(object sender, EventArgs e)
    {
        //获取要添加NewClassID值
        int id = int.Parse(this.treeClass.SelectedNode.Value);


        //如果是子节点,就显示它的父类,如果是父类就直接显示它的信息
        ClassData classData = new ClassData();
        classData = (new ClassSystem()).GetClassDataID(id);

        //给选种的结构赋值到指定的文本中
        txtClassName.Text = classData.ClassName;
        txtClassID.Text = classData.ClassID.ToString();
        txtExample.Text = classData.Example;

        //还有一个功能要实现

        int chindid = classData.Child;
        if (chindid != 0)
        {
            this.ClientScript.RegisterStartupScript(this.GetType(), "deletetoo", "<script>alert('警告!删除这个标题可能导致它的子标题,无法使用!!!')</script>");
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        //删除操作
        int id = int.Parse(txtClassID.Text.Trim().ToString());
        //删除 操作
        if ((new ClassSystem()).DeleteClass(id))
        {
            this.ClientScript.RegisterStartupScript(this.GetType(), "delete", "<script>alert('删除成功!')</script>");
        }
        else
        {
            this.ClientScript.RegisterStartupScript(this.GetType(), "delete", "<script>alert('删除失败!')</script>");
        }
        this.txtClassID.Text = "";
        this.txtClassName.Text = "";
        txtExample.Text = "";

        //重新绑定数据到Tree中
        //this.treeNewClass.Nodes.Clear();
        //BindTree(this.treeNewClass.Nodes, 0);
        Response.Redirect("Admin_ClassDelete.aspx");
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -