using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.IO;

public partial class mp4add : System.Web.UI.Page
{
    mp4films mf = new mp4films();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            if (Session["UserID"] == null && Session["UserName"] != "shuanghan")
            {
                Response.Write("<script>alert(\"请管理员登录!\")</script>");
                Response.Write("<meta http-equiv='refresh' content='1;url=mp4.aspx'>");
            }
        }

    }
    protected void ib_1_Click(object sender, ImageClickEventArgs e)
    {
        DownRecommend.Text = "1";
    }
    protected void ib_2_Click(object sender, ImageClickEventArgs e)
    {
        DownRecommend.Text = "2";
    }
    protected void ib_3_Click(object sender, ImageClickEventArgs e)
    {
        DownRecommend.Text = "3";
    }
    protected void ib_4_Click(object sender, ImageClickEventArgs e)
    {
        DownRecommend.Text = "4";
    }
    protected void ib_5_Click(object sender, ImageClickEventArgs e)
    {
        DownRecommend.Text = "5";
    }
    protected void upload_Click(object sender, EventArgs e)
    {
        if (Session["UserID"] != null)
        {
            /*获取上传的资料 */
            //根据选择分类获取分类值
            if (DownRecommend.Text.Trim() != "")
            {
                int typeID = Convert.ToInt32(TypeName.SelectedValue);
                string downUrl = DownUrl.Text.Trim();
                string downIntro = DownIntro.Text.Trim();
                string downTitle = DownTitle.Text.Trim();
                string downFormat = DownFormat.SelectedValue;
                string downSize =DownSize.Text.Trim();
                int downRecommend = Convert.ToInt32(DownRecommend.Text);

                if (downTitle.Length <= 50)
                {
                    try
                    {
                        //执行存储过程,返回bool值
                        mf.UpLoadMp4Data(typeID, downTitle, downFormat, downUrl, downSize, downIntro, downRecommend);
                        Response.Write("<script>alert(\"上传成功！\")</script>");
                        select.Visible = true;
                    }
                    catch (Exception ex)
                    {
                        Response.Write("<script>alert(\"上传失败！\")</script>");
                        //throw new Exception(ex.Message, ex);
                    }
                }
                else
                {
                    Response.Write("<script>alert(\"影片名称超过５０！\")</script>");
                }
            }
            else
            {
                Response.Write("<script>alert(\"推荐指数不能为空！\")</script>");
            }
        }
        else
        {
            Response.Write("<script>alert(\"您还没有登陆，请登陆后上传！\")</script>");
        }
    }
}