Advertisement
Tidall

Untitled

Dec 1st, 2016
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.36 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Data.SQLite;
  7. using System.Data;
  8.  
  9. namespace Oregon_Trail.Classes
  10. {
  11.     public static class db
  12.     {
  13.         public static readonly SQLiteConnection dbCon = new SQLiteConnection("Data Source=oregontrail.sqlite; version=3");
  14.         public static DataSet OTDS = new DataSet("OTDS");
  15.        
  16.         public static async void LoadData()
  17.         {
  18.             SQLiteDataAdapter dataAdapter = new SQLiteDataAdapter();
  19.            
  20.  
  21.             await Task.Factory.StartNew(() =>
  22.            {
  23.                bool isStarted;
  24.                string sql = "SELECT * FROM gamestate";
  25.                string table = "loadstuff";
  26.                dataAdapter = new SQLiteDataAdapter(sql, dbCon);
  27.                dataAdapter.Fill(OTDS, table);
  28.  
  29.                for (int i = 0; i < OTDS.Tables[3].Rows.Count; i++)
  30.                {
  31.                    string gamename = OTDS.Tables[3].Rows[i]["gamenum"].ToString();
  32.                    
  33.                    switch (gamename)
  34.                    {
  35.                        case "game1":
  36.                            {
  37.  
  38.                                int isstarted = int.Parse(OTDS.Tables[3].Rows[i]["isStarted"].ToString());
  39.  
  40.                                if (isstarted == 0)
  41.                                {
  42.                                    isStarted = false;
  43.                                    Game.EnabledGames[0] = isStarted;
  44.                                }
  45.                                else if (isstarted == 1)
  46.                                {
  47.                                    isStarted = true;
  48.                                    Game.EnabledGames[0] = isStarted;
  49.                                }
  50.  
  51.                                break;
  52.                            }
  53.                        case "game2":
  54.                            {
  55.                                int isstarted = int.Parse(OTDS.Tables[3].Rows[i]["isStarted"].ToString());
  56.  
  57.                                if (isstarted == 0)
  58.                                {
  59.                                    isStarted = false;
  60.                                    Game.EnabledGames[1] = isStarted;
  61.                                }
  62.                                else if (isstarted == 1)
  63.                                {
  64.                                    isStarted = true;
  65.                                    Game.EnabledGames[1] = isStarted;
  66.                                }
  67.  
  68.                                break;
  69.                            }
  70.                        case "game3":
  71.                            {
  72.                                int isstarted = int.Parse(OTDS.Tables[3].Rows[i]["isStarted"].ToString());
  73.  
  74.                                if (isstarted == 0)
  75.                                {
  76.                                    isStarted = false;
  77.                                    Game.EnabledGames[2] = isStarted;
  78.                                }
  79.                                else if (isstarted == 1)
  80.                                {
  81.                                    isStarted = true;
  82.                                    Game.EnabledGames[2] = isStarted;
  83.                                }
  84.  
  85.                                break;
  86.                            }
  87.                    }
  88.  
  89.  
  90.                }
  91.            });
  92.         }
  93.     }
  94. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement