首页 新闻 搜索 专区 学院

silverlight登录界面中如何实现记住用户和密码以及自动登录功能,数据库为本地数据库perst

0
悬赏园豆:60 [已解决问题] 解决于 2011-01-17 01:10

各位高手,小弟是Silverlight新手,现在遇到一个问题,请各位高手帮忙,小弟不胜感激!!!

silverlight登录界面中如何实现记住用户和密码以及自动登录功能,数据库为本地数据库perst:

具体要求是,第一次访问从服务器端获取数据保存到本地perst数据库,以后每次访问从本地数据库perst获取用户信息进行验证,点击“记住用户名和密码”和自动登录,能够自动完成登录,基本功能都完成了,可是点击自动登录和记住用户名和密码都不管用,不知道怎么回事,还请各位高手帮小弟一把,谢谢

/// <summary>
        /// 记住用户名和密码
        /// </summary>
        private void remCheckBox_Click(object sender, RoutedEventArgs e)
        {
            this.EventRemember();
        }
        /// <summary>
        /// 自动登录
        /// </summary>
        private void autoLogin_Click(object sender, RoutedEventArgs e)
        {
            this.EventAuto();
        }
        /// <summary>
        /// 单击登录按钮
        /// </summary>
        private void btnLogin_Click(object sender, RoutedEventArgs e)
        {
            this.EventLogin();
        }
       

        #endregion

        #region Methods

        /// <summary>
        /// 记住用户名和密码
        /// </summary>
        private void EventRemember()
        {
            if (DatabaseHelper.ExistsTable<T_UserInfo>(database))
            {
                //判断是否有记录
                IEnumerable<T_UserInfo> rem = null;
                rem = (from log in database.GetRecords<T_UserInfo>()
                       where log.UserLoginName == Model.Frame.SystemRunInfo.Instance.LoginUserName &&
                       log.UserPassword == Model.Frame.SystemRunInfo.Instance.LoginPassword
                       select log);
                if (rem != null && rem.ToList<T_UserInfo>().Count > 0)
                {
                    //取出该条记录的“记住账户和密码”项
                    T_UserInfo obj = rem.ToList<T_UserInfo>()[0];
                    //修改“记住账户和密码”项
                    if (this.remCheckBox.IsChecked.Equals(true))
                    {
                        obj.IsRemPw = 1;
                    }
                    else if (this.remCheckBox.IsChecked.Equals(false))
                    {
                        obj.IsRemPw = 0;
                    }
                    database.AddRecord(obj);
                }
            }
        }
        /// <summary>
        /// 自动登录
        /// </summary>
        private void EventAuto()
        {
            //判断是否有记录
            IEnumerable<T_UserInfo> auto = null;
            auto = (from log in database.GetRecords<T_UserInfo>()
                    where log.UserLoginName ==
                    Model.Frame.SystemRunInfo.Instance.LoginUserName && log.UserPassword == Model.Frame.SystemRunInfo.Instance.LoginPassword
                    select log);
            if (auto != null && auto.ToList<T_UserInfo>().Count > 0)
            {
                //取出该条记录的“自动登录”项
                T_UserInfo obj = auto.ToList<T_UserInfo>()[0];
                //修改“自动登录”项
                if (this.autoLogin.IsChecked.Equals(true))
                {
                    obj.IsAutoLogin = 1;
                }
                else if (this.autoLogin.IsChecked.Equals(false))
                {
                    obj.IsAutoLogin = 0;
                }
                database.AddRecord(obj);
            }
        }

竹--石的主页 竹--石 | 初学一级 | 园豆:7
提问于:2010-11-21 11:54
< >
分享
最佳答案
0

你没有提交

database.AddRecord(obj);

database.Storage.Commit();
database.Storage.Close();

收获园豆:60
背着PC去流浪 | 菜鸟二级 |园豆:265 | 2010-11-30 08:49
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册