using System;
using System.Data;
using System.Data.SqlClient;
using Microsoft.ApplicationBlocks.Data;

namespace SK.MemberDAL
{
	/// <summary>
	/// WebLog 的摘要说明。
	/// </summary>
	public class WebLog
	{
		/// <summary>
		/// 网站日志
		/// </summary>
		public WebLog()
		{
			//
			// TODO: 在此处添加构造函数逻辑
			//
		}
		/// <summary>
		/// 增加LOG
		/// </summary>
		/// <param name="MemberID">用户编号</param>
		/// <param name="Content">内容</param>
		/// <param name="LogType">LOG类型</param>
		public void Add(object MemberID,object Content,object LogType)
		{
			SqlParameter[] oParms =new SqlParameter[3];
			oParms[0] = new SqlParameter("@MemberID",MemberID);
			oParms[1] = new SqlParameter("@Content",Content);
			oParms[2] = new SqlParameter("@LogType",LogType);

			SqlHelper.ExecuteNonQuery(Data.ConnString,CommandType.Text,"insert into WebLog(MemberID,Content,LogType,CreateTime) values(@MemberID,@Content,@LogType,getdate())",oParms);
		}
		/// <summary>
		/// 删除指定的Log
		/// </summary>
		/// <param name="WebLogID">编号</param>
		public void Delete(object WebLogID)
		{
			SqlParameter[] oParms =new SqlParameter[1];
			oParms[0] = new SqlParameter("@WebLogID",WebLogID);

			SqlHelper.ExecuteNonQuery(Data.ConnString,CommandType.Text,"delete WebLog where WebLogID=@WebLogID",oParms);
		}
		/// <summary>
		/// 删除所有的LOG
		/// </summary>
		public void DeleteAll()
		{
			SqlHelper.ExecuteNonQuery(Data.ConnString,CommandType.Text,"delete WebLog");
		}
		/// <summary>
		/// 返回LOG的指定页
		/// </summary>
		/// <param name="PageSize">每页行数</param>
		/// <param name="PageIndex">页码</param>
		/// <returns></returns>
		public DataSet List(object PageSize,object PageIndex)
		{
			string spName;
			SqlParameter[] oParms;
			spName = "WebLog_List";
			oParms = SqlHelperParameterCache.GetSpParameterSet(Data.ConnString, spName);
			oParms[0].Value = PageSize;
			oParms[1].Value = PageIndex;
			oParms[2].Value = 0;

			return SqlHelper.ExecuteDataset(Data.ConnString, spName, oParms);		
		}
		/// <summary>
		/// 返回LOG记录数
		/// </summary>
		/// <returns></returns>
		public int List_Count()
		{
			string spName;
			SqlParameter[] oParms;
			spName = "WebLog_List";
			oParms = SqlHelperParameterCache.GetSpParameterSet(Data.ConnString, spName);
			oParms[0].Value = 0;
			oParms[1].Value = 0;
			oParms[2].Value = 1;

			return Convert.ToInt32(SqlHelper.ExecuteScalar(Data.ConnString, spName, oParms));
		}
		/// <summary>
		/// 返回指定类型的LOG记录
		/// </summary>
		/// <param name="WebType">类型</param>
		/// <param name="PageSize">每页记录数</param>
		/// <param name="PageIndex">页码</param>
		/// <returns></returns>
		public DataSet ListofType(object WebType,object PageSize,object PageIndex)
		{
			string spName;
			SqlParameter[] oParms;
			spName = "WebLogofType_List";
			oParms = SqlHelperParameterCache.GetSpParameterSet(Data.ConnString, spName);
			oParms[0].Value = WebType;
			oParms[1].Value = PageSize;
			oParms[2].Value = PageIndex;
			oParms[3].Value = 0;

			return SqlHelper.ExecuteDataset(Data.ConnString, spName, oParms);		
		}
		/// <summary>
		/// 返回指定类型的记录数
		/// </summary>
		/// <returns></returns>
		public int ListofType_Count(object WebType)
		{
			string spName;
			SqlParameter[] oParms;
			spName = "WebLogofType_List";
			oParms = SqlHelperParameterCache.GetSpParameterSet(Data.ConnString, spName);
			oParms[0].Value = WebType;
			oParms[1].Value = 0;
			oParms[2].Value = 0;
			oParms[3].Value = 1;

			return Convert.ToInt32(SqlHelper.ExecuteScalar(Data.ConnString, spName, oParms));
		}
	}
}

