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

namespace SK.MemberDAL
{
	/// <summary>
	/// Main 的摘要说明。
	/// </summary>
	public class Main
	{
		/// <summary>
		/// 
		/// </summary>
		public Main()
		{
			//
			// TODO: 在此处添加构造函数逻辑
			//
		}
		/// <summary>
		/// 更新系统常量值
		/// </summary>
		/// <param name="Name">常量名</param>
		/// <param name="Value">常量值</param>
		public void Update(object Name,object Value)
		{
			/*SqlParameter[] oParms =new SqlParameter[2];
			oParms[0] = new SqlParameter("@Name",Name);
			oParms[1] = new SqlParameter("@Value",Value);
			
			SqlHelper.ExecuteNonQuery(Data.ConnString, CommandType.Text,"update [Main] set [Value]=@Value where [Name]=@Name", oParms);
			*/
			string spName;
			SqlParameter[] oParms;
			spName = "Main_Update";
			oParms = SqlHelperParameterCache.GetSpParameterSet(Data.ConnString, spName);
			oParms[0].Value=Name;
			oParms[1].Value=Value;
			
			SqlHelper.ExecuteNonQuery(Data.ConnString, spName, oParms);
		}
		/// <summary>
		/// 返回常量值
		/// </summary>
		/// <param name="Name">常量名</param>
		/// <returns>常量值</returns>
		public object GetValue(object Name)
		{
			SqlParameter[] oParms =new SqlParameter[1];
			oParms[0] = new SqlParameter("@Name",Name);

			return SqlHelper.ExecuteScalar(Data.ConnString,CommandType.Text,"select [Value] from Main where [Name]=@Name",oParms);
		}
		public void Add(object Name,object Value)
		{
			SqlParameter[] oParms =new SqlParameter[2];
			oParms[0] = new SqlParameter("@Name",Name);
			oParms[1] = new SqlParameter("@Value",Value);

			SqlHelper.ExecuteNonQuery(Data.ConnString, CommandType.Text , "insert into [Main]([Name],[Value]) values(@Name,@Value)",oParms);
		}

	}
}
