예제 #1
0
        private void backButton_Click(object sender, RoutedEventArgs e)
        {
            homePage hp = new homePage();

            hp.Show();
            this.Close();
        }
예제 #2
0
        private void login_Click(object sender, RoutedEventArgs e)
        {
            String userName     = nameBox.Text;
            String userPassword = passwordBox.Password;

            if (userName == "" || userPassword == "")
            {
                MessageBox.Show("请填写用户名和密码!");
                return;
            }
            try
            {
                MySqlConnection connection = new MySqlConnection(Conn);
                connection.Open();
                string          sql    = "select * from db_user where name ='" + userName + "'";
                MySqlCommand    cmd    = new MySqlCommand(sql, connection);
                MySqlDataReader reader = cmd.ExecuteReader();

                if (reader.Read())                                     //如果成功读取到了数据
                {
                    string dbpassword = reader["password"].ToString(); //获取数据库中存储的密码

                    if (userPassword != dbpassword)                    //如果用户输入的密码和数据库中存储的密码不相同
                    {
                        MessageBox.Show("密码错误!");
                        return;
                    }
                    else
                    {
                        homePage hp = new homePage();
                        hp.Show();
                        this.Close();
                    }
                    reader.Close();//读取完之后需要将reader关闭
                }
                else
                {
                    MessageBox.Show("该用户不存在!");
                    return;
                }
                connection.Close();//连接打开之后也要记得关闭
            }
            catch
            {
                MessageBox.Show("连接数据库失败");
                return;
            }
        }
예제 #3
0
        public MainWindow()
        {
            InitializeComponent();
            homePage hp = new homePage();

            if (test == 1)
            {
                hp.Show();
                this.Close();

                var         filePath = "C:\\Users\\MSI-PC\\Desktop\\database\\你的名字原版.jpg";
                var         comparePath = "C:\\Users\\MSI-PC\\Desktop\\database\\你的名字旋转.jpg";
                imageSearch imgSearch = new imageSearch();
                var         oP = imgSearch.getPHash(filePath);
                var         oA = imgSearch.getAHash(filePath);
                var         pP = imgSearch.getPHash(comparePath);
                var         pA = imgSearch.getAHash(comparePath);
                var         ansP = imgSearch.pHashCompare(oP, pP);
                var         ansA = imgSearch.pHashCompare(oA, pA);
                double      ans1 = ansP / 64.0, ans2 = ansA / 64.0;
                SaveImage(oP, "op.jpg"); SaveImage(oA, "oA.jpg");
                SaveImage(pP, "pP.jpg"); SaveImage(pA, "pA.jpg");
            }
        }