private void btnLogin_Click(object sender, EventArgs e) { MSLoginDatabase database = new MSLoginDatabase(); string m_loginid = IdNumberTextBox.Text; string m_password = PasswordTextBox.Text; DataTable dataTable = new DataTable(); MySqlDataAdapter mySqlDataAdapter = new MySqlDataAdapter(); MySqlCommand mySqlCommand = new MySqlCommand("SELECT * FROM `manager` WHERE `m_loginid` = @usn and `m_password` = @pass ", database.getConnection()); mySqlCommand.Parameters.Add("@usn", MySqlDbType.VarChar).Value = m_loginid; mySqlCommand.Parameters.Add("@pass", MySqlDbType.VarChar).Value = m_password; mySqlDataAdapter.SelectCommand = mySqlCommand; mySqlDataAdapter.Fill(dataTable); if (dataTable.Rows.Count > 0) { ManagerMenu managerMenu = new ManagerMenu(); managerMenu.Show(); } else { MessageBox.Show("Incorrect Login ID and Password, Please try again!"); } }
private void btnLogin_Click(object sender, EventArgs e) { MSLoginDatabase database = new MSLoginDatabase(); String s_loginid = IdNumberTextBox.Text; String s_password = PasswordTextBox.Text; DataTable table = new DataTable(); MySqlDataAdapter adapter = new MySqlDataAdapter(); MySqlCommand Command = new MySqlCommand("SELECT * FROM `nurse` WHERE `s_loginid` = @usn and `s_password` = @pass ", database.getConnection()); Command.Parameters.Add("@usn", MySqlDbType.VarChar).Value = s_loginid; Command.Parameters.Add("@pass", MySqlDbType.VarChar).Value = s_password; adapter.SelectCommand = Command; adapter.Fill(table); if (table.Rows.Count > 0) { passingtext = IdNumberTextBox.Text; this.Close(); NurseMenu nurseMenu = new NurseMenu(); nurseMenu.Show(); } else { if (s_loginid.Trim().Equals("")) { MessageBox.Show("Enter Your Username To Login", "Empty Username", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (s_password.Trim().Equals("")) { MessageBox.Show("Enter Your Password To Login", "Empty Password", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { MessageBox.Show("Wrong Username Or Password", "Wrong Data", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }