예제 #1
0
        /// <summary>
        /// 验证用户名是否存在 2014/8/21 9:04:10   By 唐有炜
        /// </summary>
        /// <param name="accountType">账号类型(username,email,phone)</param>
        /// <param name="userName">用户名</param>
        /// <param name="userPassword">密码</param>
        /// <returns></returns>
        public bool UserPasswordExists(string accountType, string userName, string userPassword)
        {
            bool passwordExists = false;

            //解密
            userPassword = DESEncrypt.Encrypt(userPassword);

            switch (accountType)
            {
            case "username":
                if (!userName.Contains("@"))
                {
                    var existsDefault =
                        CompanyUserDao.ExistsViewEntity(cu => cu.UserLname == userName && cu.CompNum == "10000" && cu.UserPassword == userPassword);
                    if (existsDefault)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
                string[] userComp = userName.Split('@').ToArray();
                if (!Utils.IsNum(userComp[1]))
                {
                    return(false);
                }
                string userLName = userComp[0];
                string compNum   = userComp[1];

                passwordExists =
                    CompanyUserDao.ExistsViewEntity(
                        cu => cu.UserLname == userLName && cu.CompNum == compNum && cu.UserPassword == userPassword);
                if (passwordExists)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
                break;

            case "email":
                passwordExists =
                    CompanyUserDao.ExistsViewEntity(
                        cu => cu.UserEmail == userName && cu.UserPassword == userPassword);
                if (passwordExists)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
                break;

            case "phone":
                passwordExists =
                    CompanyUserDao.ExistsViewEntity(
                        cu => cu.UserPhone == userName && cu.UserPassword == userPassword);
                if (passwordExists)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
                break;

            default:
                return(false);

                break;
            }
        }
예제 #2
0
        /// <summary>
        /// 验证用户名是否存在 2014/8/21 9:04:10   By 唐有炜
        /// </summary>
        /// <param name="accountType">账号类型(username,email,phone)</param>
        /// <param name="userName">用户名</param>
        /// <returns></returns>
        public bool UserNameExists(string accountType, string userName)
        {
            switch (accountType)
            {
            case "username":
                if (!userName.Contains("@"))
                {
                    var existsDefault =
                        CompanyUserDao.ExistsViewEntity(cu => cu.UserLname == userName && cu.CompNum == "10000");
                    if (existsDefault)
                    {
                        return(true);
                    }
                    return(false);
                }
                string[] userComp = userName.Split('@').ToArray();
                if (!Utils.IsNum(userComp[1]))
                {
                    return(false);
                }
                string userLName = userComp[0];
                string compNum   = userComp[1];

//                    bool userExists = CompanyUserDao.ExistsEntity(u => u.UserLname == userLName);
//                    bool compExists = CompanyUserDao.ExistsEntity(c => c.CompNum == compNum);
                bool userExists = CompanyUserDao.ExistsViewEntity(u => u.UserLname == userLName && u.CompNum == compNum);
                // if (userExists && compExists)
                if (userExists)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
                break;

            case "email":
                bool emailExists = CompanyUserDao.ExistsViewEntity(u => u.UserEmail == userName);
                if (emailExists)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
                break;

            case "phone":
                bool phoneExists = CompanyUserDao.ExistsViewEntity(u => u.UserPhone == userName);
                if (phoneExists)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
                break;

            default:
                return(false);

                break;
            }
        }