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

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

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

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

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

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

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

		/// <summary>
		/// 得到一个对象实体，从缓存中
		/// </summary>
		public HaTeam.Dd.Model.Dd_User GetModelByCache(int User_ID)
		{
			
			string CacheKey = "Dd_UserModel-" + User_ID;
			object objModel = DataCache.GetCache(CacheKey);
			if (objModel == null)
			{
				try
				{
					objModel = dal.GetModel(User_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_User)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_User> GetModelList(string strWhere)
		{
			DataSet ds = dal.GetList(strWhere);
			return DataTableToList(ds.Tables[0]);
		}
		/// <summary>
		/// 获得数据列表
		/// </summary>
		public List<HaTeam.Dd.Model.Dd_User> DataTableToList(DataTable dt)
		{
			List<HaTeam.Dd.Model.Dd_User> modelList = new List<HaTeam.Dd.Model.Dd_User>();
			int rowsCount = dt.Rows.Count;
			if (rowsCount > 0)
			{
				HaTeam.Dd.Model.Dd_User model;
				for (int n = 0; n < rowsCount; n++)
				{
					model = new HaTeam.Dd.Model.Dd_User();
					if(dt.Rows[n]["User_ID"].ToString()!="")
					{
						model.User_ID=int.Parse(dt.Rows[n]["User_ID"].ToString());
					}
					model.User_BlogName=dt.Rows[n]["User_BlogName"].ToString();
					model.User_Email=dt.Rows[n]["User_Email"].ToString();
					model.User_OriginPsw=dt.Rows[n]["User_OriginPsw"].ToString();
					model.User_Passwd=dt.Rows[n]["User_Passwd"].ToString();
					model.User_Attetion=dt.Rows[n]["User_Attetion"].ToString();
					if(dt.Rows[n]["User_ActivCondition"].ToString()!="")
					{
						model.User_ActivCondition=int.Parse(dt.Rows[n]["User_ActivCondition"].ToString());
					}
					model.User_HeadPhoto=dt.Rows[n]["User_HeadPhoto"].ToString();
					model.User_BlackList=dt.Rows[n]["User_BlackList"].ToString();
					model.User_LikeArticle=dt.Rows[n]["User_LikeArticle"].ToString();
					model.User_Guid=dt.Rows[n]["User_Guid"].ToString();
					if(dt.Rows[n]["User_Datetime"].ToString()!="")
					{
						model.User_Datetime=DateTime.Parse(dt.Rows[n]["User_Datetime"].ToString());
					}
					if(dt.Rows[n]["User_UpDatetime"].ToString()!="")
					{
						model.User_UpDatetime=DateTime.Parse(dt.Rows[n]["User_UpDatetime"].ToString());
					}
					if(dt.Rows[n]["User_Verify"].ToString()!="")
					{
						model.User_Verify=int.Parse(dt.Rows[n]["User_Verify"].ToString());
					}
					if(dt.Rows[n]["User_Lock"].ToString()!="")
					{
						model.User_Lock=int.Parse(dt.Rows[n]["User_Lock"].ToString());
					}
					if(dt.Rows[n]["User_State"].ToString()!="")
					{
						model.User_State=int.Parse(dt.Rows[n]["User_State"].ToString());
					}
					if(dt.Rows[n]["User_Delete"].ToString()!="")
					{
						model.User_Delete=int.Parse(dt.Rows[n]["User_Delete"].ToString());
					}
					if(dt.Rows[n]["User_Count"].ToString()!="")
					{
						model.User_Count=int.Parse(dt.Rows[n]["User_Count"].ToString());
					}
					if(dt.Rows[n]["User_Order"].ToString()!="")
					{
						model.User_Order=int.Parse(dt.Rows[n]["User_Order"].ToString());
					}
					model.User_Remark=dt.Rows[n]["User_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
	}
}

