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

namespace SK.MemberDAL
{
	/// <summary>
	/// Province 的摘要说明。
	/// </summary>
	public class Province
	{
		public Province()
		{
			//
			// TODO: 在此处添加构造函数逻辑
			//
		}
		public DataSet List()
		{
			return SqlHelper.ExecuteDataset(Data.ConnString,CommandType.Text,"select * from Province");
		}
		public DataSet List(object CountryID)
		{
			SqlParameter[] oParms = new SqlParameter[1];
			oParms[0] = new SqlParameter("@CountryID",CountryID);

			return SqlHelper.ExecuteDataset(Data.ConnString,CommandType.Text,"select * from Province where CountryID=@CountryID",oParms);
		}
		public DataRow Info(object ProvinceID)
		{
			SqlParameter[] oParms = new SqlParameter[1];
			oParms[0] = new SqlParameter("@ProvinceID",ProvinceID);

			using(DataSet ds = SqlHelper.ExecuteDataset(Data.ConnString,CommandType.Text,"select * from Province where ProvinceID=@ProvinceID",oParms))
			{
				if(ds.Tables[0].Rows.Count>0)
					return ds.Tables[0].Rows[0];
				else
					return null;
			}
		}
		public void Add(object CountryID,object ProvinceName)
		{
			SqlParameter[] oParms = new SqlParameter[2];
			oParms[0] = new SqlParameter("@CountryID",CountryID);
			oParms[1] = new SqlParameter("@ProvinceName",ProvinceName);

			SqlHelper.ExecuteNonQuery(Data.ConnString,CommandType.Text,"insert into Province(CountryID,ProvinceName) values(@CountryID,@ProvinceName)",oParms);

		}
		public void Delete(object ProvinceID)
		{
			string spName;
			SqlParameter[] oParms;
			spName = "Province_Delete";
			oParms = SqlHelperParameterCache.GetSpParameterSet(Data.ConnString, spName);
			oParms[0].Value=ProvinceID;
			
			SqlHelper.ExecuteNonQuery(Data.ConnString, spName, oParms);
		}
		public void Update(object ProvinceID,object ProvinceName)
		{
			SqlParameter[] oParms = new SqlParameter[2];
			oParms[0] = new SqlParameter("@ProvinceID",ProvinceID);
			oParms[1] = new SqlParameter("@ProvinceName",ProvinceName);

			SqlHelper.ExecuteNonQuery(Data.ConnString,CommandType.Text,"update Province set ProvinceName=@ProvinceName where  ProvinceID=@ProvinceID",oParms);
		}
	}
}
