public Boolean Login(EntUser eu) { koneksi.Open(); query = "SELECT username,password FROM user WHERE username = '******' AND password = '******'"; MySqlCommand command = koneksi.CreateCommand(); command.CommandText = query; MySqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { if ((reader.GetString(0).ToString() == eu.getUsername()) && (reader.GetString(1).ToString() == eu.getPassword())) { status = true; } else { status = false; } } koneksi.Close(); return(status); }
public Boolean updateUser(EntUser eu, int id_user) { status = false; try { koneksi.Open(); query = "UPDATE user SET username ='******', password ='******' WHERE id_users=" + id_user + ""; MySqlCommand command = koneksi.CreateCommand(); command.CommandText = query; command.ExecuteNonQuery(); status = true; koneksi.Close(); } catch (MySqlException me) { Console.WriteLine(me); } return(status); }
public Boolean insertUser(EntUser eu) { status = false; try { koneksi.Open(); query = "INSERT INTO user (username,password) VALUES ('" + eu.getUsername() + "' , '" + eu.getPassword() + "')"; MySqlCommand command = koneksi.CreateCommand(); command.CommandText = query; command.ExecuteNonQuery(); status = true; koneksi.Close(); } catch (MySqlException me) { Console.WriteLine(me); } return(status); }