default.aspx.cs

来自「网上那个书店开发系统论文,需要的朋友可以下载参考哦」· CS 代码 · 共 82 行

CS
82
字号
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using BookManage.BLL;
using BookManage.Model;

	/// <summary>
	/// _Default 的摘要说明。
	/// </summary>
	public partial class _Default : System.Web.UI.Page
	{
		protected void Page_Load(object sender, System.EventArgs e)
		{

            if (!Page.IsPostBack)
            {
                filterType.AutoBindData();
            }
            txtSearch.Attributes.Add("onkeydown", "if(event.keyCode==13){document.getElementById('" + btnSearch.ClientID + "').focus();document.getElementById('" + btnSearch.ClientID + "').click();}");
            BindData();
			
		}

        protected void btnSearch_ServerClick(object sender, EventArgs e)
        {
            ViewState.Add("search", "search");
            ViewState.Remove("type");
            BindData();
        }


        protected void bookList_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                BookInfo bookInfo = (BookInfo)e.Row.DataItem;
                if (bookInfo.BookStatus == false)
                    e.Row.Cells[4].Text = "未借出";
                else
                    e.Row.Cells[4].Text = "已借出";
            }
        }
        protected void filterType_SelectedIndexChanged(object sender, EventArgs e)
        {
            ViewState.Add("type", "type");
            ViewState.Remove("search");
            BindData();
        }
        void BindData()
        {
            if (ViewState["search"] == null && ViewState["type"] == null)
            {
                bookList.DataSource = Book.GetBookList();
                bookList.DataBind();
            }
            else if (ViewState["search"] != null)
            {
                bookList.DataSource = Book.GetBookListByName(txtSearch.Value);
                bookList.DataBind();
            }
            else if (ViewState["type"] != null)
            {
                if (filterType.SelectedIndex == 0)
                    bookList.DataSource = Book.GetBookList();
                else
                {
                    int typeId = int.Parse(filterType.SelectedValue);
                    bookList.DataSource = Book.GetBookListByType(typeId);
                }
                bookList.DataBind();
            }
        }
	}

⌨️ 快捷键说明

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