using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using JuSNS.Model;
using JuSNS.Common;
using JuSNS.Factory;

namespace JuSNS.Home
{
    public class MyInfo
    {
        private IMyInfo dal;
        /// <summary>
        /// 构造函数
        /// </summary>
        public MyInfo()
        {
            dal = DataAccess.CreateMyInfo();
        }


         /// <summary>
        /// 网络设置
        /// </summary>
        /// <param name="provice">省</param>
        /// <param name="city">市</param>
        /// <returns></returns>
        public int UpdateNetSet(int provice, int city, int userid)
        {
            return dal.UpdateNetSet(provice,city,userid);
        }

        /// <summary>
        /// 帐号设置（修改姓名）
        /// </summary>
        /// <param name="oldName">旧名字</param>
        /// <param name="userName">新名字</param>
        /// <param name="userid">会员编号</param>
        /// <returns></returns>
        public int UpdateUserName(string oldName,string userName, int userid)
        {
            return dal.UpdateUserName(oldName,userName, userid);
        }

        /// <summary>
        /// 检查邮箱是否已经被使用了
        /// </summary>
        /// <param name="Email">被检查的邮箱</param>
        /// <returns></returns>
        public bool CheckEmail(string Email)
        {
            return dal.CheckEmail(Email);
        }

        /// <summary>
        /// 邮箱设置
        /// </summary>
        /// <param name="newEmail">新默认邮箱</param>
        /// <param name="oldEmail">以前的默认邮箱</param>
        /// <param name="userid">会员编号</param>
        /// <param name="Ip">IP</param>
        /// <param name="flag">true：添加新邮箱，false：更新邮箱</param>
        /// <returns></returns>
        public int UpdateEmail(string newEmail, string oldEmail, int userid, string Ip, bool flag)
        {
            return dal.UpdateEmail(newEmail,oldEmail,userid,Ip,flag);
        }

        /// <summary>
        /// 删除信息
        /// </summary>
        /// <param name="Email">要删除的邮箱</param>
        /// <returns></returns>
        public int DelInfo(string Email)
        {
            return dal.DelInfo(Email);
        }

        
        /// <summary>
        /// 根据ID返回Datatable
        /// </summary>
        /// <param name="Id"></param>
        /// <param name="flag"></param>
        /// <returns></returns>
        public DataTable getEmail(int Id, int flag)
        {
            return dal.getEmail(Id,flag);
        }

        /// <summary>
        ///  检查用户密码是否正确
        /// </summary>
        /// <param name="userId">会员编号</param>
        /// <returns></returns>
        public bool getPwd(int userId, string Pwd)
        {
            return dal.getPwd(userId,Pwd);
        }

        /// <summary>
        /// 修改密码
        /// </summary>
        /// <param name="OldPwd">旧密码</param>
        /// <param name="NewPwd">新密码</param>
        /// <param name="userId">会员编号</param>
        public int ChanagePwd(string OldPwd, string NewPwd, int userId)
        {
           return dal.ChanagePwd(OldPwd,NewPwd,userId);
        }

         /// <summary>
        /// 保存MSN/Gtalk
        /// </summary>
        /// <returns></returns>
        public int UpdateMSNGtalk(string value, int userid, int flag)
        {
            return dal.UpdateMSNGtalk(value,userid,flag);
        }

        /// <summary>
        /// 邮件通知设置
        /// </summary>
        /// <param name="type"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        public int UpdateEmailSet(string type, string value, int userID, string IP, int flag)
        {
            return dal.UpdateEmailSet(type,value,userID,IP,flag);
        }

        /// <summary>
       /// 读取发送邮件通知内容
       /// </summary>
       /// <param name="userid"></param>
       /// <returns></returns>
        public bool sendEmailStr(int userid, string email, string username,int day)
        {
            return dal.sendEmailStr(userid,email,username,day);
        }

        /// <summary>
        /// 判断MSN,Gtalk,Mobile 是否存在
        /// </summary>
        /// <param name="temp"></param>
        /// <param name="flag">标识0：MSN 1：Gtalk 2:手机号码</param>
        /// <returns></returns>
        public int getMSNGtalk(string temp, int flag)
        {
            return dal.getMSNGtalk(temp, flag);
        }

        /// <summary>
        /// 注销自己的帐号
        /// </summary>
        /// <param name="UserID"></param>
        /// <returns></returns>
        public int DelUserSelf(int UserID)
        {
            return dal.DelUserSelf(UserID);
        }
    }
}
