patrick.xu
2021-05-24 f13235bee2e25d091ba13dc3732b83f905565f80
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
 
namespace M423project
{
    public partial class ImagePassWord : Form
    {
        private string password = "";
        public ImagePassWord(string password)
        {
            InitializeComponent();
            this.password = password;
        }
 
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (tbPassWord.Text.ToUpper().Equals(password.ToUpper()))
            {
                this.DialogResult = DialogResult.OK;
            }
            else
            {
                MessageBox.Show("密码错误,请重新输入!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                tbPassWord.Text = "";
            }
        }
 
        private void tbPassword_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == 13)
            {
                if (tbPassWord.Text.ToUpper().Equals(password.ToUpper()))
                {
                    this.DialogResult = DialogResult.OK;
                }
                else
                {
                    MessageBox.Show("密码错误,请重新输入!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    tbPassWord.Text = "";
                }
            }
        }
    }
}