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

📄 tj_search.aspx.cs

📁 阿江酷站统计系统ASP.Net版,可以直接使用。和现有的网站合并就可以了。提供详细的IP分析。
💻 CS
📖 第 1 页 / 共 2 页
字号:
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_search 的摘要说明。
	/// </summary>
	public class tj_search : System.Web.UI.Page
	{
		protected System.Web.UI.WebControls.Label showtitle;
		protected System.Web.UI.WebControls.DropDownList onyear;
		protected System.Web.UI.WebControls.DropDownList onmonth;
		protected System.Web.UI.WebControls.DropDownList onday;
		protected System.Web.UI.WebControls.DropDownList offyear;
		protected System.Web.UI.WebControls.DropDownList offmonth;
		protected System.Web.UI.WebControls.DropDownList offday;
		protected System.Web.UI.WebControls.TextBox vip;
		protected System.Web.UI.WebControls.TextBox vwhere;
		protected System.Web.UI.WebControls.DropDownList vOS1;
		protected System.Web.UI.WebControls.TextBox vOS2;
		protected System.Web.UI.WebControls.DropDownList vsoft1;
		protected System.Web.UI.WebControls.TextBox vsoft2;
		protected System.Web.UI.WebControls.TextBox vcome;
		protected System.Web.UI.WebControls.TextBox vpage;
		protected System.Web.UI.WebControls.Panel search_form_panel;
		protected System.Web.UI.HtmlControls.HtmlForm tj_search_form;
		protected System.Web.UI.WebControls.CheckBoxList outtype;
		protected System.Web.UI.WebControls.HyperLink seehelp;
		protected System.Web.UI.WebControls.Button searchsub;
		
		public static DataView dv;

		public string strwherestr;
		public string strouttype;
		public string strwherename;
		public string strcontent;
		public string[] strsoft=new string[]{"NetCaptor","MSIE 6.x","MSIE 5.x","MSIE 4.x","Netscape","Opera","Other"};
		public string[] stros=new string[]{"Win2k","WinXP","Win2k3","WinNT","Win9x","类Unix","Mac","Other"};
		public string[] strweek=new string[] {"日","一","二","三","四","五","六",""};

		public string needchecked=" checked";
		private void Page_Load(object sender, System.EventArgs e)
		{
			// 在此处放置用户代码以初始化页面
			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()) < 4) Response.Redirect("help.aspx?id=004&error=您没有使用自定义统计的权限。");
			
			//获取strwherestr等参数
			strwherestr="";
			if(Request.Form["wherestr"]!=null) strwherestr=Request.Form["wherestr"];
			strouttype="";
			if(Request.Form["outtype"]!=null) strouttype=Request.Form["outtype"];
			strwherename="";
			if(Request.Form["wherename"]!=null) strwherename=Request.Form["wherename"];
			strcontent="";
			if(Request.Form["content"]!=null) strcontent=Request.Form["content"];


			//如果strouttype为空,表明不是由list.aspx直接选择已经保存的查询条件而来
			if(strouttype=="")
			{
				//判断页面是否为查询提交后的情况
				if(Page.IsPostBack)		
				{
					//页面为提交情况
					showtitle.Text="恭喜: 下面显示的就是您要查询的内容的分析结果。";
				

					//处理查询条件

					//接收提交数据
					string strontime=onyear.SelectedValue+"-"+onmonth.SelectedValue+"-"+onday.SelectedValue;
					string strofftime=offyear.SelectedValue+"-"+offmonth.SelectedValue+"-"+offday.SelectedValue;

					if(strontime!="--" && !CheckDateTime(strontime)) Response.Redirect("help.aspx?id=001&error=日期填写不合乎要求。");
					if(strofftime!="--" && !CheckDateTime(strofftime)) Response.Redirect("help.aspx?id=001&error=日期填写不合乎要求。");

					if(strofftime!="--") strofftime=DateTime.Parse(strofftime).AddDays(1).ToShortDateString();

					string strvos=vOS2.Text.Trim();
					if(strvos=="") strvos=vOS1.SelectedValue;
					string strvsoft=vsoft2.Text.Trim();
					if(strvsoft=="") strvsoft=vsoft1.SelectedValue;

					string strvip=vip.Text.Trim();
					string strvwhere=vwhere.Text.Trim();
					string strvcome=vcome.Text.Trim();
					string strvpage=vpage.Text.Trim();

					//处理strouttype的参数
					foreach(ListItem iItem in outtype.Items)
					{
						if(iItem.Selected == true) strouttype+=iItem.Text+",";
					}
					if(strouttype!="") strouttype=strouttype.Substring(0,strouttype.Length-1);

					if(strouttype=="") Response.Redirect("help.aspx?id=001&error=您没有指明要查看的项目。");

					//处理SQL指令
					if(strwherestr=="") strwherestr=" where ";
				
					//如果存在查询条件,则将查询条件加入查询字串
					if(strontime!="--") strwherestr+="and (vtime>='" + strontime +"') ";
					if(strofftime!="--") strwherestr+="and (vtime<='" + strofftime +"') ";
					if(strvip!="") strwherestr+="and (vip like '%" + strvip + "%') ";
					if(strvwhere!="") strwherestr+="and ((vwhere like '%" + strvwhere + "%') or (vwheref like '%" + strvwhere + "%')) ";
					if(strvos!="" ) strwherestr+="and (vOS like '%" + strvos + "%') ";
					if(strvsoft!="") strwherestr+="and (vsoft like '%" + strvsoft + "%') ";
					if(strvcome!="") strwherestr+="and (vcome like '%" + strvcome + "%') ";
					if(strvpage!="") strwherestr+="and (vpage like '%" + strvpage + "%') ";

					//去除第一个查询条件和 where 之间的 and
					strwherestr=strwherestr.Replace("where and","where");

					//如果没有查询条件,则查询字串应为空
					if(strwherestr.Trim()=="where") strwherestr="";

					//如果要查看的内容只有详细记录,则直接转入详细记录页
					if(strouttype=="详细")
					{
						string do_goto_showall="<html><body><Form name='goto_showall' action='tj_all.aspx' method='post'>";
						do_goto_showall+="<input name='wherestr' type='hidden' value=\""+strwherestr+"\"></Form>";
						do_goto_showall+="<script>goto_showall.submit()</script>";
						do_goto_showall+="</body></html>";
						Response.Write(do_goto_showall);
						Response.End();
					}


					search_form_panel.Visible=false;

				}
				else
				{
					//第一次调用此页
					showtitle.Text="Tips: 请在下面表格中填写您的查询条件,支持组合查询和模糊查询。";
					if(Session["master"].ToString() == "master" || int.Parse(Session["whatcan"].ToString()) >=5) 
					{
						for(int i=1;i<=12;i++)
						{
							onmonth.Items.Add(i.ToString());
							offmonth.Items.Add(i.ToString());
						}
						onmonth.SelectedIndex=0;
						offmonth.SelectedIndex=0;
						for(int i=1;i<=31;i++)
						{
							onday.Items.Add(i.ToString());
							offday.Items.Add(i.ToString());
						}
						onday.SelectedIndex=0;
						offday.SelectedIndex=0;

						for(int i=0;i<stros.Length;i++) vOS1.Items.Add(stros[i]);
						for(int i=0;i<strsoft.Length;i++) vsoft1.Items.Add(strsoft[i]);
						search_form_panel.Visible=true;

					}

				}
			}
			else
			{
				showtitle.Text="恭喜: 下面显示的就是您要查询的内容的分析结果。";
			}

		}

		#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
		
		private bool CheckDateTime(string thedate)
		{
			bool result=true;
			try
			{
				Convert.ToDateTime(thedate);
			}
			catch
			{
				result=false;
			}
			return result;
		}


		//输出图表数据的子程序(横)
		public string StatHeng(string statname,int tuwidth,string thewhich,int thehow,string unit,string wherestr)
		{
			//statname		报告名称
			//tuwidth		横图每栏宽度
			//thewhich		要查询的项目
			//thehow		共有多少种数据
			//unit			项目的单位
			//wherestr		查询条件

			//声明输出内容数组变量
			int[] val=new int[thehow];
			string [] alt=new string[thehow];
			int[] theper=new int[thehow];

			//开始计算
			string theSql="select " + thewhich + ",count(id) as theval from CounterView " + wherestr + " group by " + thewhich + " order by " + thewhich;
			DataSet myds1=new DataSet();
			DataView dv1=new DataView();

			myds1=counter.SQLConn.ExecuteSqlForDataSet(theSql);
			dv1=myds1.Tables[0].DefaultView;
			dv1.Table.AcceptChanges();

			int themax=0;
			int thesum=0;

			for(int i=0;i<thehow;i++)
			{
				if(thewhich=="vsoft")
				{
					alt[i]=strsoft[i].ToString();
				}
				else
				{
					if(thewhich=="vOS")
					{
						alt[i]=stros[i].ToString();
					}
					else
					{
						alt[i]=i.ToString();
					}
				}
			}
			int aryindex=0;
			for(int i=0;i<dv1.Count;i++)
			{
				if(thewhich=="vsoft")
				{
					for(int intindexofvsoft=0;intindexofvsoft<strsoft.Length;intindexofvsoft++)
					{
						if(strsoft[intindexofvsoft]==dv1[i].Row[thewhich].ToString())
						{
							aryindex=intindexofvsoft;
							break;
						}
					}

⌨️ 快捷键说明

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