- public partial class test_Window : Window
- {
- public test_Window()
- {
- InitializeComponent();
- }
- int testNumber;
- Random random = new Random();
- bool? falg;
- public bool? Falg
- {
- get { return falg; }
- }
- private void Window_Loaded(object sender, RoutedEventArgs e)
- {
- testNumber = random.Next(1000, 10000);
- textNmumber_TextBox.Text = testNumber.ToString();
- }
- private void input_Button_Click(object sender, RoutedEventArgs e)
- {
- if (admin_TextBox.Text == "admin"
- && password_PasswordBox.Password == "66666")
- {
- if (test_TextBox.Text == testNumber.ToString())
- {
- falg = true;
- admin_TextBox.Clear();
- password_PasswordBox.Clear();
- test_TextBox.Clear();
- MessageBox.Show("登陆成功");
- this.Close();
- }
- else
- {
- falg = false;
- MessageBox.Show("您输入的验证码不正确");
- password_PasswordBox.Clear();
- test_TextBox.Clear();
- testNumber = random.Next(1000, 10000);
- textNmumber_TextBox.Text = testNumber.ToString();
- }
- }
- else
- {
- falg = false;
- MessageBox.Show("您输入的用户名或密码不正确");
- admin_TextBox.Clear();
- password_PasswordBox.Clear();
- test_TextBox.Clear();
- testNumber = random.Next(1000, 10000);
- textNmumber_TextBox.Text = testNumber.ToString();
- }
- }
- }
复制代码 这是子函数
|