Example #1
0
 private void SciagnijListePlacowek()
 {
     try
     {
         con = new MySqlConnection(connectionString);
         con.Open();
         //   logi.GetComponent<Text>().text = "";
         using (IDbCommand dbcmd = con.CreateCommand())
         {
             string sql =
                 "SELECT *" +
                 "FROM placowki p JOIN miasta m ON m.id_miasta = p.id_miasta";
             dbcmd.CommandText = sql;
             using (IDataReader reader = dbcmd.ExecuteReader())
             {
                 while (reader.Read())
                 {
                     placowka tmp = new placowka();
                     tmp.id_placowki  = (int)reader["id_placowki"];
                     tmp.id_miasta    = (int)reader["id_miasta"];
                     tmp.nazwa        = (string)reader["nazwa"];
                     tmp.ulica        = (string)reader["ulica"];
                     tmp.telefon      = (string)reader["telefon"];
                     tmp.liczba_ludzi = (int)reader["liczba_ludzi"];
                     tmp.lajki        = (int)reader["lajki"];
                     tmp.dislajki     = (int)reader["dislajki"];
                     // int smiec = (int)reader["id_miasta"];
                     tmp.nazwa_miasta = (string)reader["nazwa_miasta"];
                     lista_placowek.Add(tmp);
                 }
                 //foreach (placowka p in lista_placowek)
                 // {
                 //    Debug.Log(p.id_placowki + " " + p.nazwa + " " + p.nazwa_miasta);
                 //}
             }
         }
         if (con != null)
         {
             if (con.State.ToString() != "Closed")
             {
                 con.Close();
                 Debug.Log("DB con closed");
             }
             con.Dispose();
         }
     }
     catch (Exception e)
     {
         Debug.Log(e);
     }
 }
Example #2
0
        public placowka Zwrot_Glowa()
        {
            placowka tmp = new placowka();

            foreach (placowka p in lista_placowek)
            {
                if (p.id_placowki == id_wyszukiwania)
                {
                    tmp = p;
                    break;
                }
            }
            return(tmp);
        }
Example #3
0
        public void dodaj_komentarz(string nick, string data, string godzina, int liczba_ludzi, string komentarz, int lapka)
        {
            try
            {
                con = new MySqlConnection(connectionString);
                con.Open();

                string sqluserstrig =
                    "Insert into komentarze(nick, data, godzina, liczba_osob ,komentarz, id_placowki, kciuk)" +
                    "values ('" + nick + "','" + data + "','" + godzina + "'," + liczba_ludzi + ",'" + komentarz + "'," + id_wyszukiwania + "," + lapka + ");";

                if (lapka == 2)
                {
                    sqluserstrig += "Update placowki set lajki = lajki+1 where id_placowki =" + id_wyszukiwania + ";";
                }
                else if (lapka == 1)
                {
                    sqluserstrig += "Update placowki set dislajki = dislajki+1 where id_placowki =" + id_wyszukiwania + ";";
                }

                sqluserstrig += "Update placowki set liczba_ludzi = " + liczba_ludzi + " Where id_placowki = " + id_wyszukiwania + ";";

                MySqlCommand cmd = new MySqlCommand(sqluserstrig, con);
                cmd.CommandTimeout = 200;
                cmd.ExecuteNonQuery();



                if (con != null)
                {
                    if (con.State.ToString() != "Closed")
                    {
                        con.Close();
                        Debug.Log("DB con closed");
                    }
                    con.Dispose();
                }
            }
            catch (Exception e)
            {
                Debug.Log(e);
                //   logi3.GetComponent<Text>().text += "\nRzucony wyjatek: \n" + e.ToString();
            }
            //SciagnijListePlacowek();
            for (int i = 0; i < lista_placowek.Count; i++)
            {
                if (lista_placowek[i].id_placowki == id_wyszukiwania)
                {
                    placowka tmp = lista_placowek[i];
                    tmp.liczba_ludzi = liczba_ludzi;

                    if (lapka == 2)
                    {
                        tmp.lajki++;
                    }
                    else if (lapka == 1)
                    {
                        tmp.dislajki++;
                    }

                    lista_placowek[i] = tmp;
                    break;
                }
            }
            for (int i = 0; i < zwrot_placowek.Count; i++)
            {
                if (zwrot_placowek[i].id_placowki == id_wyszukiwania)
                {
                    placowka tmp = zwrot_placowek[i];
                    tmp.liczba_ludzi = liczba_ludzi;

                    if (lapka == 2)
                    {
                        tmp.lajki++;
                    }
                    else if (lapka == 1)
                    {
                        tmp.dislajki++;
                    }

                    zwrot_placowek[i] = tmp;
                    break;
                }
            }


            sciagnij_komentarze(id_wyszukiwania);
            SceneManager.LoadScene(5);
            // Destroy(gameObject);
        }