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

📄 productclass.aspx.cs

📁 电子商务网站,结合Visual Sttudio 2005和SQL 2005 用ASP.NET语言开发的网站.
💻 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;
using shop.DbBase;

namespace shop
{
	/// <summary>
	/// productClass 的摘要说明。
	/// </summary>
	public class productClass : System.Web.UI.Page
	{
		protected Label pageNow;
		protected Label pTotal;
		protected LinkButton toFirst;
		protected LinkButton prePage;
		protected LinkButton nextPage;
		protected LinkButton toEnd;
		protected Label lblNotice;
		protected Repeater Repeater1;
		protected Label Label1;

		#region 自定义私有变量
		private int iCurPage;
		private int iPageSize;
		private int iTotalPage;
		#endregion

		private void Page_Load(object sender, System.EventArgs e)
		{
			// 在此处放置用户代码以初始化页面
			refreshProduct();
			pageNow.Text = iCurPage.ToString();
			pTotal.Text = iTotalPage.ToString();
		}

		private void nextPage_Click(object sender, EventArgs e)
		{
			iCurPage += int.Parse(pageNow.Text);
		}

		private void prePage_Click(object sender, EventArgs e)
		{
			iCurPage -= int.Parse(pageNow.Text);
		}

		private void toFirst_Click(object sender, EventArgs e)
		{
			iCurPage = 1;
		}

		private void toEnd_Click(object sender, EventArgs e)
		{
			iCurPage = int.Parse(pTotal.Text);
		}

		private void refreshProduct()
		{
			if(!object.Equals(Request.QueryString["ClassName"],null))
			{
				string sClassName = Request.QueryString["ClassName"];
				string sSql = "Select * from Product where BClassName='" + sClassName + "' order by PTime desc";
				iPageSize = 10;
				iCurPage = int.Parse(pageNow.Text);
				DataSet oDS = OleBase.ExecuteSql4Ds(sSql);
				int iTotalRow = oDS.Tables[0].Rows.Count;
				iTotalPage = (int)Math.Ceiling(((double)iTotalRow)/iPageSize);
				if(iCurPage > iTotalPage)
					iCurPage = iTotalPage;
				if(iCurPage < 1)
					iCurPage = 1;
				DataTable oDT = new DataTable();
				foreach(DataColumn oDC in oDS.Tables[0].Columns)
					oDT.Columns.Add(oDC.ColumnName,oDC.GetType());
				for(int i = (iCurPage-1)*iPageSize;i<iCurPage*iPageSize;i++)
				{
					if(i < iTotalRow)
					{
						DataRow oDR = oDT.NewRow();
						for(int j=0;j<oDS.Tables[0].Columns.Count;j++)
							oDR[j] = oDS.Tables[0].Rows[i].ItemArray[j];
						oDT.Rows.Add(oDR);
					}
				}
				Repeater1.DataSource = oDT.DefaultView;
				Repeater1.DataBind();
			}
		}

		#region Web 窗体设计器生成的代码
		override protected void OnInit(EventArgs e)
		{
			//
			// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
			//
			InitializeComponent();
			base.OnInit(e);
		}
		
		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{    
			this.Load += new System.EventHandler(this.Page_Load);
			nextPage.Click += new EventHandler(nextPage_Click);
			prePage.Click += new EventHandler(prePage_Click);
			toFirst.Click += new EventHandler(toFirst_Click);
			toEnd.Click += new EventHandler(toEnd_Click);
		}
		#endregion
	}
}

⌨️ 快捷键说明

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