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

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

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

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

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

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

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

		/// <summary>
		/// 得到一个对象实体，从缓存中
		/// </summary>
		public HaTeam.Dd.Model.Dd_Attention GetModelByCache(int Attention_ID)
		{
			
			string CacheKey = "Dd_AttentionModel-" + Attention_ID;
			object objModel = DataCache.GetCache(CacheKey);
			if (objModel == null)
			{
				try
				{
					objModel = dal.GetModel(Attention_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_Attention)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_Attention> GetModelList(string strWhere)
		{
			DataSet ds = dal.GetList(strWhere);
			return DataTableToList(ds.Tables[0]);
		}
		/// <summary>
		/// 获得数据列表
		/// </summary>
		public List<HaTeam.Dd.Model.Dd_Attention> DataTableToList(DataTable dt)
		{
			List<HaTeam.Dd.Model.Dd_Attention> modelList = new List<HaTeam.Dd.Model.Dd_Attention>();
			int rowsCount = dt.Rows.Count;
			if (rowsCount > 0)
			{
				HaTeam.Dd.Model.Dd_Attention model;
				for (int n = 0; n < rowsCount; n++)
				{
					model = new HaTeam.Dd.Model.Dd_Attention();
					if(dt.Rows[n]["Attention_ID"].ToString()!="")
					{
						model.Attention_ID=int.Parse(dt.Rows[n]["Attention_ID"].ToString());
					}
					if(dt.Rows[n]["Attention_UerID"].ToString()!="")
					{
						model.Attention_UerID=int.Parse(dt.Rows[n]["Attention_UerID"].ToString());
					}
					if(dt.Rows[n]["Attented_By_user"].ToString()!="")
					{
						model.Attented_By_user=int.Parse(dt.Rows[n]["Attented_By_user"].ToString());
					}
					if(dt.Rows[n]["Attention_BlackList"].ToString()!="")
					{
						model.Attention_BlackList=int.Parse(dt.Rows[n]["Attention_BlackList"].ToString());
					}
					model.Attention_Guid=dt.Rows[n]["Attention_Guid"].ToString();
					if(dt.Rows[n]["Attention_Datetime"].ToString()!="")
					{
						model.Attention_Datetime=DateTime.Parse(dt.Rows[n]["Attention_Datetime"].ToString());
					}
					if(dt.Rows[n]["Attention_UpDatetime"].ToString()!="")
					{
						model.Attention_UpDatetime=DateTime.Parse(dt.Rows[n]["Attention_UpDatetime"].ToString());
					}
					if(dt.Rows[n]["Attention_Verify"].ToString()!="")
					{
						model.Attention_Verify=int.Parse(dt.Rows[n]["Attention_Verify"].ToString());
					}
					if(dt.Rows[n]["Attention_Lock"].ToString()!="")
					{
						model.Attention_Lock=int.Parse(dt.Rows[n]["Attention_Lock"].ToString());
					}
					if(dt.Rows[n]["Attention_State"].ToString()!="")
					{
						model.Attention_State=int.Parse(dt.Rows[n]["Attention_State"].ToString());
					}
					if(dt.Rows[n]["Attention_Delete"].ToString()!="")
					{
						model.Attention_Delete=int.Parse(dt.Rows[n]["Attention_Delete"].ToString());
					}
					if(dt.Rows[n]["Attention_Count"].ToString()!="")
					{
						model.Attention_Count=int.Parse(dt.Rows[n]["Attention_Count"].ToString());
					}
					if(dt.Rows[n]["Attention_Order"].ToString()!="")
					{
						model.Attention_Order=int.Parse(dt.Rows[n]["Attention_Order"].ToString());
					}
					model.Attention_Remark=dt.Rows[n]["Attention_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
	}
}

