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

📄 booktypemanage.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 BookManage.Model;
using BookManage.BLL;

public partial class Admin_BookTypeManage : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            selectType.AutoBindData();
        }
            

        BookType bookType = new BookType();
        bookTypeList.DataSource = bookType.GetBookTypeListWithDesc();
        bookTypeList.DataBind();
    }
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
       
        BookType type = new BookType();
        if (ViewState["modifyID"] == null)
        {
            int parentId = Convert.ToInt32(Request.Form[selectType.UniqueID]);
            BookTypeInfo typeInfo = new BookTypeInfo(0, txtDesc.Value, txtName.Text,parentId);
            type.AddBookType(typeInfo);
            Page.RegisterStartupScript("alert", "<script type=\"text/javascript\">alert('添加成功')</script>");
        }
        else
        {
            int id = Convert.ToInt32(ViewState["modifyID"]);
            BookTypeInfo typeInfo = new BookTypeInfo(id, txtDesc.Value, txtName.Text);
            type.ModifyBookType(typeInfo);
            ViewState.Remove("modifyID");
            Page.RegisterStartupScript("alert", "<script type=\"text/javascript\">alert('修改成功')</script>");
        }
        bookTypeList.DataSource = type.GetBookTypeListWithDesc();
        bookTypeList.DataBind();
        selectType.AutoBindData();
        
    }
 
    protected void bookTypeList_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            BookTypeInfo typeInfo = (BookTypeInfo)e.Row.DataItem;
            string typeName = typeInfo.BookTypeName;
            
            if (typeInfo.LevelId > 1)
            {
                int padding = typeInfo.LevelId * 8;
                typeName = "└ " + typeName;
                e.Row.Cells[0].Attributes.CssStyle.Add("padding-left", padding + "px");
            }
            
            e.Row.Cells[0].Text = typeName;
        }
    }
    protected void bookTypeList_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        BookType bookType = new BookType();
        int id =Convert.ToInt32(bookTypeList.DataKeys[e.RowIndex].Value);
        if(bookType.DeleteBookType(id)>0)
            Page.RegisterStartupScript("alert", "<script type=\"text/javascript\">alert('删除成功')</script>"); ;
        bookTypeList.DataSource = bookType.GetBookTypeListWithDesc();
        bookTypeList.DataBind();
        selectType.AutoBindData();
    }

    protected void bookTypeList_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == "Modify")
        {
            selectType.AutoBindData();
            int id = Convert.ToInt32(e.CommandArgument);
            ViewState.Add("modifyID", id);
            BookType type = new BookType();
            BookTypeInfo typeInfo = type.GetBookTypeById(id);
            txtName.Text = typeInfo.BookTypeName;
            txtDesc.Value = typeInfo.BookTypeDesc;
            selectType.SelectedValue = typeInfo.ParentTypeId.ToString();
            ltMode.Visible = true;
            bookTypeList.Visible = false;
        }
    }
}

⌨️ 快捷键说明

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