using System;
using System.Data;
using System.Configuration;
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;

/// <summary>
/// mp4 的摘要说明
/// </summary>
public class mp4films:System.Web.UI.Page
{
    DataBaseLayer db = new DataBaseLayer();
	public mp4films()
	{
		//
		// TODO: 在此处添加构造函数逻辑
		//
	}
    /// <summary>
    ///  用来截取字符串的长度，如果超过定义的长度，则用“…”省略。
    /// </summary>
    /// <param name="str">原字符串</param>
    /// <param name="length">要求显示的长度</param>
    /// <returns>返回修改后的字符串</returns>
    public string SubStr(string str, int length)
    {
        if (str.Trim().Length <= length)
        {
            return str;
        }
        else
        {
            string newStr;
            newStr = str.Substring(0, length);
            newStr += "…";
            return newStr;
        }
    }
    //显示星星图片
    public string ShowStars(object num)
    {
        return @"images/" + num + "star.gif";
    }
    //通过下载ID获取下载信息,返回SqlDataReader
    public SqlDataReader GetMp4DataByDownID(int DownID)
    {
        SqlParameter[] prams ={
            db.ParamBuilder("@DownID",DownID,SqlDbType.Int)
        };
        SqlDataReader dr = db.DataReader("Pr_Mp4_GetMp4DataByDownID", prams);
        return dr;
    }
    //通过下载ID获取下载信息,返回SqlDataReader
    public SqlDataReader GetMp4LookDataByMp4ID(int Mp4ID)
    {
        SqlParameter[] prams ={
            db.ParamBuilder("@Mp4ID",Mp4ID,SqlDbType.Int)
        };
        SqlDataReader dr = db.DataReader("Pr_Mp4_GetMp4LookDataByMp4ID", prams);
        return dr;
    }
    //增加用户点击数
    public void AddMp4Hits(int DownID)
    {
        SqlParameter[] prams ={
            db.ParamBuilder("@DownID",DownID,SqlDbType.Int)
        };
        db.ExecuteNonQuery("Pr_Mp4_AddHits", prams);
    }
    //增加用户点击数
    public void AddMp4LookHits(int Mp4ID)
    {
        SqlParameter[] prams ={
            db.ParamBuilder("@Mp4ID",Mp4ID,SqlDbType.Int)
        };
        db.ExecuteNonQuery("Pr_Mp4_AddMp4LookHits", prams);
    }
    //上传操作
    public void UpLoadMp4Data(int TypeID, string DownTitle, string DownFormat,string DownUrl, string DownSize, string DownIntro, int DownRecommend)
    {
        SqlParameter[] prams ={
            db.ParamBuilder("@TypeID",TypeID,SqlDbType.Int),
            db.ParamBuilder("@DownTitle",DownTitle,SqlDbType.VarChar),
            db.ParamBuilder("@DownFormat",DownFormat,SqlDbType.VarChar),
            db.ParamBuilder("@DownUrl",DownUrl,SqlDbType.VarChar),
            db.ParamBuilder("@UpdateTime",DateTime.Now,SqlDbType.DateTime),
            db.ParamBuilder("@DownSize",DownSize,SqlDbType.VarChar),
            db.ParamBuilder("@DownIntro",DownIntro,SqlDbType.VarChar),
            db.ParamBuilder("@DownReCommend",DownRecommend,SqlDbType.Int)
        };
        try
        {
            db.ExecuteNonQuery("Pr_Mp4_UploadMp4Data", prams);
        }
        catch(Exception ex)
        {
            throw new Exception(ex.Message, ex);
            //Response.Redirect(ErrorPage);
        }
    }
    //上传操作
    public void UpLoadMp4LookData(string Mp4Title,string Mp4Pic,string Mp4Url, string Mp4Size, string Mp4Intro)
    {
        SqlParameter[] prams ={
            db.ParamBuilder("@Mp4Title",Mp4Title,SqlDbType.VarChar),
            db.ParamBuilder("@Mp4Pic",Mp4Pic,SqlDbType.VarChar),
            db.ParamBuilder("@Mp4Url",Mp4Url,SqlDbType.VarChar),
            db.ParamBuilder("@UpdateTime",DateTime.Now,SqlDbType.DateTime),
            db.ParamBuilder("@Mp4Size",Mp4Size,SqlDbType.VarChar),
            db.ParamBuilder("@Mp4Intro",Mp4Intro,SqlDbType.Text)
        };
        try
        {
            db.ExecuteNonQuery("Pr_Mp4_UploadMp4LookData", prams);
        }
        catch (Exception ex)
        {
            throw new Exception(ex.Message, ex);
            //Response.Redirect(ErrorPage);
        }
    }

}
