private void button12_Click(object sender, EventArgs e) { this.Hide(); Homepage ho = new Homepage(); ho.Show(); }
private void btn_login_Click(object sender, EventArgs e) { if (userCombo.SelectedIndex < 0) { MessageBox.Show("Invalid Username!", "Error"); userCombo.Focus(); } else { int a = userCombo.SelectedIndex; string uid = Convert.ToString(a); string uName = userCombo.SelectedItem.ToString(); string password = passField.Text; var conn = new MySqlConnection(connString); string query = "SELECT * from staff where sId ='" + uid + "';"; try{ conn.Open(); MySqlCommand cmd = new MySqlCommand(query, conn); var read = cmd.ExecuteReader(); if (read.Read()) { if (read.GetString("pass") == password) { MessageBox.Show(uName + " logged in successfully!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); Homepage home = new Homepage(); home.currentUser = uName; Homepage.currentUser1 = uName; home.currentUID = uid; home.currentUserAccess = read.GetInt32("access").ToString(); home.Show(); this.Hide(); } else { MessageBox.Show(" Incorrect Password"); passField.Focus(); passField.SelectAll(); } } } catch (Exception ex) { MessageBox.Show(ex.Message); } } }
private void btn_login_Click(object sender, EventArgs e) { if (userCombo.SelectedIndex < 0) { MessageBox.Show("Invalid Username!", "Error"); } else { string uname = userCombo.SelectedItem.ToString(); string password = passField.Text; var conn = new MySqlConnection(connString); string query = "SELECT password from staff where username ='******';"; try{ conn.Open(); MySqlCommand cmd = new MySqlCommand(query, conn); var read = cmd.ExecuteReader(); if (read.Read()) { if (read.GetString("password") == password) { MessageBox.Show(uname + " logged in successfully!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); Homepage home = new Homepage(uname); home.Show(); this.Hide(); } else { MessageBox.Show("username and/or password is incorrect"); } } } catch (Exception ex) { MessageBox.Show(ex.Message); } } }