private void button1_Click(object sender, EventArgs e) { if (CheckUser() == 1) { int id = CheckTitle(); if (id > 0) { int cb = checkBook(id); if (cb > 0) { if (checkIssue(cb) == 1) { issueBook(cb); SearchArtifact sa = new SearchArtifact(); this.Hide(); sa.ShowDialog(); } } } } }
private void button1_Click(object sender, EventArgs e) { string myConnection = "datasource=localhost;port=3306;username=root;password=root;"; MySqlConnection myConn = new MySqlConnection(myConnection); try { MySqlCommand SelectCommand = new MySqlCommand("select * from library_system.user where email='" + this.username_txt.Text + "' and pass='******';", myConn); MySqlDataReader myReader; myConn.Open(); myReader = SelectCommand.ExecuteReader(); int count = 0; while (myReader.Read()) { count++; } if (count == 1) { //MessageBox.Show("Username and Password is correct"); this.Hide(); SearchArtifact s = new SearchArtifact(); s.ShowDialog(); } else if (count > 1) { MessageBox.Show("Duplicate Username and Password...Access Denied."); } else { MessageBox.Show("Username or password is incorrect...Please Try again"); } } catch (Exception ex) { MessageBox.Show(ex.Message); } myConn.Close(); }