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

📄 video.cs.bak

📁 视频点播系统使用方法如下: 1. 将"视频点播系统"目录下的所有文件和目录复制到IIS服务器根目录下某新建的虚目录
💻 BAK
字号:
using System;
using System.Data;
using System.Data.SqlClient;
using My.Vod.DbBase;
using System.Collections ;

namespace My
{
	/// <summary>
	/// Video description for Video.
	/// </summary>
	public class Video:Base
	{
		public Video()
		{
			
		}
		//get all data of books
		public static void Hits(string videoId)
		{
			strSQL =  "Update Video set hits=hits+1 Where id= " + videoId;
			try
			{
				ExecuteSql4Ds(strSQL);				
			}
			catch
			{
				throw new Exception("Hits FAILED!!");
			}
		}
                public DataRow GetVideoDetail(int VideoId)
		{
			string strsql;
			DataSet myDs;
			try
			{
				//strsql="select video.id,video.name,video.Filename,Class,Nclass,Sizev,hits,descr from Video where Video.id="+VideoId;
				//strsql="select video.id,video.name,video.Filename,Class,Nclass,Sizev,hits,descr,image=case when(not Cover is null) then ' <img src=cover Border=1 width=80 height=120>' else ' <img src=img/pic.jpg border=1 width=80 height=120>' end from video where Video.id="+VideoId;
				strsql="select video.id,video.name,video.Filename,Class,Nclass,Sizev,hits,descr,cover,Dealtime,Type from video where Video.id="+VideoId;
				myDs=ExecuteSql4Ds(strsql);
				return myDs.Tables[0].Rows[0];
			}
			catch(System.Data.SqlClient.SqlException er)
			{
				throw new Exception(er.Message);
			}

	         }
	        public DataView GetNewVideo()
		{
			String strsql;
			DataSet myDs;
			strsql="select top 5 id,name from Video order by id desc";
			myDs=ExecuteSql4Ds(strsql);
			return myDs.Tables[0].DefaultView ;
		}
                
                public SqlDataReader GetVideoByHits()
		{
			string strsql;
			SqlDataReader result;
			try
			{
				SqlConnection myCn=new SqlConnection(strConn);
				//strsql="select top 10 id,name,descr='&nbsp;&nbsp;'+SUBSTRING(descr,0,100)+'......',image='<img src=(My.Video.GetVideoCover(id))[0] Border=1 width=70 height=100>' from Video order by Hits DESC";
			        //strsql="select top 10 id,name,descr='&nbsp;&nbsp;'+SUBSTRING(descr,0,100)+'......',image='<img src=img/pic.jpg border=1 width=70 height=100>'from video order by hits DESC";
				strsql="select top 6 id,name,descr='&nbsp;&nbsp;'+SUBSTRING(descr,0,100)+'......',image='<img src=upload/'+cover+' Border=1 width=70 height=100>'from video order by hits DESC";
				SqlCommand myCm=new SqlCommand(strsql,myCn);
				myCn.Open ();
				result=myCm.ExecuteReader(CommandBehavior.CloseConnection);
				return result;
			}
			catch(System.Data.SqlClient.SqlException er)
			{
				throw new Exception(er.Message);
			}

	        }
	        
	        public SqlDataReader GetVideoTest(string videoName)
		{
			string strsql;
			SqlDataReader result;
			try
			{
				SqlConnection myCn=new SqlConnection(strConn);
				
				strsql="select id from video where name = videoName";
				SqlCommand myCm=new SqlCommand(strsql,myCn);
				myCn.Open ();
				result=myCm.ExecuteReader(CommandBehavior.CloseConnection);
				return result;
			}
			catch(System.Data.SqlClient.SqlException er)
			{
				throw new Exception(er.Message);
			}

	         }
	
	        public DataView GetVideoCover(int VideoId)
		{
			String strsql;
			DataSet myDs;
			strsql="select cover from video where id="+VideoId;
			myDs=ExecuteSql4Ds(strsql);
			return myDs.Tables[0].DefaultView ;
		}
		
		public DataView GetVideoPath(int VideoId)
		{
			String strsql;
			DataSet myDs;
			strsql="select Filename from video where id="+VideoId;
			myDs=ExecuteSql4Ds(strsql);
			return myDs.Tables[0].DefaultView ;
		}
		//get top ten best salers
		public DataView GetVideoTop10()
		{
			String strsql;
			DataSet myDs;
			strsql="select top 10 id,name from Video order by Hits DESC";
			myDs=ExecuteSql4Ds(strsql);
			return myDs.Tables[0].DefaultView ;
		}
		public static DataSet Search(string Msg)
		{
			string str;
			str="select * from Video where name like '%" + Msg + "%'";
			DataSet myDs;
			myDs=ExecuteSql4Ds(str);
			return myDs;
		}
		public static DataSet SearchByClass(int ClassId)
		{
			string str;
			str="select * from Video where Class="+ClassId;
			DataSet myDs;
			myDs=ExecuteSql4Ds(str);
			return myDs;
		}		
		//get all data of Videos
		public static DataSet GetVideo()
		{
			strSQL = "SELECT * FROM video";

			try
			{
				return ExecuteSql4Ds(strSQL);				
			}
			catch
			{
				throw new Exception("Get all the video Information failed!");
			}			
		}
		////////////////////////////////////////
		/// <summary>
		/// add Video,Operator Storeprocedure "AddVideo"
		/// </summary>
		/// <param name="tempary">Video detail,Kind:ArrayList</param>
		/// <returns></returns>
		public static void AddVideo(ArrayList tempary)
		{
			SqlConnection myCn=new SqlConnection(strConn);
			SqlCommand myCm=new SqlCommand("AddVideo",myCn);
			myCm.CommandType =CommandType.StoredProcedure ;

			myCm.Parameters.Add(new SqlParameter("@Name",SqlDbType.VarChar,50));
			myCm.Parameters["@Name"].Value =tempary[0];

			myCm.Parameters.Add(new SqlParameter("@Filename",SqlDbType.VarChar,50));
			myCm.Parameters["@FileName"].Value =tempary[1];

			myCm.Parameters.Add(new SqlParameter("@Hits",SqlDbType.Int));
			myCm.Parameters["@Hits"].Value =tempary[2];

			myCm.Parameters.Add(new SqlParameter("@Class",SqlDbType.Int));
			myCm.Parameters["@Class"].Value =tempary[3];

			myCm.Parameters.Add(new SqlParameter("@NClass",SqlDbType.Int));
			myCm.Parameters["@NClass"].Value =tempary[4];

			myCm.Parameters.Add(new SqlParameter("@Sizev", SqlDbType.Int));
			myCm.Parameters["@Sizev"].Value =tempary[5];

			myCm.Parameters.Add(new SqlParameter("@Cover",SqlDbType.VarChar,50));
			myCm.Parameters["@Cover"].Value =tempary[6];;

			myCm.Parameters.Add(new SqlParameter("@Type",SqlDbType.Int ));
			myCm.Parameters["@Type"].Value =tempary[7];

			myCm.Parameters.Add(new SqlParameter("@Dealtime",SqlDbType.DateTime));
			myCm.Parameters["@Dealtime"].Value =tempary[8];

			myCm.Parameters.Add(new SqlParameter("@Descr",SqlDbType.VarChar,100));
			myCm.Parameters["@Descr"].Value =tempary[9];

			try
			{
				myCn.Open() ;
				myCm.ExecuteNonQuery() ;
			}
			catch(System.Data.SqlClient.SqlException er)
			{
				throw new  Exception(er.Message);
			}
			finally
			{
				myCm.Dispose() ;
				myCn.Close() ;
			}
		}

		////////////////////////////////////////
		/// <summary>
		/// add Video,Operator Storeprocedure "AddVideo"
		/// </summary>
		/// <param name="tempary">Video detail,Kind:ArrayList</param>
		/// <returns></returns>
		public static void UpdateVideo(ArrayList tempary)
		{
			SqlConnection myCn=new SqlConnection(strConn);
			SqlCommand myCm=new SqlCommand("UpdateVideo",myCn);
			myCm.CommandType =CommandType.StoredProcedure ;

			myCm.Parameters.Add(new SqlParameter("@Id",SqlDbType.Int));
			myCm.Parameters["@Id"].Value =tempary[0];

			myCm.Parameters.Add(new SqlParameter("@Name",SqlDbType.VarChar,50));
			myCm.Parameters["@Name"].Value =tempary[1];

			myCm.Parameters.Add(new SqlParameter("@Filename",SqlDbType.VarChar,50));
			myCm.Parameters["@FileName"].Value =tempary[2];

			myCm.Parameters.Add(new SqlParameter("@Hits",SqlDbType.Int));
			myCm.Parameters["@Hits"].Value =tempary[3];

			myCm.Parameters.Add(new SqlParameter("@Class",SqlDbType.Int));
			myCm.Parameters["@Class"].Value =tempary[4];

			myCm.Parameters.Add(new SqlParameter("@NClass",SqlDbType.Int));
			myCm.Parameters["@NClass"].Value =tempary[5];

			myCm.Parameters.Add(new SqlParameter("@Sizev", SqlDbType.Int));
			myCm.Parameters["@Sizev"].Value =tempary[6];

			myCm.Parameters.Add(new SqlParameter("@Cover",SqlDbType.VarChar,50));
			myCm.Parameters["@Cover"].Value =tempary[7];;

			myCm.Parameters.Add(new SqlParameter("@Type",SqlDbType.Int ));
			myCm.Parameters["@Type"].Value =tempary[8];

			myCm.Parameters.Add(new SqlParameter("@Dealtime",SqlDbType.DateTime));
			myCm.Parameters["@Dealtime"].Value =tempary[9];

			myCm.Parameters.Add(new SqlParameter("@Descr",SqlDbType.VarChar,100));
			myCm.Parameters["@Descr"].Value =tempary[10];

			try
			{
				myCn.Open() ;
				myCm.ExecuteNonQuery() ;
			}
			catch(System.Data.SqlClient.SqlException er)
			{
				throw new  Exception(er.Message);
			}
			finally
			{
				myCm.Dispose() ;
				myCn.Close() ;
			}
		}



		/// <summary>
		/// Delete Video By Videoid
		/// </summary>
		/// <param name="VideoId"></param>
		public void DeleteVideoById(int VideoId)
		{
			strSQL = "Delete From Video Where id="+VideoId;
			
			try
			{
				ExecuteSql(strSQL);				
			}
			catch
			{
				throw new Exception("delete failed!");
			}
		}
		public static DataRow GetVideo(int VideoId)
		{
			string strsql;
			DataSet myDs;
			try
			{
				strsql="select * from Video where Id="+VideoId;
				myDs=ExecuteSql4Ds(strsql);
				return myDs.Tables[0].Rows[0];
			}
			catch(System.Data.SqlClient.SqlException er)
			{
				throw new Exception(er.Message);
			}

		}


		/// <summary>
		/// Delete a group user
		/// </summary>
		/// <param name="names">Users' names</param>		
		public static void DeleteGroup(string videoId)
		{
			strSQL = "Delete From video Where Id in ('" + videoId + "')";
			
			try
			{
				ExecuteSql(strSQL);				
			}
			catch
			{
				throw new Exception("Delete user FAILED!");
			}
		}

		/// <summary>
		/// Search Video By name,author,translator,publisher
		/// </summary>
		/// <param name="Msg"></param>
		/// <returns></returns>
		public static DataSet SearchVideo(string Msg)
		{
			string str;
			str="select * from Video where Name like '%" + Msg + "%' ";
			DataSet myDs;
			myDs=ExecuteSql4Ds(str);
			return myDs;
		}
	}
	public class VideoClass1 :Base
	{
		public VideoClass1()
		{
			
		}
		//get all data of Video type
		public static DataSet GetVideoClass1()
		{
			strSQL = "SELECT * FROM class";

			try
			{
				return ExecuteSql4Ds(strSQL);				
			}
			catch
			{
				throw new Exception("Get all the class Information failed!");
			}			
		}

		/// <summary>
		/// add types
		/// </summary>
		/// <param name="name">name</param>
		/// <param name="memo">memo</param>
		/// <returns></returns>
		public static void Add(string name)
		{
			if(IfExist(name))
			{
				throw new Exception("type existed");
			}
			else
			{
				strSQL = "Insert into class (className) Values("				
					+ "'" + name + "')"	;			
				try
				{
					ExecuteSql(strSQL);				
				}
				catch
				{
					throw new Exception("add class failed");
				}			
			}					
		}
		public static void Update(int oldId, string oldname, string newname)
		{
			if(!IfExist(oldname))
			{
				throw new Exception("class not existed");
			}
			else
			{
				strSQL = "Update class Set "				
				+ "className='" + newname
				+"' Where classId="+oldId.ToString();			
				try
				{
					ExecuteSql(strSQL);				
				}
				catch
				{
					throw new Exception("update class failed");
				}			
			}					
		}
		/// <summary>
		/// delete type
		/// </summary>
		/// <param name="id">jVideo_id</param>
		public static void Delete(int classId)
		{
			My.VideoClass2.DeleteClass(classId);
			strSQL = "Delete From class Where classId="+classId.ToString();
			
			try
			{
				ExecuteSql(strSQL);				
			}
			catch
			{
				throw new Exception("delete failed!");
			}
		}
		
		/// <summary>
		/// if book existed
		/// </summary>
		/// <param name="BTName"></param>
		/// <returns></returns>
		public static bool IfExist(string BTName)
		{
			strSQL = "Select classId from class Where className='"
				+ BTName + "'";

			try
			{
				ExecuteSql4Value(strSQL);
				return true;
			}
			catch
			{
				return false;
			}
		}
	}
	
	public class VideoClass2 :Base
	{
		public VideoClass2()
		{
			
		}

		//get all data of Video type
		public static DataSet GetVideoClass2(int classId)
		{
			strSQL = "SELECT * FROM nclass where classId=" + classId.ToString();

			try
			{
				return ExecuteSql4Ds(strSQL);				
			}
			catch
			{
				throw new Exception("Get all the class Information failed!");
			}			
		}
		/// <summary>
		/// add types
		/// </summary>
		/// <param name="name">name</param>
		/// <param name="memo">memo</param>
		/// <returns></returns>
		public static void Add(string name, int classId)
		{
			if(IfExist(name,classId))
			{
				throw new Exception("type existed");
			}
			else
			{
				strSQL = "Insert into nclass (nclassName,classId) Values("				
					+ "'" + name + "',"
					+ "'" + classId.ToString() +"')";			
				try
				{
					ExecuteSql(strSQL);				
				}
				catch
				{
					throw new Exception("register failed");
				}			
			}					
		}
		public static void Update(string oldname, string newname, int classId)
		{
			if(!IfExist(oldname, classId))
			{
				throw new Exception("class not existed");
			}
			else
			{
				strSQL = "Update nclass Set "				
				+ "nclassName='" + newname
				+"' Where nclassName='"+oldname + "' And classId="+classId.ToString();			
				try
				{
					ExecuteSql(strSQL);				
				}
				catch
				{
					throw new Exception("update class failed");
				}			
			}					
		}
		/// <summary>
		/// delete type
		/// </summary>
		/// <param name="id">jVideo_id</param>
		public static void Delete(string name, int classId)
		{
			strSQL = "Delete From nclass Where nclassName="+"'"+name+"' and classId="+classId.ToString();
			
			try
			{
				ExecuteSql(strSQL);				
			}
			catch
			{
				throw new Exception("delete failed!");
			}
		}

		public static void DeleteClass(int classId)
		{
			strSQL = "Delete From nclass Where classId="+classId.ToString();
			
			try
			{
				ExecuteSql(strSQL);				
			}
			catch
			{
				throw new Exception("delete failed!");
			}
		}		
				/// <summary>
		/// if book existed
		/// </summary>
		/// <param name="BTName"></param>
		/// <returns></returns>
		public static bool IfExist(string BTName, int classId)
		{
			strSQL = "Select nclassId from nclass Where nclassName='"
				+ BTName + "' And classId="+classId.ToString();

			try
			{
				ExecuteSql4Value(strSQL);
				return true;
			}
			catch
			{
				return false;
			}
		}
	}
		
	public class VideoType:Base
	{
		public VideoType()
		{
			
		}
		//get all data of book type
		public DataView GetVideoType()
		{
			String strsql;
			DataSet myDs;
			strsql="select * from Class";
			myDs=ExecuteSql4Ds(strsql);
			return myDs.Tables[0].DefaultView ;
		}
	}
	
        public class VideoClass:Base
	{
		public VideoClass()
		{
			
		}
		//get all data of book type
		public static DataView GetClassName(int ClassId)
		{
			String strsql;
			DataSet myDs;
			strsql="select classname from Class where classid="+ ClassId;
			myDs=ExecuteSql4Ds(strsql);
			return myDs.Tables[0].DefaultView;
		}

		/// <summary>
		/// add types
		/// </summary>
		/// <param name="name">name</param>
		/// <param name="memo">memo</param>
		/// <returns></returns>
		
	}
}

⌨️ 快捷键说明

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