Beispiel #1
0
        /// <summary>
        /// 通过用户名获取本地存储的用户信息
        /// </summary>
        /// <param name="Name"></param>
        /// <returns></returns>
        public static List <LocalLoginUser> GetLocalUsers()
        {
            string LocalLoginUserFile = CommonConstString.STR_DataPath + "\\LocalLoginUsers.xml";

            if (!System.IO.File.Exists(LocalLoginUserFile))
            {
                XmlDocument pXmlDocument = XmlUtil.CreateXmlDocument("LocalLoginUsers");
                pXmlDocument.Save(LocalLoginUserFile);
                return(new List <LocalLoginUser>());
            }
            try
            {
                DataSet ds = new DataSet();
                ds.ReadXml(LocalLoginUserFile);
                List <LocalLoginUser> LocalLoginUserList = new List <LocalLoginUser>();
                if (ds.Tables.Count == 0)
                {
                    return(LocalLoginUserList);
                }

                foreach (DataRow pRow in ds.Tables[0].Rows)
                {
                    LocalLoginUser pLocalLoginUser = new LocalLoginUser();
                    pLocalLoginUser.FillData(pRow);
                    pLocalLoginUser.DecryptPassword();
                    LocalLoginUserList.Add(pLocalLoginUser);
                }
                return(LocalLoginUserList);
            }
            catch { return(new List <LocalLoginUser>()); }
        }
Beispiel #2
0
        private void ImgCmbUserName_SelectedIndexChanged(object sender, EventArgs e)
        {
            LocalLoginUser pUser = LocalLoginUserList[ImgCmbUserName.SelectedIndex];

            txtPassword.Text    = pUser.PassWord;
            RememberPwd.Checked = !string.IsNullOrEmpty(pUser.PassWord);
        }
Beispiel #3
0
        /// <summary>
        /// 将本地登录的信息存储起来
        /// </summary>
        /// <param name="pLocalLoginUser"></param>
        public static void AddLocalLoginInfo(LocalLoginUser pLocalLoginUser)
        {
            string LocalLoginUserFile = CommonConstString.STR_DataPath + "\\LocalLoginUsers.xml";

            pLocalLoginUser.EncryptpassWord();
            XmlDocument pLocalLoginUserDoc = XmlUtil.LoadXmlDocument(LocalLoginUserFile);

            XmlUtil.AddXmlElementByDataTable(pLocalLoginUserDoc, pLocalLoginUserDoc["LocalLoginUsers"], pLocalLoginUser.ConvertToDataTable().Table);
            pLocalLoginUserDoc.Save(LocalLoginUserFile);
        }
Beispiel #4
0
        /// <summary>
        /// 保存登录信息
        /// </summary>
        /// <param name="pLocalLoginUser"></param>
        public static void SaveLoginInfo(LocalLoginUser pLocalLoginUser)
        {
            string      LocalLoginUserFile = CommonConstString.STR_DataPath + "\\LocalLoginUsers.xml";
            XmlDocument pLocalLoginUserDoc = XmlUtil.LoadXmlDocument(LocalLoginUserFile);
            XmlElement  RootElement        = pLocalLoginUserDoc["LocalLoginUsers"];

            foreach (XmlNode pUserElement in RootElement.ChildNodes)
            {
                if (string.Equals(pUserElement["UserName"].InnerText, pLocalLoginUser.UserName, StringComparison.OrdinalIgnoreCase))
                {
                    pLocalLoginUser.EncryptpassWord();
                    pUserElement["Password"].InnerText = pLocalLoginUser.PassWord;
                }
            }
            pLocalLoginUserDoc.Save(LocalLoginUserFile);
        }
Beispiel #5
0
        private void LoginRight()
        {
            //Properties.Settings.Default.LastLoginUser = ImgCmbUserName.Text;
            //Properties.Settings.Default.Save();
            LocalLoginUser pUser = new LocalLoginUser();

            pUser.UserName = this.ImgCmbUserName.Text;
            pUser.PassWord = this.txtPassword.Text;
            if (!RememberPwd.Checked)
            {
                pUser.PassWord = string.Empty;
            }
            if (ImgCmbUserName.SelectedIndex == -1)
            {
                LocalLoginManager.AddLocalLoginInfo(pUser);
            }
            else
            {
                LocalLoginManager.SaveLoginInfo(pUser);
            }
            this.DialogResult = DialogResult.OK;
        }