コード例 #1
0
        private void btn_login_Click(object sender, EventArgs e)
        {
            Analyse_page newAnalysePage = new Analyse_page();

            this.Visible           = false;
            newAnalysePage.Visible = true;
        }
コード例 #2
0
 private void textBox3_KeyPress(object sender, KeyPressEventArgs e)
 {
     if (e.KeyChar == '\r')
     {
         Analyse_page newAnalysePage = new Analyse_page();
         this.Visible           = false;
         newAnalysePage.Visible = true;
     }
 }
コード例 #3
0
        private void btn_login_Click(object sender, EventArgs e)
        {
            try
            {
                string           MyConnection2 = "Server=127.0.0.1;Database=new_schema;Uid=root;Pwd=BlVH5thGSFfHE209Nt4E;";
                string           query         = "SELECT * FROM users where username=@username";
                MySqlConnection  connection    = new MySqlConnection(MyConnection2);
                MySqlCommand     command       = new MySqlCommand(query, connection);
                MySqlDataAdapter myAdapter     = new MySqlDataAdapter();
                command.Parameters.AddWithValue("@username", textBox4.Text);
                myAdapter.SelectCommand = command;
                DataTable table = new DataTable();
                myAdapter.Fill(table);
                DataRow[] row = table.Select();
                if (row.Length != 1)
                {
                    MessageBox.Show("Username cannot be found!");
                    return;
                }

                string password = row[0]["password"].ToString();
                string username = row[0]["username"].ToString();


                UserNamePassword user = new UserNamePassword();
                user.checkUserNamePassword(textBox4.Text, textBox3.Text, username, password);
            }
            catch (UserIsNotValidException ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                if (userLogged)
                {
                    Analyse_page newAnalysePage = new Analyse_page(this);
                    this.Visible           = false;
                    newAnalysePage.Visible = true;
                }
            }
        }