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

📄 tj_all.aspx.cs

📁 阿江酷站统计系统ASP.Net版,可以直接使用。和现有的网站合并就可以了。提供详细的IP分析。
💻 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 counter
{
	/// <summary>
	/// tj_all 的摘要说明。
	/// </summary>
	public class tj_all : System.Web.UI.Page
	{
		protected System.Web.UI.WebControls.DataGrid show_all;
		public static DataView dv;
		protected System.Web.UI.HtmlControls.HtmlForm Form1;
		public static DataView dv1;
		public string strwherestr;
		public string strSql;
		protected System.Web.UI.WebControls.LinkButton thefirst;
		protected System.Web.UI.WebControls.LinkButton theprev;
		protected System.Web.UI.WebControls.LinkButton thenext;
		protected System.Web.UI.WebControls.LinkButton thelast;
		protected int intpagecount;
		protected System.Web.UI.WebControls.DropDownList pagegoto;
		protected int intcurrentpage;

		private void Page_Load(object sender, System.EventArgs e)
		{
			// 在此处放置用户代码以初始化页面
			if(Request.Form["wherestr"]!=null)
			{
				strwherestr=Request.Form["wherestr"].ToString();
			}
			else
			{
				strwherestr="";
			}

			strSql="select * from CounterView "+strwherestr+" order by id";

			DataSet myds = new DataSet();
			myds = counter.SQLConn.ExecuteSqlForDataSet("select * from CounterInfo");
			dv=myds.Tables[0].DefaultView;
			if(Session["master"]==null) Session["master"]="";
			if(Session["whatcan"]==null) Session["whatcan"]=dv[0].Row["whatcan"].ToString();
			if(Session["master"].ToString() != "master" && int.Parse(Session["whatcan"].ToString()) < 2) Response.Redirect("help.aspx?id=004&error=您没有查看详细记录的权限。");

			if(!Page.IsPostBack)
			{
				DataSet myds1 = new DataSet();
				myds1 = counter.SQLConn.ExecuteSqlForDataSet(strSql);
				dv1=myds1.Tables[0].DefaultView;
				dv1.Table.AcceptChanges();
				
				if(dv1.Count==0)
				{
					Response.Write("没有符合条件的记录");
					dv1.Dispose();
					Response.End();
				}
				show_all.PageSize=int.Parse(dv[0].Row["mPageSize"].ToString());
				show_all.VirtualItemCount =dv1.Count;
				
				ViewState["datacount"]=dv1.Count;
				ViewState["statrindex"]=0;
				ViewState["currentpage"]=intcurrentpage;
				
				intpagecount=(int)(Math.Ceiling(double.Parse(ViewState["datacount"].ToString())/(double)show_all.PageSize));

				BindGrid();
				
				if(intpagecount==1)
				{
					thefirst.Enabled=false;
					theprev.Enabled=false;
					thenext.Enabled=false;
					thelast.Enabled=false;
				}

				thefirst.Enabled=false;
				theprev.Enabled=false;

				for(int i=1;i<=intpagecount;i++)
				{
					pagegoto.Items.Add(new ListItem(i.ToString(),i.ToString()));
				}
			}

			intpagecount=(int)(Math.Ceiling(double.Parse(ViewState["datacount"].ToString())/(double)show_all.PageSize));

		}

		public void BindGrid()
		{
			DataSet myds1 = new DataSet();
			myds1 = counter.SQLConn.ExecuteSqlForDataSetPageing(strSql,int.Parse(ViewState["statrindex"].ToString()),show_all.PageSize,"CounterView");
			dv1=myds1.Tables[0].DefaultView;
			dv1.Table.AcceptChanges();
			
			show_all.VirtualItemCount=int.Parse(ViewState["datacount"].ToString());
			show_all.DataSource = dv1;
			show_all.DataBind();
		}

		public void DataGrid_ItemDataBound(Object sender,DataGridItemEventArgs e)
		{
			if(e.Item.ItemIndex>=0)
			{
				DateTime show_time=DateTime.Parse(e.Item.Cells[0].Text);
				string strshow_time=show_time.Year.ToString();
				strshow_time=strshow_time.Substring(2,strshow_time.Length-2)+"-";
				if(int.Parse(show_time.Month.ToString())<10) strshow_time+="0";
				strshow_time+=show_time.Month.ToString()+"-";
				if(int.Parse(show_time.Day.ToString())<10) strshow_time+="0";
				strshow_time+=show_time.Day.ToString()+" ";
				if(int.Parse(show_time.Hour.ToString())<10) strshow_time+="0";
				strshow_time+=show_time.Hour.ToString()+":";
				if(int.Parse(show_time.Minute.ToString())<10) strshow_time+="0";
				strshow_time+=show_time.Minute.ToString();

				e.Item.Cells[0].Text="<a title='"+e.Item.Cells[6].Text+"'>"+strshow_time;
				e.Item.Cells[0].Text+="</a>";

				e.Item.Cells[1].Text="<a title='"+e.Item.Cells[7].Text+" "+e.Item.Cells[1].Text+"·"+e.Item.Cells[8].Text+"'>"+e.Item.Cells[1].Text+"</a>";

				if(e.Item.Cells[5].Text.Length>20)
				{
					e.Item.Cells[5].Text="<a title='"+e.Item.Cells[5].Text+"' href='"+e.Item.Cells[5].Text+"'>"+e.Item.Cells[5].Text.ToString().Substring(0,20)+"...</a>";
				}
				else
				{
					e.Item.Cells[5].Text="<a  href='"+e.Item.Cells[5].Text+"'>"+e.Item.Cells[5].Text.ToString()+"</a>";
				}


			}
		}
		
		public void FirstPage_Click(object sender, System.EventArgs e)
		{
			intcurrentpage=0;
			ViewState["statrindex"]=0;
			ViewState["currentpage"]=intcurrentpage;
			BindGrid();
			if(intpagecount>1)
			{
				thenext.Enabled=true;
				thelast.Enabled=true;
			}
			thefirst.Enabled=false;
			theprev.Enabled=false;
		}
		
		public void PrevPage_Click(object sender, System.EventArgs e)
		{
			intcurrentpage=int.Parse(ViewState["currentpage"].ToString())-1;
			ViewState["statrindex"]=intcurrentpage * show_all.PageSize;
			ViewState["currentpage"]=intcurrentpage;
			BindGrid();
			if(intpagecount>1)
			{
				thenext.Enabled=true;
				thelast.Enabled=true;
			}

			if(intcurrentpage==0)
			{
				thefirst.Enabled=false;
				theprev.Enabled=false;
			}
		}

		public void NextPage_Click(object sender, System.EventArgs e)
		{
			intcurrentpage=int.Parse(ViewState["currentpage"].ToString())+1;
			ViewState["statrindex"]=intcurrentpage * show_all.PageSize;
			ViewState["currentpage"]=intcurrentpage;
			BindGrid();
			if(intpagecount>1)
			{
				thefirst.Enabled=true;
				theprev.Enabled=true;
			}

			if((intcurrentpage+1)*int.Parse(show_all.PageSize.ToString())>=int.Parse(ViewState["datacount"].ToString()))
			{
				thenext.Enabled=false;
				thelast.Enabled=false;
			}
		}

		public void LastPage_Click(object sender, System.EventArgs e)
		{
			intcurrentpage=intpagecount-1;
			ViewState["statrindex"]=intcurrentpage * show_all.PageSize;
			ViewState["currentpage"]=intcurrentpage;
			BindGrid();
			if(intpagecount>1)
			{
				thefirst.Enabled=true;
				theprev.Enabled=true;
			}
			thenext.Enabled=false;
			thelast.Enabled=false;
		}

		public void PageGo_Click(object sender, System.EventArgs e)
		{
			Do_PageGo_Click(pagegoto.SelectedItem.Value);
		}

		public void Do_PageGo_Click(string dopage)
		{
			if(int.Parse(dopage)>intpagecount)
			{
				intcurrentpage=intpagecount-1;
			}
			else
			{
				if(int.Parse(dopage)<1)
				{
					intcurrentpage=0;
				}
				else
				{
					intcurrentpage=int.Parse(dopage)-1;
				}
			}

			ViewState["statrindex"]=intcurrentpage * show_all.PageSize;
			ViewState["currentpage"]=intcurrentpage;
			BindGrid();

			if(intpagecount==1)
			{
				thefirst.Enabled=false;
				theprev.Enabled=false;
				thenext.Enabled=false;
				thelast.Enabled=false;
			}
			else
			{
				if(intcurrentpage==0)
				{
					thefirst.Enabled=false;
					theprev.Enabled=false;
					thenext.Enabled=true;
					thelast.Enabled=true;
				}
				else
				{
					if(intcurrentpage==intpagecount-1)
					{
						thefirst.Enabled=true;
						theprev.Enabled=true;
						thenext.Enabled=false;
						thelast.Enabled=false;
					}
					else
					{
						thefirst.Enabled=true;
						theprev.Enabled=true;
						thenext.Enabled=true;
						thelast.Enabled=true;
					}
				}
			}

		}


		#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);

		}
		#endregion
	}
}

⌨️ 快捷键说明

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