Пример #1
0
        /// <summary>
        /// 登录验证
        /// </summary>
        /// <param name="name">用户名</param>
        /// <param name="pwd">密码</param>
        /// <param name="type">用户类型</param>
        /// <returns></returns>
        public LoginState Login(string name, string pwd, out int type)
        {
            type = -1;
            //type = -1      没有
            //type = 0       员工
            //type = 1       老板
            //type = 2       顾客
            //根据用户名进行对象的查询
            ManagerInfo mi     = miDal.GetByName(name);
            MemberInfo  member = memberDal.GetByName(name);

            if (mi != null)
            {
                //用户名正确
                if (MD5Helper.EncryptString(mi.MPwd).Equals(MD5Helper.EncryptString(pwd)))
                {
                    //密码正确
                    //登录成功
                    type = mi.MType;
                    //保存用户session
                    GlobalVariable.userId   = Convert.ToString(mi.Id);
                    GlobalVariable.userName = mi.MName;
                    GlobalVariable.pwd      = mi.MPwd;
                    return(LoginState.Ok);
                }
                else
                {
                    //密码错误
                    return(LoginState.PwdError);
                }
            }
            else if (member != null)
            {
                //用户名正确
                if (MD5Helper.EncryptString(member.MPwd).Equals(MD5Helper.EncryptString(pwd)))
                {
                    //密码正确
                    //登录成功
                    type = 2;         //顾客
                    //保存用户session
                    GlobalVariable.userId   = Convert.ToString(member.Id);
                    GlobalVariable.userName = member.MName;
                    GlobalVariable.pwd      = member.MPwd;
                    GlobalVariable.phone    = member.MPhone;
                    return(LoginState.Ok);
                }
                else
                {
                    //密码错误
                    return(LoginState.PwdError);
                }
            }
            return(LoginState.NameError);
        }
Пример #2
0
 public MemberInfo GetByName(string name)
 {
     return(memInfoDal.GetByName(name));
 }