示例#1
0
        private bool ValidationLogin()
        {
            if (!this.Login(""))
            {
                MessageBox.Show(this, "ÃÜÂë»òÑéÖ¤ÂëÊäÈë´íÎó£¬ÇëÖØÊÔ£¡", Constants.MESSAGEBOX_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Error);

                bool retryLogin = true;
                while (retryLogin)
                {
                    DlgImageCode dlgPic = new DlgImageCode();                    
                    dlgPic.Email = txtEmail.Text;
                    dlgPic.Password = txtPassword.Text;
                    dlgPic.UserName = txtUserName.Text;
                    dlgPic.UserId = txtUserId.Text;
                    dlgPic.Gender = txtGender.Text;
                    dlgPic.ValidationImage = _image;
                    dlgPic.Location = this.Location;
                    this.Visible = false;
                    if (_oldemail != null && _oldemail != string.Empty)
                    {
                        dlgPic.Icon = IconCtrl.GetIconFromResx(TreeConstants.ICON_KEYS);
                        dlgPic.WindowsCaption = "±à¼­Õ˺Å";
                    }
                    else
                        dlgPic.WindowsCaption = "Ìí¼ÓÕ˺Å";
                    if (dlgPic.ShowDialog(this) == DialogResult.OK)
                    {
                        if (!_expanded)
                            SetControls(true);
                        this.Location = dlgPic.Location;
                        this.Visible = true;
                        txtEmail.Text = dlgPic.Email;
                        txtPassword.Text = dlgPic.Password;
                        txtValidationCode.Text = dlgPic.ValidationCode;
                        if (_image != null & _image.Length > 0)
                        {
                            MemoryStream stream = new MemoryStream();
                            stream.Write(_image, 0, _image.Length);
                            imgValidationCode.Image = Image.FromStream(stream);
                        }

                        if (!this.Login(dlgPic.ValidationCode))
                        {
                            MessageBox.Show(this, "ÃÜÂë»òÑéÖ¤ÂëÊäÈë´íÎó£¬ÇëÖØÊÔ£¡", Constants.MESSAGEBOX_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Error);
                            continue;
                        }
                        else
                            break;
                    }
                    else
                        retryLogin = false;

                }
                if (!retryLogin)
                    return false;
            }
            return true;
        }
示例#2
0
        private bool ValidationLogin()
        {
            if (!this.Login(""))
            {
                MessageBox.Show(this, "ÃÜÂë»òÑéÖ¤ÂëÊäÈë´íÎó£¬ÇëÖØÊÔ£¡", Constants.MESSAGEBOX_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Error);

                bool retryLogin = true;
                while (retryLogin)
                {
                    DlgImageCode dlgPic = new DlgImageCode();
                    dlgPic.Email           = txtEmail.Text;
                    dlgPic.Password        = txtPassword.Text;
                    dlgPic.UserName        = txtUserName.Text;
                    dlgPic.UserId          = txtUserId.Text;
                    dlgPic.Gender          = txtGender.Text;
                    dlgPic.ValidationImage = _image;
                    dlgPic.Location        = this.Location;
                    this.Visible           = false;
                    if (_oldemail != null && _oldemail != string.Empty)
                    {
                        dlgPic.Icon           = IconCtrl.GetIconFromResx(TreeConstants.ICON_KEYS);
                        dlgPic.WindowsCaption = "±à¼­Õ˺Å";
                    }
                    else
                    {
                        dlgPic.WindowsCaption = "Ìí¼ÓÕ˺Å";
                    }
                    if (dlgPic.ShowDialog(this) == DialogResult.OK)
                    {
                        if (!_expanded)
                        {
                            SetControls(true);
                        }
                        this.Location          = dlgPic.Location;
                        this.Visible           = true;
                        txtEmail.Text          = dlgPic.Email;
                        txtPassword.Text       = dlgPic.Password;
                        txtValidationCode.Text = dlgPic.ValidationCode;
                        if (_image != null & _image.Length > 0)
                        {
                            MemoryStream stream = new MemoryStream();
                            stream.Write(_image, 0, _image.Length);
                            imgValidationCode.Image = Image.FromStream(stream);
                        }

                        if (!this.Login(dlgPic.ValidationCode))
                        {
                            MessageBox.Show(this, "ÃÜÂë»òÑéÖ¤ÂëÊäÈë´íÎó£¬ÇëÖØÊÔ£¡", Constants.MESSAGEBOX_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Error);
                            continue;
                        }
                        else
                        {
                            break;
                        }
                    }
                    else
                    {
                        retryLogin = false;
                    }
                }
                if (!retryLogin)
                {
                    return(false);
                }
            }
            return(true);
        }