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

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

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

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

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

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

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

		/// <summary>
		/// 得到一个对象实体，从缓存中
		/// </summary>
		public HaTeam.Dd.Model.Dd_Picture GetModelByCache(int Picture_ID)
		{
			
			string CacheKey = "Dd_PictureModel-" + Picture_ID;
			object objModel = DataCache.GetCache(CacheKey);
			if (objModel == null)
			{
				try
				{
					objModel = dal.GetModel(Picture_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_Picture)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_Picture> GetModelList(string strWhere)
		{
			DataSet ds = dal.GetList(strWhere);
			return DataTableToList(ds.Tables[0]);
		}
		/// <summary>
		/// 获得数据列表
		/// </summary>
		public List<HaTeam.Dd.Model.Dd_Picture> DataTableToList(DataTable dt)
		{
			List<HaTeam.Dd.Model.Dd_Picture> modelList = new List<HaTeam.Dd.Model.Dd_Picture>();
			int rowsCount = dt.Rows.Count;
			if (rowsCount > 0)
			{
				HaTeam.Dd.Model.Dd_Picture model;
				for (int n = 0; n < rowsCount; n++)
				{
					model = new HaTeam.Dd.Model.Dd_Picture();
					if(dt.Rows[n]["Picture_ID"].ToString()!="")
					{
						model.Picture_ID=int.Parse(dt.Rows[n]["Picture_ID"].ToString());
					}
					if(dt.Rows[n]["User_ID"].ToString()!="")
					{
						model.User_ID=int.Parse(dt.Rows[n]["User_ID"].ToString());
					}
					model.Picture_Address=dt.Rows[n]["Picture_Address"].ToString();
					model.Picture_Discription=dt.Rows[n]["Picture_Discription"].ToString();
					model.Picture_Tag=dt.Rows[n]["Picture_Tag"].ToString();
					if(dt.Rows[n]["Picture_OriginId"].ToString()!="")
					{
						model.Picture_OriginId=int.Parse(dt.Rows[n]["Picture_OriginId"].ToString());
					}
					if(dt.Rows[n]["Picture_PublishMode"].ToString()!="")
					{
						model.Picture_PublishMode=int.Parse(dt.Rows[n]["Picture_PublishMode"].ToString());
					}
					if(dt.Rows[n]["Picture_PutTop"].ToString()!="")
					{
						if((dt.Rows[n]["Picture_PutTop"].ToString()=="1")||(dt.Rows[n]["Picture_PutTop"].ToString().ToLower()=="true"))
						{
						model.Picture_PutTop=true;
						}
						else
						{
							model.Picture_PutTop=false;
						}
					}
					if(dt.Rows[n]["Picture_Fever"].ToString()!="")
					{
						model.Picture_Fever=int.Parse(dt.Rows[n]["Picture_Fever"].ToString());
					}
					model.Picture_Guid=dt.Rows[n]["Picture_Guid"].ToString();
					if(dt.Rows[n]["Picture_Datetime"].ToString()!="")
					{
						model.Picture_Datetime=DateTime.Parse(dt.Rows[n]["Picture_Datetime"].ToString());
					}
					if(dt.Rows[n]["Picture_UpDatetime"].ToString()!="")
					{
						model.Picture_UpDatetime=DateTime.Parse(dt.Rows[n]["Picture_UpDatetime"].ToString());
					}
					if(dt.Rows[n]["Picture_Verify"].ToString()!="")
					{
						model.Picture_Verify=int.Parse(dt.Rows[n]["Picture_Verify"].ToString());
					}
					if(dt.Rows[n]["Picture_Lock"].ToString()!="")
					{
						model.Picture_Lock=int.Parse(dt.Rows[n]["Picture_Lock"].ToString());
					}
					if(dt.Rows[n]["Picture_State"].ToString()!="")
					{
						model.Picture_State=int.Parse(dt.Rows[n]["Picture_State"].ToString());
					}
					if(dt.Rows[n]["Picture_Delete"].ToString()!="")
					{
						model.Picture_Delete=int.Parse(dt.Rows[n]["Picture_Delete"].ToString());
					}
					if(dt.Rows[n]["Picture_Count"].ToString()!="")
					{
						model.Picture_Count=int.Parse(dt.Rows[n]["Picture_Count"].ToString());
					}
					if(dt.Rows[n]["Picture_Order"].ToString()!="")
					{
						model.Picture_Order=int.Parse(dt.Rows[n]["Picture_Order"].ToString());
					}
					model.Picture_Remark=dt.Rows[n]["Picture_Remark"].ToString();
					model.Picture_Empty=dt.Rows[n]["Picture_Empty"].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
	}
}

