예제 #1
0
 public void LoginFreshShow()
 {
     if (SelectDao.UserLogion(this.textName.Text, this.textPsw.Text))
     {
         this.DialogResult = DialogResult.OK;
         UserRight instance = UserRight.GetInstance();
         instance.GetUserRight(this.textName.Text);
         string appPath = System.AppDomain.CurrentDomain.BaseDirectory + "FootConfig.xml";
         XmlUtil.SavaDataInfo(appPath, "User", this.textName.Text);
         //加密
         if (this.checkEdit1.Checked)
         {
             string password = XmlUtil.Encryption(this.textPsw.Text);
             XmlUtil.SavaDataInfo(appPath, "Password", password);
             XmlUtil.SavaDataInfo(appPath, "Remember", "true");
         }
         this.Close();
     }
     else
     {
         progressBarControl1.Position = 0;
         backgroundWorker1.CancelAsync();
         XtraMessageBox.Show("登录失败!");
     }
 }
예제 #2
0
        private void BtnLogin_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(this.txtUserName.Text))
            {
                XtraMessageBox.Show("用户名不能为空!", "错误信息", MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.txtUserName.Focus();
                return;
            }
            if (string.IsNullOrEmpty(this.txtPassWord.Text))
            {
                XtraMessageBox.Show("密码不能为空!", "错误信息", MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.txtPassWord.Focus();
                return;
            }

            if (SelectDao.UserLogion(this.txtUserName.Text, this.txtPassWord.Text))
            {
                Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
                config.AppSettings.Settings["User"].Value = this.txtUserName.Text;
                if (this.checkEdit1.Checked)
                {
                    string password = XmlUtil.Encryption(this.txtPassWord.Text);
                    config.AppSettings.Settings["Password"].Value = password;
                    config.AppSettings.Settings["Remember"].Value = "true";
                    config.Save();
                }
                this.Hide();
                InitServer();
                this.DialogResult = DialogResult.OK;
                this.Close();
            }
            else
            {
                XtraMessageBox.Show("登录失败!");
            }
        }