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

📄 modifyvideo.aspx.cs

📁 视频点播系统使用方法如下: 1. 将"视频点播系统"目录下的所有文件和目录复制到IIS服务器根目录下某新建的虚目录
💻 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 System.IO;

namespace Vod
{
	/// <summary>
	/// ShowBook 的摘要说明。
	/// </summary>
	public class ModifyVideo : System.Web.UI.Page
	{
		protected System.Web.UI.WebControls.DropDownList DropDownList1;
		protected System.Web.UI.WebControls.DropDownList DropDownList2;
		
		protected System.Web.UI.WebControls.TextBox Name;
		protected System.Web.UI.WebControls.TextBox DealTime;
		protected System.Web.UI.WebControls.TextBox FileName;
		protected System.Web.UI.HtmlControls.HtmlInputFile Cover;
		protected System.Web.UI.WebControls.TextBox Sizev;
		protected System.Web.UI.WebControls.TextBox Hits;	
		protected System.Web.UI.WebControls.TextBox Descr;			

		protected System.Web.UI.WebControls.RadioButtonList RadioButtonList1;
			
		protected System.Web.UI.WebControls.Button  Modify;
		protected System.Web.UI.WebControls.Button  Show;				

		private void Page_Load(object sender, System.EventArgs e)
		{
			// 在此处放置用户代码以初始化页面
			if(!Page.IsPostBack )
			{
				ViewState["VideoId"]=Request.QueryString["Id"];
				Bind();
			}
		}

		#region Web Form Designer generated code
		override protected void OnInit(EventArgs e)
		{
			//
			// CODEGEN:该调用是 ASP.NET Web 窗体设计器所必需的。
			//
			InitializeComponent();
			base.OnInit(e);
		}
		
		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{    
			this.Modify.Click += new System.EventHandler(this.Modify_Click);
			this.Show.Click += new System.EventHandler(this.Show_Click);		
			
			this.DropDownList1.SelectedIndexChanged += new System.EventHandler(this.selectClass);
				
			this.Load += new System.EventHandler(this.Page_Load);
		}
		#endregion

		private void Modify_Click(object sender, System.EventArgs e)
		{
			
			ArrayList CommAry=new ArrayList();
            //string newext1="";
            //string newname1="";
            string newext2="";
            string newname2="";

  			if((Cover.PostedFile!=null)&&(Cover.PostedFile.FileName.Trim()!=""))
   			{     
  				string nam = Cover.PostedFile.FileName ;
  				//取得文件名(包括路径)里最后一个"."的索引
  				int i= nam.LastIndexOf(".");
 				//取得文件扩展名
  				newext2 =nam.Substring(i);
  				//这里自动根据日期和文件大小不同为文件命名,确保文件名不重复。
  				DateTime now = DateTime.Now; 
  				newname2 =now.DayOfYear.ToString()+ Cover.PostedFile.ContentLength.ToString(); 
  				//保存文件到你所要的目录,这里是IIS根目录下的upfiles目录.你可以改变.
  				//注意: 我这里用Server.MapPath()取当前文件的绝对目录.在asp.net里"\"必须用"\\"代替
 				Cover.PostedFile.SaveAs(Server.MapPath("\\vod\\"+newname2+newext2)); 
  				//得到这个文件的相关属性:文件名,文件类型,文件大小
   			}
   			
			CommAry.Add(int.Parse(ViewState["VideoId"].ToString()));				
			CommAry.Add(Name.Text.Trim());
			CommAry.Add(FileName.Text.Trim());			
			CommAry.Add(0);			
			CommAry.Add(Int32.Parse(DropDownList1.SelectedItem.Value));
			CommAry.Add(Int32.Parse(DropDownList2.SelectedItem.Value));
			CommAry.Add(Sizev.Text.Trim());
			CommAry.Add(newname2+newext2);
			CommAry.Add(Int32.Parse(RadioButtonList1.SelectedItem.Value));
			CommAry.Add(System.DateTime.Now);			
			CommAry.Add(Descr.Text.Trim());

           // My.Video.AddVideo(CommAry);
			
			try
			{
				My.Video.UpdateVideo(CommAry);
			}
			catch
			{
				Response.Redirect("Error.aspx");
			}
		}

		private void Show_Click(object sender, System.EventArgs e)
		{						
			Bind();	
		}
	
	    private void Bind()
		{
			DataSet ds = My.VideoClass1.GetVideoClass1();
			DataRow myDr;
			DataRow myDr2;
			int     i;
			
			myDr=My.Video.GetVideo(int.Parse(ViewState["VideoId"].ToString()));	
								
			this.DropDownList1.DataSource = ds.Tables[0].DefaultView;
			this.DropDownList1.DataBind();

            this.DropDownList1.SelectedItem.Value = myDr["class"].ToString();
			
			for(i=0; i<ds.Tables[0].Rows.Count ;i++)
			{
				myDr2 = ds.Tables[0].Rows[i];
				if(int.Parse(myDr2["classId"].ToString()) == Int32.Parse(DropDownList1.SelectedItem.Value))
				{
					this.DropDownList1.SelectedIndex = i;
					break;
				}
				else
				this.DropDownList1.SelectedIndex = 0;
			}
			
	    	DataSet dsVideoClass21 = My.VideoClass2.GetVideoClass2(Int32.Parse(DropDownList1.SelectedItem.Value));
	    				
			this.DropDownList2.DataSource = dsVideoClass21.Tables[0].DefaultView;
			this.DropDownList2.DataBind();
			this.DropDownList2.SelectedItem.Value = myDr["nclass"].ToString();
							        	
			Name.Text=myDr["Name"].ToString();
			FileName.Text=myDr["FileName"].ToString();
			DealTime.Text=myDr["DealTime"].ToString();
			//Cover.Value=myDr["Cover"].ToString();
			Sizev.Text=myDr["Sizev"].ToString();
			Hits.Text=myDr["Hits"].ToString();
			Descr.Text=myDr["Descr"].ToString();
	    }	
	    private void selectClass(object sender, System.EventArgs e)
	    {
	    	DataSet dsVideoClass21 = My.VideoClass2.GetVideoClass2(Int32.Parse(DropDownList1.SelectedItem.Value));
	    				
			this.DropDownList2.DataSource = dsVideoClass21.Tables[0].DefaultView;
			this.DropDownList2.DataBind();
			
	    }	    	
	}
}

⌨️ 快捷键说明

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