using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;
using System.Data.Common;
using System.Data;
using Fm.DataAccess;

namespace Fm.Bussiness
{
    public class member
    {
        /// <summary>
        /// 删除原有的角色权限
        /// </summary>
        /// <param name="power"></param>
        /// <returns></returns>
        public Boolean MemberPowerDel(Fm.EntityClass.Member_power power)
        {
            DbCommand db = DataAccess.DataAccess.db.GetStoredProcCommand("Query_Fm_member_power_Delete");
          
            DataAccess.DataAccess.db.AddInParameter(db, "@rid", DbType.Int32, power.rid);
            return DataAccess.DataAccess.GetData.Query<DbCommand>(db);
        }
        /// <summary>
        /// 会员组角色权限的添加
        /// </summary>
        /// <param name="power"></param>
        /// <returns></returns>
        public Boolean MemberPowerAdd(Fm.EntityClass.Member_power power)
        {
            DbCommand db = DataAccess.DataAccess.db.GetStoredProcCommand("Query_Fm_member_power_ADD");
            DataAccess.DataAccess.db.AddOutParameter(db,"@pid",DbType.Int32,power.pid);
            DataAccess.DataAccess.db.AddInParameter(db,"@mid",DbType.Int32,power.mid);
            DataAccess.DataAccess.db.AddInParameter(db,"@rid",DbType.Int32,power.rid);
            return DataAccess.DataAccess.GetData.Query<DbCommand>(db);
        }
        /// <summary>
        /// 查询会员所属角色组
        /// </summary>
        /// <param name="uid"></param>
        /// <returns></returns>
        public DataView member_role(int uid)
        {
            DbCommand db = DataAccess.DataAccess.db.GetStoredProcCommand("Fm_member_urcenter");
            DataAccess.DataAccess.db.AddInParameter(db,"@uid",DbType.Int32,uid);
            return DataAccess.DataAccess.GetData.Select<DbCommand>(db) as DataView;
        }
        /// <summary>
        /// 查询会员所拥有的权限
        /// </summary>
        /// <param name="where"></param>
        /// <returns></returns>
        public DataView member_menu(string where)
        {
            DbCommand db = DataAccess.DataAccess.db.GetStoredProcCommand("Fm_member_menu_proc");
            DataAccess.DataAccess.db.AddInParameter(db, "@where", DbType.String, where);
            return DataAccess.DataAccess.GetData.Select<DbCommand>(db) as DataView;
        }
    }
}
