示例#1
0
        private void Button1_Click(object sender, RoutedEventArgs e)
        {
            /*
             * 判断输入框是否为空
             */
            if (textBox1.Text == "")
            {
                MessageBox.Show("用户名不能为空!");
                return;
            }
            else if (passwordBox1.Password == "")
            {
                MessageBox.Show("密码不能为空!");
                return;
            }
            else if (textBox2.Text == "")
            {
                MessageBox.Show("验证码不能为空!");
                return;
            }

            /*
             * 判断验证码是否正确
             */
            else if (!textBox2.Text.ToString().ToUpper().Equals(validCode.CheckCode))
            {
                MessageBox.Show("验证码错误!");
                validCode          = new ValidCode(5, ValidCode.CodeType.Alphas);
                this.image1.Source = BitmapFrame.Create(validCode.CreateCheckCodeImage());
                return;
            }

            int result = ManagerConnector.Login(textBox1.Text, passwordBox1.Password);

            if (result == -2)
            {
                MessageBox.Show("用户名或密码错误!");
                textBox1.Text         = "";
                passwordBox1.Password = "";
                textBox2.Text         = "";
                LoadValidCode();
            }
            else
            {
                MainMenuWindow mainMenuWindow = new MainMenuWindow(result);
                mainMenuWindow.Show();
                this.Close();
            }
        }
示例#2
0
 /*
  * 刷新验证码的函数
  */
 private void LoadValidCode()
 {
     validCode           = new ValidCode(5, ValidCode.CodeType.Alphas);
     this.image1.Source  = BitmapFrame.Create(validCode.CreateCheckCodeImage());
     this.image1.Stretch = Stretch.Uniform;
 }