📄 bookintype.aspx.cs
字号:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.Mobile;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.MobileControls;
//using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data.OleDb;
using System.Configuration;
public partial class bookintype : System.Web.UI.MobileControls.MobilePage
{
protected void Page_Load(object sender, EventArgs e)
{
int num = 1;
if (base.Request.QueryString["type"] == null)
{
base.Response.Redirect("booklist.aspx");
}
else
{
int num3;
AdRotator rotator = new AdRotator();
rotator.AdvertisementFile="~/ad.xml";
this.Form1.Controls.Add(rotator);
if (base.Request.QueryString["page"] != null)
{
num = Convert.ToInt32(base.Request.QueryString["page"].ToString());
}
string type = base.Request.QueryString["type"].ToString();
this.Form1.Title=type;
DataSet list = new DataSet();
list = this.GetList(type);
Label label = new Label();
label.Text="##" + type + "##";
label.BreakAfter=true;
this.Form1.Controls.Add(label);
Link[] linkArray = new Link[10];
for (int i = 0; ((((num - 1) * 10) + i) < list.Tables[0].Rows.Count) && (i < 10); i++)
{
linkArray[i] = new Link();
linkArray[i].Text=list.Tables[0].Rows[((num - 1) * 10) + i]["名称"].ToString();
linkArray[i].NavigateUrl="readbook.aspx?id=" + list.Tables[0].Rows[((num - 1) * 10) + i]["顺序"].ToString();
this.Form1.Controls.Add(linkArray[i]);
}
if ((list.Tables[0].Rows.Count % 10) != 0)
{
num3 = (list.Tables[0].Rows.Count / 10) + 1;
}
else
{
num3 = list.Tables[0].Rows.Count / 10;
}
if (num != 1)
{
Link link = new Link();
link.Text="前一页";
link.NavigateUrl="bookintype.aspx?type=" + type + "&page=" + Convert.ToString((int)(num - 1));
this.Form1.Controls.Add(link);
link.BreakAfter=false;
}
Label label2 = new Label();
label2.Text=num.ToString() + "/" + num3.ToString();
this.Form1.Controls.Add(label2);
label2.BreakAfter=false;
if (num < num3)
{
Link link2 = new Link();
link2.Text="下一页";
link2.NavigateUrl="bookintype.aspx?type=" + type + "&page=" + Convert.ToString((int)(num + 1));
this.Form1.Controls.Add(link2);
}
Label label3 = new Label();
label3.Text="";
this.Form1.Controls.Add(label3);
if ((num3 != 1) && (num != 1))
{
label3.BreakAfter=false;
}
}
Link child = new Link();
child.Text="返回目录";
child.NavigateUrl="booklist.aspx";
this.Form1.Controls.Add(child);
}
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 + ";");
}
private DataSet GetList(string type)
{
DataSet dataSet = new DataSet();
string connString = GetConnString();
new OleDbDataAdapter("select id as 顺序, name as 名称 from books where Type= '" + type + "' and DeleteFlag=False Order by id Desc", connString).Fill(dataSet, "Tb2");
return dataSet;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -