private void btn_main_menu_Click(object sender, RoutedEventArgs e)
        {
            main_panel main_Panel = new main_panel(this.user_type);

            main_Panel.Owner = this;
            this.Hide();
            main_Panel.Show();
        }
예제 #2
0
        private void btnLogin_Click(object sender, RoutedEventArgs e)
        {
            if (this.checkField(txt_username.Text.ToString(), txt_password.Password.ToString()))
            {
                String password = this.encryptPassword(txt_password.Password.ToString());

                string query = "select * from users where username = '******' and password = '******' limit 1";

                MySqlConnection con = Models.DBConfiguration.DBCON();
                try
                {
                    con.Open();
                    MySqlCommand    cmd = new MySqlCommand(query, con);
                    MySqlDataReader dr  = cmd.ExecuteReader();
                    if (dr.HasRows)
                    {
                        dr.Read();
                        this.user_role = dr.GetString("user_role_code");

                        main_panel main_Panel = new main_panel(this.user_role);
                        main_Panel.Owner = this;
                        this.Hide();
                        main_Panel.Show();
                    }
                    else
                    {
                        MessageBox.Show("Invalid email or password");
                    }
                }
                catch (MySqlException ex)
                {
                    MessageBox.Show(ex.Message);
                }
                finally
                {
                    con.Close();
                }
            }
        }