Esempio n. 1
0
        public bool UserExists(string pseudo, string pass)
        {
            DataSet res = BDD.query("SELECT id FROM joueur WHERE pseudo='" + pseudo + "' AND pass=SHA1('" + pass + "')", "pseudo");

            if (res != null && res.Tables[0].Rows.Count == 1)
            {
                int id = (int)res.Tables[0].Rows[0]["id"];
                //res = BDD.query("INSERT INTO joueur ('pseudo', 'pass', 'mail') VALUES ('trolol', SHA1('trolol'), '*****@*****.**')");
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Clic sur l'élement du menu "Télécharger des jeux"
        /// </summary>
        private void téléchargerDesJeuxToolStripMenuItem_Click(object sender, EventArgs e)
        {
            DataSet ds = BDD.query("SELECT nom, chemin, version, description, icone FROM jeux", "nom", "chemin", "version", "description", "icone");

            if (ds == null)
            {
                MessageBox.Show("Impossible de télécharger la liste de jeux", "Erreur lors du téléchargement", MessageBoxButtons.OK);
            }
            else
            {
                remoteGames = new List <Game>();
                try
                {
                    foreach (DataRow dr in ds.Tables[0].Rows)
                    // Téléchargement de l'icône
                    {
                        WebClient client = new WebClient();
                        client.DownloadFile(new Uri("http://g2iut.alwaysdata.net/icons/" + dr["icone"]), Path.Combine(temporaryPath, (string)dr["icone"]));
                        remoteGames.Add(new Game((string)dr["nom"], (string)dr["icone"], (string)dr["chemin"], (string)dr["description"], (int)dr["version"], InstallState.NotInstalled));
                    }
                }
                catch (Exception sarlon)
                {
                    string msg = "";
#if DEBUG
                    msg = sarlon.Message;
#endif
                    MessageBox.Show("Impossible de contacter le serveur " + msg, "Erreur lors de la récupération", MessageBoxButtons.OK);
                }
                foreach (Game rg in remoteGames)
                {
                    int  j         = 0;
                    bool installed = false;
                    while (j < localGames.Count && !installed)
                    {
                        if (rg.Executable == localGames[j].Executable)
                        {
                            installed = true;
                            int i = 0;
                            while (i < listView1.Items.Count && (Game)listView1.Items[i].Tag != localGames[j])
                            {
                                i++;
                            }
                            if (i < listView1.Items.Count)
                            {
                                if (rg.Equals(localGames[j]))
                                {
                                    localGames[j].Install = InstallState.UpToDate;
                                }
                                else
                                {
                                    localGames[j].Install = InstallState.UpdateAvailable;
                                }
                            }
                        }
                        j++;
                    }
                    if (!installed)
                    {
                        int          lviPosition = listView1.Items.Count;
                        ListViewItem lvi         = new ListViewItem(rg.Name, lviPosition);
                        lvi.Tag = rg;
                        Bitmap b = new Bitmap(Path.Combine(temporaryPath, rg.Icon));
                        smallIconList.Images.Add(b);
                        mediumIconList.Images.Add(b);
                        lvi.SubItems.Add(rg.IState());
                        lvi.SubItems.Add(rg.Description);
                        listView1.Items.Add(lvi);
                    }
                }
            }
        }