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

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

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

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

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

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

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

		/// <summary>
		/// 得到一个对象实体，从缓存中
		/// </summary>
		public HaTeam.Dd.Model.Dd_Reprint GetModelByCache(int Reprint_ID)
		{
			
			string CacheKey = "Dd_ReprintModel-" + Reprint_ID;
			object objModel = DataCache.GetCache(CacheKey);
			if (objModel == null)
			{
				try
				{
					objModel = dal.GetModel(Reprint_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_Reprint)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_Reprint> GetModelList(string strWhere)
		{
			DataSet ds = dal.GetList(strWhere);
			return DataTableToList(ds.Tables[0]);
		}
		/// <summary>
		/// 获得数据列表
		/// </summary>
		public List<HaTeam.Dd.Model.Dd_Reprint> DataTableToList(DataTable dt)
		{
			List<HaTeam.Dd.Model.Dd_Reprint> modelList = new List<HaTeam.Dd.Model.Dd_Reprint>();
			int rowsCount = dt.Rows.Count;
			if (rowsCount > 0)
			{
				HaTeam.Dd.Model.Dd_Reprint model;
				for (int n = 0; n < rowsCount; n++)
				{
					model = new HaTeam.Dd.Model.Dd_Reprint();
					if(dt.Rows[n]["Reprint_ID"].ToString()!="")
					{
						model.Reprint_ID=int.Parse(dt.Rows[n]["Reprint_ID"].ToString());
					}
					if(dt.Rows[n]["Reprint_ArticleID"].ToString()!="")
					{
						model.Reprint_ArticleID=int.Parse(dt.Rows[n]["Reprint_ArticleID"].ToString());
					}
					if(dt.Rows[n]["Reprint_type"].ToString()!="")
					{
						model.Reprint_type=int.Parse(dt.Rows[n]["Reprint_type"].ToString());
					}
					if(dt.Rows[n]["Reprint_UserID"].ToString()!="")
					{
						model.Reprint_UserID=int.Parse(dt.Rows[n]["Reprint_UserID"].ToString());
					}
					if(dt.Rows[n]["Reprint_CopyFrom"].ToString()!="")
					{
						model.Reprint_CopyFrom=int.Parse(dt.Rows[n]["Reprint_CopyFrom"].ToString());
					}
					if(dt.Rows[n]["Reprint_OriginID"].ToString()!="")
					{
						model.Reprint_OriginID=int.Parse(dt.Rows[n]["Reprint_OriginID"].ToString());
					}
					model.Reprint_Guid=dt.Rows[n]["Reprint_Guid"].ToString();
					if(dt.Rows[n]["Reprint_Datetime"].ToString()!="")
					{
						model.Reprint_Datetime=DateTime.Parse(dt.Rows[n]["Reprint_Datetime"].ToString());
					}
					if(dt.Rows[n]["Reprint_UpDatetime"].ToString()!="")
					{
						model.Reprint_UpDatetime=DateTime.Parse(dt.Rows[n]["Reprint_UpDatetime"].ToString());
					}
					if(dt.Rows[n]["Reprint_Verify"].ToString()!="")
					{
						model.Reprint_Verify=int.Parse(dt.Rows[n]["Reprint_Verify"].ToString());
					}
					if(dt.Rows[n]["Reprint_Lock"].ToString()!="")
					{
						model.Reprint_Lock=int.Parse(dt.Rows[n]["Reprint_Lock"].ToString());
					}
					if(dt.Rows[n]["Reprint_State"].ToString()!="")
					{
						model.Reprint_State=int.Parse(dt.Rows[n]["Reprint_State"].ToString());
					}
					if(dt.Rows[n]["Reprint_Delete"].ToString()!="")
					{
						model.Reprint_Delete=int.Parse(dt.Rows[n]["Reprint_Delete"].ToString());
					}
					if(dt.Rows[n]["Reprint_Count"].ToString()!="")
					{
						model.Reprint_Count=int.Parse(dt.Rows[n]["Reprint_Count"].ToString());
					}
					if(dt.Rows[n]["Reprint_Order"].ToString()!="")
					{
						model.Reprint_Order=int.Parse(dt.Rows[n]["Reprint_Order"].ToString());
					}
					model.Reprint_Remark=dt.Rows[n]["Reprint_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
	}
}

