private void Re_btn_Click(object sender, RoutedEventArgs e) { adminsoption ao = new adminsoption(); ao.Show(); this.Close(); }
private void Btnlogin_Click(object sender, RoutedEventArgs e) { if (adminisempty()) { MySqlConnection mysqlConnection = new MySqlConnection("Data Source= localhost;Initial Catalog=quiz;Integrated Security=true;username=root;password=''"); try { { if (mysqlConnection.State == ConnectionState.Closed) { mysqlConnection.Open(); string query = "SELECT COUNT(1) FROM admin_athu WHERE adminname=@username AND adminpassword=@password"; MySqlCommand mysqlcmd = new MySqlCommand(query, mysqlConnection); mysqlcmd.CommandType = CommandType.Text; mysqlcmd.Parameters.AddWithValue("@username", txtusrname.Text); mysqlcmd.Parameters.AddWithValue("@password", txtpswd.Password); int count = Convert.ToInt32(mysqlcmd.ExecuteScalar()); if (count == 1) { adminsoption ao = new adminsoption(); ao.Show(); this.Close(); } else { MessageBox.Show("u are u username or password is not correct"); txtusrname.Text = ""; txtpswd.Password = ""; } } } } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { mysqlConnection.Close(); } } else { MessageBox.Show("login failed due to empty fields"); } }