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

📄 book.aspx.cs

📁 自己开发的一个wap手机网站源代码 公开代码供大家学习下载
💻 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 System.Data.OleDb;

public partial class admins_book : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (this.Session["name"] == null)
        {
            base.Response.Redirect("login.aspx");
        }
        else if (!base.IsPostBack)
        {
            this.Search();
        }

    }
    protected void BtAdd_Click(object sender, EventArgs e)
    {
        base.Response.Redirect("BookEdit.aspx");
    }

    protected void BtDel_Click(object sender, EventArgs e)
    {
        for (int i = 0; i < this.GvBookList.Rows.Count; i++)
        {
            CheckBox box = (CheckBox)this.GvBookList.Rows[i].FindControl("chkEport");
            if (box.Checked)
            {
                HyperLink link = (HyperLink)this.GvBookList.Rows[i].FindControl("Hyname");
                string text = link.Text;
                this.delflag(text);
            }
        }
        this.Search();
    }
    protected void BtNext_Click(object sender, EventArgs e)
    {
        if (this.GvBookList.PageIndex < (this.GvBookList.PageCount - 1))
        {
            this.GvBookList.PageIndex++;
        }
        this.Search();
    }

    protected void BtPre_Click(object sender, EventArgs e)
    {
        if (this.GvBookList.PageIndex > 0)
        {
            this.GvBookList.PageIndex--;
        }
        this.Search();
    }

    protected void BtReset_Click(object sender, EventArgs e)
    {
        this.TbxName.Text = "";
        this.TbxType.Text = "";
    }

    protected void BtSearch_Click(object sender, EventArgs e)
    {
        this.GvBookList.PageIndex = 0;
        this.Search();
    }

    protected void Button1_Click(object sender, EventArgs e)
    {
        base.Response.Redirect("list.aspx");
    }

    private void delflag(string code)
    {
        OleDbConnection connection = new OleDbConnection(GetConnString());
        OleDbCommand command = new OleDbCommand("update books set DeleteFlag=True where  name= '" + code + "'", connection);
        connection.Open();
        command.ExecuteNonQuery();
        connection.Close();
    }
    protected void Dr_SelectedIndexChanged(object sender, EventArgs e)
    {
        this.GvBookList.PageIndex = this.Dr.SelectedIndex;
        this.Search();
    }
    protected static string GetConnString()
    {
        string str2 = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
        string path = ConfigurationManager.ConnectionStrings["DBPaths"].ConnectionString;
        string str4 = HttpContext.Current.Server.MapPath(path);
        return (str2 + str4 + ";");
    }
    protected void GvBookList_DataBound(object sender, EventArgs e)
    {
        this.Dr.Items.Clear();
        for (int i = 0; i < this.GvBookList.PageCount; i++)
        {
            int num2 = i + 1;
            ListItem item = new ListItem(num2.ToString(), num2.ToString());
            this.Dr.Items.Add(item);
        }
        if (this.Dr.Items.Count > 0)
        {
            this.Dr.SelectedIndex = this.GvBookList.PageIndex;
        }
    }

    private void Search()
    {
        DataSet dataSet = new DataSet();
        string connString = GetConnString();
        new OleDbDataAdapter("select id as 顺序, name as 名称, zhuozhe as 作者 ,Type as 类型,Jibie as 级别 from books where  Type like '%" + this.TbxType.Text.Trim() + "%' AND name like '%" + this.TbxName.Text.Trim() + "%'  and DeleteFlag=False  Order by id Desc", connString).Fill(dataSet, "Tb2");
        this.GvBookList.DataSource = dataSet.Tables[0];
        this.GvBookList.DataBind();
        this.GvBookList.PageSize = 5;
    }

}

⌨️ 快捷键说明

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