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

namespace SK.MemberDAL
{
	/// <summary>
	/// Pay 的摘要说明。
	/// </summary>
	public class Payment
	{
		public Payment()
		{
			//
			// TODO: 在此处添加构造函数逻辑
			//
		}
		public void Add(object MemberID,object v_amount,object v_oid,object v_pmode,object v_pstatus,
			object v_pstring,object v_moneytype,object ProductID,object PayMonth,object PayPoint,object Operate)
		{
			/*SqlParameter[] oParms =new SqlParameter[11];
			oParms[0] = new SqlParameter("@MemberID",MemberID);
			oParms[1] = new SqlParameter("@v_amount",v_amount);
			oParms[2] = new SqlParameter("@v_oid",v_oid);
			oParms[3] = new SqlParameter("@v_pmode",v_pmode);
			oParms[4] = new SqlParameter("@v_pstatus",v_pstatus);
			oParms[5] = new SqlParameter("@v_pstring",v_pstring);
			oParms[6] = new SqlParameter("@v_moneytype",v_moneytype);
			oParms[7] = new SqlParameter("@ProductID",ProductID);
			oParms[8] = new SqlParameter("@PayMonth",PayMonth);
			oParms[9] = new SqlParameter("@PayPoint",PayPoint);
			oParms[10] = new SqlParameter("@Operate",Operate);

			SqlHelper.ExecuteNonQuery(Data.ConnString,CommandType.Text,"INSERT INTO Payment([MemberID], [PayTime], [v_amount], [v_oid], [v_pmode], [v_pstatus], [v_pstring], [v_moneytype], [Operate], [ProductID], [PayMonth], [PayPoint]) values(@MemberID,getdate(),@v_amount,@v_oid,@v_pmode,@v_pstatus,@v_pstring,@v_moneytype,@Operate,@ProductID,@PayMonth,@PayPoint)",oParms);
			*/
			string spName;
			SqlParameter[] oParms;
			spName = "Payment_Add";
			oParms = SqlHelperParameterCache.GetSpParameterSet(Data.ConnString, spName);
			oParms[0].Value=MemberID;
			oParms[1].Value=v_amount;
			oParms[2].Value=v_oid;
			oParms[3].Value=v_pmode;
			oParms[4].Value=v_pstatus;
			oParms[5].Value=v_pstring;
			oParms[6].Value=v_moneytype;
			oParms[7].Value=ProductID;
			oParms[8].Value=PayMonth;
			oParms[9].Value=PayPoint;
			oParms[10].Value=Operate;
			
			SqlHelper.ExecuteNonQuery(Data.ConnString, spName, oParms);
		}
		public bool HasBillID(object v_oid)
		{
			SqlParameter[] oParms = new SqlParameter[1];
			oParms[0] = new SqlParameter("@v_oid",v_oid);

			return Convert.ToInt32(SqlHelper.ExecuteScalar(Data.ConnString,CommandType.Text,"select count(PaymentID) from Payment where v_oid=@v_oid",oParms))>0;
		}
		public DataSet List(object PageSize,object PageIndex)
		{
			string spName;
			SqlParameter[] oParms;
			spName = "Payment_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);
		}
		public int List_Count()
		{
			string spName;
			SqlParameter[] oParms;
			spName = "Payment_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));
		}
		public void Delete(object PaymentID)
		{
			SqlParameter[] oParms = new SqlParameter[1];
			oParms[0] = new SqlParameter("@PaymentID",PaymentID);

			SqlHelper.ExecuteNonQuery(Data.ConnString,CommandType.Text,"Delete Payment where PaymentID=@PaymentID",oParms);
		}
	}
}
