Asp.net视频点播系统后端部分AddVideo

目录

1 Asp.net视频点播系统后端部分AddVideo

1.1 添加文件

1.2 重置

1.3 绑定数据

  1. Asp.net视频点播系统后端部分AddVideo

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

{

public class AddVideo : 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  Add;

protected System.Web.UI.WebControls.Button  Reset;

private void Page_Load(object sender, System.EventArgs e)

{

// 在此处放置用户代码以初始化页面

if(!Page.IsPostBack )

{

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.Add.Click += new System.EventHandler(this.Add_Click);

this.Reset.Click += new System.EventHandler(this.Reset_Click);

this.DropDownList1.SelectedIndexChanged += new System.EventHandler(this.selectClass);

this.Load += new System.EventHandler(this.Page_Load);

}

#endregion

    1. 添加文件

private void Add_Click(object sender, System.EventArgs e)

{

ArrayList CommAry=new ArrayList();

            string newext2="";

            string newname2="";

   /*if((FileName.PostedFile!= null)&&(FileName.PostedFile.FileName.Trim()!=""))

    {

   string nam = FileName.PostedFile.FileName ;

   //取得文件名(包括路径)里最后一个"."的索引

   int i= nam.LastIndexOf(".");

  //取得文件扩展名

   newext1 =nam.Substring(i);

   //这里自动根据日期和文件大小不同为文件命名,确保文件名不重复。

   DateTime now = DateTime.Now;

   newname1 =now.DayOfYear.ToString()+FileName.PostedFile.ContentLength.ToString();

   //保存文件到你所要的目录,这里是IIS根目录下的upfiles目录.你可以改变.

   //注意: 我这里用Server.MapPath()取当前文件的绝对目录.在asp.net里"\"必须用"\\"代替

  // FileName.PostedFile.SaveAs(Server.MapPath("\\studyASP\\upload\\"+newname1+newext1));

   //得到这个文件的相关属性:文件名,文件类型,文件大小

    }*/

   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(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.AddVideo(CommAry);

}

catch

{

Response.Redirect("Error.aspx");

}

}

    1. 重置

private void Reset_Click(object sender, System.EventArgs e)

{

Name.Text="";

DealTime.Text="";

Sizev.Text="";

Hits.Text="";

Descr.Text="";

Bind();

}

    1. 绑定数据

    private void Bind()

{

DataSet ds = My.VideoClass1.GetVideoClass1();

this.DropDownList1.DataSource = ds.Tables[0].DefaultView;

this.DropDownList1.DataBind();

            

            this.DropDownList1.SelectedIndex = 0;

     DataSet dsVideoClass21 = My.VideoClass2.GetVideoClass2(Int32.Parse(DropDownList1.SelectedItem.Value));

    

this.DropDownList2.DataSource = dsVideoClass21.Tables[0].DefaultView;

this.DropDownList2.DataBind();

    }

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

    }     

}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

m0_74456535

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值