📄 pith.aspx.cs
字号:
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;
namespace doughty_cn
{
/// <summary>
/// pith 的摘要说明。
/// </summary>
public partial class pith : System.Web.UI.Page
{
protected System.Data.SqlClient.SqlCommand sqlSelectCommand1;
protected System.Data.SqlClient.SqlCommand sqlInsertCommand1;
protected System.Data.SqlClient.SqlCommand sqlUpdateCommand1;
protected System.Data.SqlClient.SqlCommand sqlDeleteCommand1;
protected System.Data.SqlClient.SqlConnection sqlConnection1;
protected System.Data.SqlClient.SqlDataAdapter sqlDataAdapter1;
public string navigation;
int PageSize,CurrentPage,PageCount;
public void BindGrid(int SID)
{
string sql1;
int BID;
if (Request.QueryString["BID"]==null)
BID=1;
else
BID=System.Convert.ToInt32(Request.QueryString["BID"]);
sql1="SELECT Q_ID, author, Q_Note, Q_Content, ImageName, HiteCounter, AnsCounter,ReleaseTime, ReferTime, BigClass_ID, SmallClass_ID, kind FROM Questions WHERE (SmallClass_ID = "+SID+") AND (pith = 1) AND (kind > 0) AND (kind < 5) ORDER BY Q_ID DESC";
string sql2;
sql2="SELECT COUNT(*) AS co FROM Questions WHERE (SmallClass_ID = "+SID+") AND (pith = 1) AND (kind > 0) AND (kind < 5)";
PageSize=15;
CurrentPage = 0;
//计算总共有多少记录
int RecordCount = CalculateRecord(sql2);
lblRecordCount.Text = RecordCount.ToString();
//计算总共有多少页
PageCount = (RecordCount+PageSize-1)/PageSize;
lblPageCount.Text = PageCount.ToString();
//获取页面参数
if (Request.QueryString["Page"] != null)
CurrentPage=Convert.ToInt32(Request.QueryString["Page"]);
else
CurrentPage=1;
if (PageCount<CurrentPage)
CurrentPage=PageCount;
if (CurrentPage<=0)
CurrentPage=1;
ListBind(sql1);
lnkNext.Enabled = true;
lnkPrev.Enabled = true;
if(CurrentPage==(PageCount))
{
lnkNext.Enabled = false;
}
else
lnkNext.NavigateUrl=Request.CurrentExecutionFilePath+ "?BID="+ BID.ToString()+ "&SID="+ SID.ToString()+"&Page=" + Convert.ToString(CurrentPage+1);
if(CurrentPage==1)
{
lnkPrev.Enabled = false;
}
else
lnkPrev.NavigateUrl=Request.CurrentExecutionFilePath + "?BID="+ BID.ToString()+ "&SID="+ SID.ToString()+"&Page=" + Convert.ToString(CurrentPage-1);
lblCurrentPage.Text = CurrentPage.ToString();
Page.DataBind();
}
//设定导入的起终地址
public void ListBind(string sql)
{
int StartIndex = (CurrentPage-1)*PageSize;
DataList1.DataSource=DBOperate.SelectFormForum(sql,StartIndex,PageSize,"Download");
}
//计算总共有多少条记录
public int CalculateRecord(string sql)
{
int intCount;
DataRow dr =DBOperate.GetDataRow(sql,"Download","DBConnection");
if(!dr.IsNull(0))
{
intCount = Int32.Parse(dr["co"].ToString());
}
else
{
intCount = 0;
}
return intCount;
}
protected void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
if(!Page.IsPostBack)
{
int BID,SID;
if ((Request.QueryString["BID"]==null)||(Request.QueryString["SID"]==null))
{
BID=1;
SID=200;
}
else
{
BID=System.Convert.ToInt32(Request.QueryString["BID"]);
SID=System.Convert.ToInt32(Request.QueryString["SID"]);
}
navigation="当前位置:<a href='default2.aspx'>"+doughty_cn.inputcon.ConvertString.TitleName(this.Request.Url.ToString())+"</a>->"
+"<a href='BigcalssList.aspx?BID="+BID+"'>"+Navigation.GetBigClassName(BID)+"</a>->"
+"<a href='Mainlist.aspx?BID="+BID+"&SID="+SID+"'>"+Navigation.GetSmallClassName(SID)+"</a>->"
+"精华区";
BindGrid(SID);
}
}
#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -