using System;
using System.Data;
using System.Collections.Generic;
using DotNet.FrameWork.Data;
using HaTeam.Dd.Model;
namespace HaTeam.Dd.BLL
{
	/// <summary>
	/// Dd_Video
	/// </summary>
	public partial class Dd_Video
	{
		private readonly HaTeam.Dd.DAL.Dd_Video dal=new HaTeam.Dd.DAL.Dd_Video();
		public Dd_Video()
		{}
		#region  Method

		/// <summary>
		/// 得到最大ID
		/// </summary>
		public int GetMaxId()
		{
			return dal.GetMaxId();
		}

		/// <summary>
		/// 是否存在该记录
		/// </summary>
		public bool Exists(int Video_ID)
		{
			return dal.Exists(Video_ID);
		}

		/// <summary>
		/// 增加一条数据
		/// </summary>
		public int  Add(HaTeam.Dd.Model.Dd_Video model)
		{
			return dal.Add(model);
		}

		/// <summary>
		/// 更新一条数据
		/// </summary>
		public bool Update(HaTeam.Dd.Model.Dd_Video model)
		{
			return dal.Update(model);
		}

		/// <summary>
		/// 删除一条数据
		/// </summary>
		public bool Delete(int Video_ID)
		{
			
			return dal.Delete(Video_ID);
		}
		/// <summary>
		/// 删除一条数据
		/// </summary>
		public bool DeleteList(string Video_IDlist )
		{
			return dal.DeleteList(Video_IDlist );
		}

		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public HaTeam.Dd.Model.Dd_Video GetModel(int Video_ID)
		{
			
			return dal.GetModel(Video_ID);
		}

		/// <summary>
		/// 得到一个对象实体，从缓存中
		/// </summary>
		public HaTeam.Dd.Model.Dd_Video GetModelByCache(int Video_ID)
		{
			
			string CacheKey = "Dd_VideoModel-" + Video_ID;
			object objModel = DataCache.GetCache(CacheKey);
			if (objModel == null)
			{
				try
				{
					objModel = dal.GetModel(Video_ID);
					if (objModel != null)
					{
						int ModelCache = ConfigHelper.GetConfigInt("ModelCache");
						DataCache.SetCache(CacheKey, objModel, DateTime.Now.AddMinutes(ModelCache), TimeSpan.Zero);
					}
				}
				catch{}
			}
			return (HaTeam.Dd.Model.Dd_Video)objModel;
		}

		/// <summary>
		/// 获得数据列表
		/// </summary>
		public DataSet GetList(string strWhere)
		{
			return dal.GetList(strWhere);
		}
		/// <summary>
		/// 获得前几行数据
		/// </summary>
		public DataSet GetList(int Top,string strWhere,string filedOrder)
		{
			return dal.GetList(Top,strWhere,filedOrder);
		}
		/// <summary>
		/// 获得数据列表
		/// </summary>
		public List<HaTeam.Dd.Model.Dd_Video> GetModelList(string strWhere)
		{
			DataSet ds = dal.GetList(strWhere);
			return DataTableToList(ds.Tables[0]);
		}
		/// <summary>
		/// 获得数据列表
		/// </summary>
		public List<HaTeam.Dd.Model.Dd_Video> DataTableToList(DataTable dt)
		{
			List<HaTeam.Dd.Model.Dd_Video> modelList = new List<HaTeam.Dd.Model.Dd_Video>();
			int rowsCount = dt.Rows.Count;
			if (rowsCount > 0)
			{
				HaTeam.Dd.Model.Dd_Video model;
				for (int n = 0; n < rowsCount; n++)
				{
					model = new HaTeam.Dd.Model.Dd_Video();
					if(dt.Rows[n]["Video_ID"].ToString()!="")
					{
						model.Video_ID=int.Parse(dt.Rows[n]["Video_ID"].ToString());
					}
					if(dt.Rows[n]["User_ID"].ToString()!="")
					{
						model.User_ID=int.Parse(dt.Rows[n]["User_ID"].ToString());
					}
					model.Video_Address=dt.Rows[n]["Video_Address"].ToString();
					model.Video_Radiourl=dt.Rows[n]["Video_Radiourl"].ToString();
					model.Video_Imageurl=dt.Rows[n]["Video_Imageurl"].ToString();
					model.Video_Description=dt.Rows[n]["Video_Description"].ToString();
					model.Video_Tag=dt.Rows[n]["Video_Tag"].ToString();
					if(dt.Rows[n]["Video_OriginId"].ToString()!="")
					{
						model.Video_OriginId=int.Parse(dt.Rows[n]["Video_OriginId"].ToString());
					}
					if(dt.Rows[n]["Video_PublishMode"].ToString()!="")
					{
						model.Video_PublishMode=int.Parse(dt.Rows[n]["Video_PublishMode"].ToString());
					}
					if(dt.Rows[n]["Video_PutTop"].ToString()!="")
					{
						if((dt.Rows[n]["Video_PutTop"].ToString()=="1")||(dt.Rows[n]["Video_PutTop"].ToString().ToLower()=="true"))
						{
						model.Video_PutTop=true;
						}
						else
						{
							model.Video_PutTop=false;
						}
					}
					if(dt.Rows[n]["Video_Fever"].ToString()!="")
					{
						model.Video_Fever=int.Parse(dt.Rows[n]["Video_Fever"].ToString());
					}
					model.Video_Guid=dt.Rows[n]["Video_Guid"].ToString();
					if(dt.Rows[n]["Video_Datetime"].ToString()!="")
					{
						model.Video_Datetime=DateTime.Parse(dt.Rows[n]["Video_Datetime"].ToString());
					}
					if(dt.Rows[n]["Video_UpDatetime"].ToString()!="")
					{
						model.Video_UpDatetime=DateTime.Parse(dt.Rows[n]["Video_UpDatetime"].ToString());
					}
					if(dt.Rows[n]["Video_Verify"].ToString()!="")
					{
						model.Video_Verify=int.Parse(dt.Rows[n]["Video_Verify"].ToString());
					}
					if(dt.Rows[n]["Video_Lock"].ToString()!="")
					{
						model.Video_Lock=int.Parse(dt.Rows[n]["Video_Lock"].ToString());
					}
					if(dt.Rows[n]["Video_State"].ToString()!="")
					{
						model.Video_State=int.Parse(dt.Rows[n]["Video_State"].ToString());
					}
					if(dt.Rows[n]["Video_Delete"].ToString()!="")
					{
						model.Video_Delete=int.Parse(dt.Rows[n]["Video_Delete"].ToString());
					}
					if(dt.Rows[n]["Video_Count"].ToString()!="")
					{
						model.Video_Count=int.Parse(dt.Rows[n]["Video_Count"].ToString());
					}
					if(dt.Rows[n]["Video_Order"].ToString()!="")
					{
						model.Video_Order=int.Parse(dt.Rows[n]["Video_Order"].ToString());
					}
					model.Video_Remark=dt.Rows[n]["Video_Remark"].ToString();
					modelList.Add(model);
				}
			}
			return modelList;
		}

		/// <summary>
		/// 获得数据列表
		/// </summary>
		public DataSet GetAllList()
		{
			return GetList("");
		}

		/// <summary>
		/// 分页获取数据列表
		/// </summary>
		//public DataSet GetList(int PageSize,int PageIndex,string strWhere)
		//{
			//return dal.GetList(PageSize,PageIndex,strWhere);
		//}

		#endregion  Method
	}
}

