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

namespace Fm.Bussiness
{
    public class sys_user_user
    {
        public sys_user_user()
        { }
        /// <summary>
        /// 新会员信息添加
        /// </summary>
        /// <param name="u_name"></param>
        /// <param name="u_pass"></param>
        /// <param name="u_nc"></param>
        /// <param name="u_aqm"></param>
        /// <param name="u_mon"></param>
        /// <param name="email"></param>
        /// <returns></returns>
        public int sys_user_add(Fm.EntityClass.User user)
        {
            DbCommand db = DataAccess.DataAccess.db.GetStoredProcCommand("Query_Fm_user_ADD");
            DataAccess.DataAccess.db.AddOutParameter(db,"@u_id",DbType.Int32,user.u_id);
            DataAccess.DataAccess.db.AddInParameter(db,"@u_name",DbType.String,user.u_name);
            DataAccess.DataAccess.db.AddInParameter(db,"@u_pass",DbType.String,user.u_pass);
            DataAccess.DataAccess.db.AddInParameter(db,"@u_nc",DbType.String,user.u_nc);
            DataAccess.DataAccess.db.AddInParameter(db,"@u_mail",DbType.String,user.u_mail);
            DataAccess.DataAccess.GetData.Query<DbCommand>(db);
            user.u_id = int.Parse(db.Parameters["@u_id"].Value.ToString());
            return user.u_id;
        }
        /// <summary>
        /// 所属会员组添加
        /// </summary>
        /// <param name="u_id"></param>
        /// <param name="r_id"></param>
        /// <returns></returns>
        public bool sys_ur_add(Fm.EntityClass.Urcenter ur)
        {
            DbCommand db = DataAccess.DataAccess.db.GetStoredProcCommand("Query_Fm_urcenter_ADD");
            DataAccess.DataAccess.db.AddOutParameter(db,"@c_id",DbType.Int32,ur.c_id);
            DataAccess.DataAccess.db.AddInParameter(db,"@u_id",DbType.Int32,ur.u_id);
            DataAccess.DataAccess.db.AddInParameter(db,"@r_id",DbType.Int32,ur.r_id);
            return DataAccess.DataAccess.GetData.Query<DbCommand>(db);
        }
        /// <summary>
        /// 会员信息修改
        /// </summary>
        /// <param name="u_id"></param>
        /// <param name="u_pass"></param>
        /// <param name="u_nc"></param>
        /// <param name="u_aqm"></param>
        /// <param name="u_mon"></param>
        /// <param name="email"></param>
        /// <returns></returns>
        public bool sys_user_update(Fm.EntityClass.User user)
        {
            DbCommand db = DataAccess.DataAccess.db.GetStoredProcCommand("Query_Fm_user_Update");
            DataAccess.DataAccess.db.AddInParameter(db, "@u_id", DbType.Int32, user.u_id);
            DataAccess.DataAccess.db.AddInParameter(db, "@u_name", DbType.String, user.u_name);
            DataAccess.DataAccess.db.AddInParameter(db, "@u_pass", DbType.String, user.u_pass);
            DataAccess.DataAccess.db.AddInParameter(db, "@u_nc", DbType.String, user.u_nc);
            DataAccess.DataAccess.db.AddInParameter(db, "@u_mail", DbType.String, user.u_mail);
            return DataAccess.DataAccess.GetData.Query<DbCommand>(db);
        }
        /// <summary>
        /// 会员所属权限组信息修改
        /// </summary>
        /// <param name="u_id"></param>
        /// <param name="r_id"></param>
        /// <returns></returns>
        public bool sys_ur_update(Fm.EntityClass.Urcenter ur)
        {
            DbCommand db = DataAccess.DataAccess.db.GetStoredProcCommand("Query_Fm_urcenter_Update");
            DataAccess.DataAccess.db.AddInParameter(db, "@c_id", DbType.Int32, ur.c_id);
            DataAccess.DataAccess.db.AddInParameter(db, "@u_id", DbType.Int32, ur.u_id);
            DataAccess.DataAccess.db.AddInParameter(db, "@r_id", DbType.Int32, ur.r_id);
            return DataAccess.DataAccess.GetData.Query<DbCommand>(db);
        }
        /// <summary>
        /// 会员信息删除
        /// </summary>                                      
        /// <param name="u_id"></param>
        /// <returns></returns>
        public bool sys_user_del(Fm.EntityClass.User user)
        {
            DbCommand db = DataAccess.DataAccess.db.GetStoredProcCommand("Query_Fm_user_Delete");
            DataAccess.DataAccess.db.AddInParameter(db, "@u_id", DbType.Int32, user.u_id);
            return DataAccess.DataAccess.GetData.Query<DbCommand>(db);
        }
    }
}
