网络电视Default.aspx
1
using System;
2
using System.Collections;
3
using System.ComponentModel;
4
using System.Data;
5
using System.Data.SqlClient;
6
using System.Drawing;
7
using System.Web;
8
using System.Web.SessionState;
9
using System.Web.UI;
10
using System.Web.UI.WebControls;
11
using System.Web.UI.HtmlControls;
12
using JJS_BMT;
13
using System.IO;
14
using System.Configuration;
15
16
namespace JJS_OMT
17
{
18
/// <summary>
19
/// _Default 的摘要说明。
20
/// </summary>
21
public class _Default : System.Web.UI.Page
22
{
23
protected System.Web.UI.HtmlControls.HtmlTableCell Nav;//小类导航容器
24
protected System.Web.UI.HtmlControls.HtmlTableCell TvList;//网络电视列表容器
25
NetTVFunction Fun=new NetTVFunction();
26
int BTypeID,STypeID;
27
string strKey=null;//初始化关键字
28
string condition=String.Empty;//初始化条件
29
protected System.Web.UI.HtmlControls.HtmlTableCell TVSearch;//搜索容器
30
int TotalNumber1;//总记录条数(不包括会员登陆后个性定制的总记录条数)
31
int TotalNumber2;//总记录条数(个性定制的记录条数)
32
int Rows,PagerIndex1,PagerIndex2;//PagerIndex1:页次(不包括会员登陆后个性定制的页次),PagerIndex2:页次(个性定制的页次)
33
protected System.Web.UI.HtmlControls.HtmlTableCell Pager;//分页控件容器
34
protected System.Web.UI.HtmlControls.HtmlTableCell TypeNav;//大类导航容器
35
36
private void Page_Load(object sender, System.EventArgs e)
37
{
38
// 在此处放置用户代码以初始化页面
39
PagerIndex1=(Request.Params["page"]==null)?1:Convert.ToInt32(Request.Params["page"]);//得到当前页次,如果为空的话,则默认1
40
Rows=15;//******在这里设置网络电视列表每页显示的记录数******
41
BTypeID=(Request.Params["BTypeID"]==null)?1:Convert.ToInt32(Request.Params["BTypeID"]);//得到大类id,如果为空的话,则默认为1
42
STypeID=(Request.Params["STypeID"]==null)?1:Convert.ToInt32(Request.Params["STypeID"]);//得到小类id,如果为空的话,则默认为1
43
strKey=(Request.Params["key1"]==null)?String.Empty:Request.Params["key1"].Trim();//得到关键字,如果为空的话,默认为空字符串
44
if(Request.Params["key1"]!=null&&Request.Params["key1"]!=String.Empty)//如果搜索引擎
45
{
46
condition="(charindex("+"\'"+strKey+"\'"+" ,a.fChannelName)<>0)";//初始化附加条件
47
STypeID=0;//大类ID设为0
48
}
49
if(Request.Params["Fun"]!=null&&Request.Params["Fun"].Trim()=="Logout")//如果会员注销,登出
50
{
51
Fun.SetSesionEmpty();//调用清空Session函数
52
}
53
SetCollection();//当会员用户登陆之后,单击定制,后调用,第一把定制的数据写入数据库,第二判断用户是否重复订制某条频道
54
string url="Default.aspx?BTypeID="+BTypeID+"&STypeID="+STypeID+"&key1="+strKey;//当前URL
55
string strNav=Fun.GetRadioNav(BTypeID,STypeID,url+"&page="+PagerIndex1);//得到小类构造HTML,后面加上&page="+PagerIndex1,是为了当用户定制频道,提交表单不会回到第一页,而是保持在当前页次
56
string strTvList=Fun.GetTVList(BTypeID,STypeID,condition,ref TotalNumber1,ref PagerIndex1,Rows);//得到网络电视列表构造HTML
57
string strTVSearhc=Fun.GetTVSearch();//得到搜索构造HMTL
58
string strTypeNav=Fun.GetTypeNav(BTypeID);//得到大类构造HTML
59
string strPager=Fun.GetTVPager(url,ref PagerIndex1,TotalNumber1,Rows,true,true,"条");//得到分页控件构造THML
60
TVSearch.Controls.Add(new LiteralControl(strTVSearhc));
61
TypeNav.Controls.Add(new LiteralControl(strTypeNav));
62
if(BTypeID==3)//如果用户单击个性定制
63
{
64
if(Session["UserID"]!=null)//用户已经登陆会员
65
{
66
PagerIndex2=(Request.Params["page"]==null)?1:Convert.ToInt32(Request.Params["page"]);
67
string strUserMess=Fun.SetTotalCollect();
68
string strTvList2=Fun.GetCollectList(ref TotalNumber2,ref PagerIndex2,Rows);
69
string strPager2=Fun.GetTVPager(url,ref PagerIndex2,TotalNumber2,Rows,true,true,"条");
70
Nav.Controls.Add(new LiteralControl(strUserMess));
71
TvList.Controls.Add(new LiteralControl(strTvList2));
72
Pager.Controls.Add(new LiteralControl(strPager2));
73
}
74
else//用户没有登陆
75
{
76
Response.Write("<script language='javascript'>alert('请先登陆!');history.go(-1);</script>");
77
}
78
}
79
else
80
{
81
Nav.Controls.Add(new LiteralControl(strNav));
82
TvList.Controls.Add(new LiteralControl(strTvList));
83
Pager.Controls.Add(new LiteralControl(strPager));
84
}
85
}
86
87
/// <summary>
88
/// 用户个性定制频道
89
/// </summary>
90
public void SetCollection()
91
{
92
if(Request.Params["Check_Sel"]!=null)
93
{
94
string s=(Request.Params["Check_Sel"]);
95
string[] s1=s.Split(',');
96
string connStr=ConfigurationSettings.AppSettings["connStr"];
97
SqlConnection conn=new SqlConnection(connStr);
98
for(int i=0;i<s1.Length;i++)
99
{
100
string strSql="select count(*) from TV_Collection a INNER JOIN TV_User b ON a.UserID = b.UserID where a.fCannelId="+Convert.ToInt32(s1[i])+" and a.UserID='"+Session["UserId"].ToString()+"'";
101
SqlCommand comm=new SqlCommand(strSql,conn);
102
conn.Open();
103
int count=Convert.ToInt32(comm.ExecuteScalar());
104
conn.Close();
105
if(count!=0)
106
{
107
Response.Write("<script language='javascript'>alert('你已经定制过这个频道!');history.go(-1);</script>");
108
return;
109
}
110
strSql="insert into TV_Collection (UserID,fCannelId,AddDate) values(@UserID,@fCannelId,@AddDate)";
111
comm=new SqlCommand(strSql,conn);
112
comm.Parameters.Add("@UserID",SqlDbType.VarChar,18);
113
comm.Parameters.Add("@fCannelId",SqlDbType.Int);
114
comm.Parameters.Add("@AddDate",SqlDbType.DateTime);
115
comm.Parameters["@UserID"].Value=Session["UserId"].ToString();
116
comm.Parameters["@fCannelId"].Value=Convert.ToInt32(s1[i]);
117
comm.Parameters["@AddDate"].Value=DateTime.Now;
118
conn.Open();
119
comm.ExecuteNonQuery();
120
conn.Close();
121
}
122
}
123
}
124
125
Web 窗体设计器生成的代码
144
}
145
}
146
using System;2
using System.Collections;3
using System.ComponentModel;4
using System.Data;5
using System.Data.SqlClient;6
using System.Drawing;7
using System.Web;8
using System.Web.SessionState;9
using System.Web.UI;10
using System.Web.UI.WebControls;11
using System.Web.UI.HtmlControls;12
using JJS_BMT;13
using System.IO;14
using System.Configuration;15

16
namespace JJS_OMT17
{18
/// <summary>19
/// _Default 的摘要说明。20
/// </summary>21
public class _Default : System.Web.UI.Page22
{23
protected System.Web.UI.HtmlControls.HtmlTableCell Nav;//小类导航容器24
protected System.Web.UI.HtmlControls.HtmlTableCell TvList;//网络电视列表容器25
NetTVFunction Fun=new NetTVFunction();26
int BTypeID,STypeID;27
string strKey=null;//初始化关键字28
string condition=String.Empty;//初始化条件29
protected System.Web.UI.HtmlControls.HtmlTableCell TVSearch;//搜索容器30
int TotalNumber1;//总记录条数(不包括会员登陆后个性定制的总记录条数)31
int TotalNumber2;//总记录条数(个性定制的记录条数)32
int Rows,PagerIndex1,PagerIndex2;//PagerIndex1:页次(不包括会员登陆后个性定制的页次),PagerIndex2:页次(个性定制的页次)33
protected System.Web.UI.HtmlControls.HtmlTableCell Pager;//分页控件容器34
protected System.Web.UI.HtmlControls.HtmlTableCell TypeNav;//大类导航容器35
36
private void Page_Load(object sender, System.EventArgs e)37
{38
// 在此处放置用户代码以初始化页面39
PagerIndex1=(Request.Params["page"]==null)?1:Convert.ToInt32(Request.Params["page"]);//得到当前页次,如果为空的话,则默认140
Rows=15;//******在这里设置网络电视列表每页显示的记录数******41
BTypeID=(Request.Params["BTypeID"]==null)?1:Convert.ToInt32(Request.Params["BTypeID"]);//得到大类id,如果为空的话,则默认为142
STypeID=(Request.Params["STypeID"]==null)?1:Convert.ToInt32(Request.Params["STypeID"]);//得到小类id,如果为空的话,则默认为143
strKey=(Request.Params["key1"]==null)?String.Empty:Request.Params["key1"].Trim();//得到关键字,如果为空的话,默认为空字符串44
if(Request.Params["key1"]!=null&&Request.Params["key1"]!=String.Empty)//如果搜索引擎45
{46
condition="(charindex("+"\'"+strKey+"\'"+" ,a.fChannelName)<>0)";//初始化附加条件47
STypeID=0;//大类ID设为048
}49
if(Request.Params["Fun"]!=null&&Request.Params["Fun"].Trim()=="Logout")//如果会员注销,登出50
{51
Fun.SetSesionEmpty();//调用清空Session函数52
}53
SetCollection();//当会员用户登陆之后,单击定制,后调用,第一把定制的数据写入数据库,第二判断用户是否重复订制某条频道54
string url="Default.aspx?BTypeID="+BTypeID+"&STypeID="+STypeID+"&key1="+strKey;//当前URL55
string strNav=Fun.GetRadioNav(BTypeID,STypeID,url+"&page="+PagerIndex1);//得到小类构造HTML,后面加上&page="+PagerIndex1,是为了当用户定制频道,提交表单不会回到第一页,而是保持在当前页次56
string strTvList=Fun.GetTVList(BTypeID,STypeID,condition,ref TotalNumber1,ref PagerIndex1,Rows);//得到网络电视列表构造HTML57
string strTVSearhc=Fun.GetTVSearch();//得到搜索构造HMTL58
string strTypeNav=Fun.GetTypeNav(BTypeID);//得到大类构造HTML59
string strPager=Fun.GetTVPager(url,ref PagerIndex1,TotalNumber1,Rows,true,true,"条");//得到分页控件构造THML60
TVSearch.Controls.Add(new LiteralControl(strTVSearhc));61
TypeNav.Controls.Add(new LiteralControl(strTypeNav));62
if(BTypeID==3)//如果用户单击个性定制63
{64
if(Session["UserID"]!=null)//用户已经登陆会员65
{66
PagerIndex2=(Request.Params["page"]==null)?1:Convert.ToInt32(Request.Params["page"]); 67
string strUserMess=Fun.SetTotalCollect();68
string strTvList2=Fun.GetCollectList(ref TotalNumber2,ref PagerIndex2,Rows);69
string strPager2=Fun.GetTVPager(url,ref PagerIndex2,TotalNumber2,Rows,true,true,"条");70
Nav.Controls.Add(new LiteralControl(strUserMess));71
TvList.Controls.Add(new LiteralControl(strTvList2));72
Pager.Controls.Add(new LiteralControl(strPager2));73
}74
else//用户没有登陆75
{76
Response.Write("<script language='javascript'>alert('请先登陆!');history.go(-1);</script>");77
}78
}79
else80
{81
Nav.Controls.Add(new LiteralControl(strNav));82
TvList.Controls.Add(new LiteralControl(strTvList));83
Pager.Controls.Add(new LiteralControl(strPager));84
}85
}86

87
/// <summary>88
/// 用户个性定制频道89
/// </summary>90
public void SetCollection()91
{92
if(Request.Params["Check_Sel"]!=null)93
{94
string s=(Request.Params["Check_Sel"]);95
string[] s1=s.Split(',');96
string connStr=ConfigurationSettings.AppSettings["connStr"];97
SqlConnection conn=new SqlConnection(connStr);98
for(int i=0;i<s1.Length;i++)99
{100
string strSql="select count(*) from TV_Collection a INNER JOIN TV_User b ON a.UserID = b.UserID where a.fCannelId="+Convert.ToInt32(s1[i])+" and a.UserID='"+Session["UserId"].ToString()+"'";101
SqlCommand comm=new SqlCommand(strSql,conn);102
conn.Open();103
int count=Convert.ToInt32(comm.ExecuteScalar());104
conn.Close();105
if(count!=0)106
{107
Response.Write("<script language='javascript'>alert('你已经定制过这个频道!');history.go(-1);</script>");108
return;109
}110
strSql="insert into TV_Collection (UserID,fCannelId,AddDate) values(@UserID,@fCannelId,@AddDate)";111
comm=new SqlCommand(strSql,conn);112
comm.Parameters.Add("@UserID",SqlDbType.VarChar,18);113
comm.Parameters.Add("@fCannelId",SqlDbType.Int);114
comm.Parameters.Add("@AddDate",SqlDbType.DateTime);115
comm.Parameters["@UserID"].Value=Session["UserId"].ToString();116
comm.Parameters["@fCannelId"].Value=Convert.ToInt32(s1[i]);117
comm.Parameters["@AddDate"].Value=DateTime.Now;118
conn.Open();119
comm.ExecuteNonQuery();120
conn.Close();121
}122
}123
}124

125
Web 窗体设计器生成的代码144
}145
}146



浙公网安备 33010602011771号