コード例 #1
0
        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);
        }
コード例 #2
0
 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);
 }
コード例 #3
0
 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);
 }