protected BaseMasterPage()
     : base()
 {
     isUserLogined = false;
     currentUser = User.GetCurrentUserCookieInfo();
     if (currentUser != null)
     {
         isUserLogined = true;
     }
 }
Exemple #2
0
        /// <summary>
        /// ��֤һ���û��Ƿ���Ч
        /// </summary>
        /// <param name="email">�û��ʼ���ַ</param>
        /// <param name="password">��¼����</param>
        /// <param name="uc">UserCookieInfoʵ��</param>
        /// <returns></returns>
        public static bool IsUser(string email, string password, out UserCookieInfo uc)
        {
            /*
             INV_IsUser
             @email varchar(50),
             @pass varchar(50)
             */
            //[Id],[Email],[Name]

            bool bln = false;
            int _id;
            string _name, _email;
            uc = null;

            using (SqlDataReader reader = Database.ExecuteReader(CommandType.StoredProcedure, "INV_IsUser",
                new SqlParameter[] {
                    Database.MakeInParam("@email",SqlDbType.VarChar,50,email),
                    Database.MakeInParam("@param",SqlDbType.VarChar,50,Util.MD5(password))
                }))
            {
                if (reader.Read())
                {
                    _id = reader.GetInt32(0);
                    _email = reader.GetString(1);
                    _name = reader.GetString(2);
                    bln = true;
                    uc = new UserCookieInfo(_id, _name, _email);
                }
                reader.Close();
            }

            return bln;
        }
        public static UserCookieInfo Get()
        {
            UserCookieInfo info=null;

            if (Cookies.HasCookie(COOKIE_NAME))
            {
                info = new UserCookieInfo();
                try
                {
                    info.id = Convert.ToInt32(Cookies.GetCookieValue(COOKIE_NAME, "ID"));
                    info.name = Cookies.GetCookieValue(COOKIE_NAME, "NAME");
                    info.email = Cookies.GetCookieValue(COOKIE_NAME, "EMAIL");
                }
                catch
                {
                    //
                }
            }

            return info;
        }
Exemple #4
0
        /// <summary>
        /// ���һ�����û�
        /// </summary>
        /// <param name="u">�û�ʵ��</param>
        /// <param name="autoLogin">��ӳɹ����Ƿ��Զ���¼</param>
        /// <returns>���û�ID</returns>
        public static int AddNew(User u,bool autoLogin)
        {
            /*
            INV_UserAddNew
            @email varchar(50),
            @pass varchar(50),
            @name varchar(10),
            @telephone varchar(20)='',
            @cellphone varchar(15)='',
            @status smallint=1
             */

            SqlParameter[] prams = new SqlParameter[] {
                Database.MakeReturnValueParam("@returnValue"),
                Database.MakeInParam("@email",SqlDbType.VarChar,50,u.email),
                Database.MakeInParam("@pass",SqlDbType.VarChar,50,Util.MD5(u.password)),
                Database.MakeInParam("@name",SqlDbType.VarChar,10,u.name),
                Database.MakeInParam("@telephone",SqlDbType.VarChar,20,u.telephone),
                Database.MakeInParam("@cellphone",SqlDbType.VarChar,15,u.cellphone),
                Database.MakeInParam("@status",SqlDbType.SmallInt,u.status)
            };

            int ret = Database.ExecuteNonQuery(CommandType.StoredProcedure, "INV_UserAddNew", prams);
            u.id = ret;

            if (ret>0 && autoLogin)
            {
                UserCookieInfo uc = new UserCookieInfo(u);
            }

            return ret;
        }