コード例 #1
0
        private async void SubmitButton_Click(object sender, RoutedEventArgs e)
        {
            DateTime d     = DateTime.Now;
            string   day   = d.Day < 10 ? "0" + d.Day.ToString() : d.Day.ToString();
            string   month = d.Month < 10 ? "0" + d.Month.ToString() : d.Month.ToString();
            string   year  = d.Year.ToString();
            string   date  = day + "-" + month + "-" + year;

            string hour   = d.Hour < 10 ? "0" + d.Hour.ToString() : d.Hour.ToString();
            string minute = d.Minute < 10 ? "0" + d.Minute.ToString() : d.Minute.ToString();
            string second = d.Second < 10 ? "0" + d.Minute.ToString() : d.Minute.ToString();
            string time   = hour + ":" + minute + ":" + second;

            string orderNo = "Order - " + (rowCount + 1000).ToString();

            if (orderDict.Count > 0)
            {
                // insert in order table
                conn.CreateTable <Order>();
                conn.Insert(new Order()
                {
                    Id           = rowCount,
                    UserId       = Login.userId,
                    OrderDate    = date,
                    OrderTime    = time,
                    TotalAmount  = total,
                    Acknowledged = 0,
                    Deliveried   = 0,
                    ProcessTime  = "",
                    Canceled     = 0,
                    OrderNo      = orderNo
                });

                // insert in order item table
                foreach (var order in orderDict)
                {
                    string[] itemId_Price = order.Key.Split(' ');
                    int      itemId       = Convert.ToInt32(itemId_Price[0]);
                    double   price        = Convert.ToDouble(itemId_Price[1]);
                    int      quantity     = Convert.ToInt32(order.Value);

                    conn.CreateTable <OrderItem>();
                    conn.Insert(new OrderItem()
                    {
                        OrderId  = rowCount,
                        UserId   = Login.userId,
                        Date     = date,
                        Time     = time,
                        ItemId   = itemId,
                        Price    = price,
                        Quantity = quantity,
                        Total    = price * quantity
                    });
                }
                await new MessageDialog("Order is submitted successfully.\nTotal Amount: " + total).ShowAsync();
                SubmittedOrder.showOrderDict = orderDict;
                SubmittedOrder.title         = orderNo;
                this.Frame.Navigate(typeof(SubmittedOrder));
            }
        }
コード例 #2
0
 public JournalViewModel()
 {
     conn = new Connection().GetConnection();
     conn.CreateTable <Journal>();
     conn.CreateTable <NumberGenerator>();
     conn.CreateTable <Ledger>();
 }
コード例 #3
0
ファイル: BlankPage1.xaml.cs プロジェクト: mahimg/Passave
        private void button2_Click(object sender, RoutedEventArgs e)
        {
            textBlockx.Text      = "Passwords,";
            listView1.Visibility = Visibility.Collapsed;
            var query = conn.Table <Userdata>();

            conn.CreateTable <Userdata1>();
            foreach (var me in query)
            {
                if (me.Username == us)
                {
                    var s = conn.Insert(new Userdata1()
                    {
                        Site         = me.Site,
                        SiteUsername = me.SiteUsername,
                        Password     = me.Password
                    });
                }
            }
            var query2 = conn.Table <Userdata1>();

            listView.ItemsSource = query2;
            listView.Visibility  = Visibility.Visible;
            conn.DropTable <Userdata1>();
        }
コード例 #4
0
        public MainPage()
        {
            this.InitializeComponent();

            //catches current titlebar and sets custom shape as titlebar
            CoreApplicationViewTitleBar coreTitleBar = CoreApplication.GetCurrentView().TitleBar;

            coreTitleBar.ExtendViewIntoTitleBar = true;
            Window.Current.SetTitleBar(titlebar);

            //set cur titlebar as var titleBar
            var titleBar = ApplicationView.GetForCurrentView().TitleBar;

            //Titlebar colors
            titleBar.ButtonBackgroundColor         = Colors.Transparent;
            titleBar.ButtonForegroundColor         = Colors.White;
            titleBar.ButtonInactiveBackgroundColor = Colors.Transparent;

            //create array for info textboxes
            TextBox[] infoBoxArr = { usernameTextbox, cvcTextbox, passwordTextbox, accountTextbox, sq1_Textbox, sq2_Textbox, sqa1_Textbox, sqa2_Textbox, accNoTextbox, codeTextbox };

            //loop through array to manipulate properties
            for (int i = 0; i < infoBoxArr.Length; i++)
            {
                infoBoxArr[i].IsReadOnly = true;
                infoBoxArr[i].IsEnabled  = false;
            }

            //create new tables
            conn.CreateTable <Passwords>();
            conn.CreateTable <Mail>();
            conn.CreateTable <Wallet>();
            //select first category
            CategoryListbox.SelectedIndex = 0;
        }
コード例 #5
0
        public ViewModelBase()
        {
            var config = DependencyService.Get <IConfig>();

            _conexao = new SQLite.Net.SQLiteConnection(config.Plataforma, System.IO.Path.Combine(config.DiretorioDB, "bancodados3.db3"));
            _conexao.CreateTable <ProdutoCompra>();
            _conexao.CreateTable <SettingsModel>();
        }
コード例 #6
0
 public SQLiteController()
 {
     //Create db and tables if they do not exist
     path = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "db.sqlite");
     conn = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), path);
     conn.CreateTable <User>();
     conn.CreateTable <Score>();
 }
コード例 #7
0
ファイル: AcessoDados.cs プロジェクト: niltondiniz/e_Portaria
        public AcessoDados()
        {
            var config = DependencyService.Get <IConfig>();

            _conexao = new SQLite.Net.SQLiteConnection(config.Plataforma, System.IO.Path.Combine(config.DiretorioDB, "bancodados2.db3"));

            _conexao.CreateTable <Entidade>();
            _conexao.CreateTable <Estabelecimento>();
        }
コード例 #8
0
        public ViewModelBase()
        {
            var config = DependencyService.Get <IConfig>();

            _conexao = new SQLite.Net.SQLiteConnection(config.Plataforma, System.IO.Path.Combine(config.DiretorioDB, "bancodados1.db3"));
            _conexao.CreateTable <Entidade>();
            _conexao.CreateTable <Estabelecimento>();
            _conexao.CreateTable <ePortaria.Model.Controle>();
        }
コード例 #9
0
ファイル: BlankPage1.xaml.cs プロジェクト: mahimg/Passave
 public BlankPage1()
 {
     this.InitializeComponent();
     path = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path,
                         "db.sqlite");
     conn = new SQLite.Net.SQLiteConnection(new
                                            SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), path);
     conn.CreateTable <Userdata>();
     conn.CreateTable <UserNotes>();
 }
コード例 #10
0
 public static void InitializeConnection()
 {
     DBpath     = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "newdb17.sqlite");
     Connection = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), DBpath);
     Connection.CreateTable <UserModel>();
     Connection.CreateTable <TaskModel>();
     Connection.CreateTable <Comment>();
     Connection.CreateTable <FavoriteTask>();
     Connection.CreateTable <Reaction>();
 }
コード例 #11
0
 public ManageActivitiesViewModel()
 {
     AddButton    = new RelayCommand(AddButtonExecute);
     DeleteButton = new RelayCommand(DeleteButtonExecute);
     SaveButton   = new RelayCommand(SaveButtonExecute);
     Database     = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), path);
     Database.CreateTable <ServiceTable>();
     Database.CreateTable <ShiftTable>();
     this.ActivitiesListing = GetActivitiesListing();
     SelectedActivity       = ActivitiesListing[0];
 }
コード例 #12
0
ファイル: DatabaseHelper.cs プロジェクト: desmond700/BlogUWP
 public void CreateDatabase(string DB_PATH)
 {
     if (!CheckFileExists(DB_PATH).Result)
     {
         using (SQLite.Net.SQLiteConnection conn = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), DB_PATH))
         {
             conn.CreateTable <User>();
             //conn.CreateTable<Comment>();
             conn.CreateTable <Post>();
         }
     }
 }
コード例 #13
0
 //Create Tabble
 public void CreateDatabase(string DB_PATH)
 {
     if (!CheckFileExists(DB_PATH).Result)
     {
         using (SQLite.Net.SQLiteConnection conn = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), DB_PATH))
         {
             conn.CreateTable <ExpenseItem>();
             conn.CreateTable <RegularItem>();
             conn.CreateTable <UniqueExpenseItem>();
         }
     }
 }
コード例 #14
0
        public ToDo()
        {
            this.InitializeComponent();
            // 建立数据库连接
            string path = Path.Combine(ApplicationData.Current.LocalFolder.Path, "mydb.sqlite");    //建立数据库

            conn = new SQLite.Net.SQLiteConnection(new SQLitePlatformWinRT(), path);
            //建表
            conn.CreateTable <ToDoTasks>(); //默认表名同范型参数
            conn.CreateTable <ToDoTaskSteps>();
            SetThemeColor();
            LoadData();
            MainPage.Current.MyNav.IsBackEnabled = true;
            MainPage.Current.SelectedPageItem    = "ToDo";
        }
コード例 #15
0
 public PartyViewModel()
 {
     conn = new Connection().GetConnection();
     conn.CreateTable <Party>();
     settings  = new SettingsViewModel();
     accountVM = new AccountViewModel();
 }
コード例 #16
0
        CreateGameViewModel.CreateGameResult IStorage.Upload(Core.Model.Game game, FileInfo dbFile, FileInfo savedGame)
        {
            CreateGameAtGoogle cgg = new CreateGameAtGoogle();

            GoogleDrive.GoogleStorageResult googleResult = cgg.Execute(m_User, game, dbFile, savedGame);

            m_DB.CreateTable <MasterTableGoogle>();

            MasterTableGoogle googleMasterTable = new MasterTableGoogle();

            googleMasterTable.GameID     = game.ID;
            googleMasterTable.DBFileID   = googleResult.DatabaseFileID;
            googleMasterTable.GameFileID = googleResult.GameFileID;
            m_DB.Insert(googleMasterTable);

            var result = new CreateGameViewModel.CreateGameResult();

            result.GameID      = game.ID;
            result.GameType    = game.GameType;
            result.StorageType = this.Type;
            result.IDList.Add(googleResult.DatabaseFileID);
            result.IDList.Add(googleResult.GameFileID);

            return(result);
        }
コード例 #17
0
        public ProductRepository(string dbName)
        {
            path = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "db.sqlite");
            conn = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), path);

            conn.CreateTable <Products>();
        }
コード例 #18
0
        public JournalAdd()
        {
            this.InitializeComponent();
            conn = new Connection().GetConnection();
            conn.CreateTable <Journal>();
            viewModel = new JournalViewModel();
            accountVM = new AccountViewModel();
            partyVM   = new PartyViewModel();
            typeVM    = new JournalTypeViewModel();
            settings  = new SettingsViewModel();

            LoadPage();


            // Testing JSON Operation
            Dictionary <int, int> data = new Dictionary <int, int>()
            {
                { 1, 2 },
                { 3, 4 }
            };
            string abc = JsonConvert.SerializeObject(data, Formatting.Indented);

            Debug.WriteLine("###################################################");
            Debug.WriteLine(abc.ToString());

            Dictionary <int, int> returnData = JsonConvert.DeserializeObject <Dictionary <int, int> >(abc);

            Debug.WriteLine("###################################################");
            foreach (KeyValuePair <int, int> acc in returnData)
            {
                Debug.WriteLine("Key = {0}, Value = {1}", acc.Key, acc.Value);
            }
        }
コード例 #19
0
 public PartySubtypeAdd()
 {
     this.InitializeComponent();
     conn = new Connection().GetConnection();
     conn.CreateTable <PartySubtype>();
     viewModel = new PartySubtypeViewModel();
 }
コード例 #20
0
ファイル: Category.cs プロジェクト: nahidsaikat/EasyFood
        public static List <Category> getCategory()
        {
            string path;

            SQLite.Net.SQLiteConnection conn;
            path = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "db.sqlite");
            conn = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), path);
            conn.CreateTable <Category>();

            int             i             = 1;
            List <Category> categoryList  = new List <Category>();
            var             queryCategory = conn.Table <Category>();

            foreach (var category in queryCategory)
            {
                categoryList.Add(new Category()
                {
                    Id   = i,
                    Name = category.Name
                });
                i++;
            }

            return(categoryList);
        }
コード例 #21
0
ファイル: EatDb.cs プロジェクト: fabiolelis/mobileapps
        public int save()
        {
            var path = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "db.sqlite");

            using (SQLite.Net.SQLiteConnection conn = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), path))
            {
                var infoTable = conn.GetTableInfo("Eat");

                if (!infoTable.Any())
                {
                    //conn.DropTable<Eat>();
                    conn.CreateTable <Eat>();
                }
                var info = conn.GetMapping(typeof(Eat));

                if (this._eat.EatID == 0)
                {
                    var i = conn.Insert(this._eat);
                    conn.Commit();
                    return(i);
                }
                else
                {
                    var i = conn.Update(this._eat);
                    return(i);
                }
            }
        }
コード例 #22
0
        public static List <User> getUsers()
        {
            string path;

            SQLite.Net.SQLiteConnection conn;
            path = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "db.sqlite");
            conn = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), path);
            conn.CreateTable <User>();

            int         i         = 1;
            List <User> userList  = new List <User>();
            var         queryUser = conn.Table <User>();

            foreach (var user in queryUser)
            {
                userList.Add(new User()
                {
                    Id        = i,
                    FirstName = user.FirstName,
                    LastName  = user.LastName,
                    FullName  = user.FullName,
                    UserName  = user.UserName,
                    Password  = user.Password,
                    Email     = user.Email,
                    ContactNo = user.ContactNo,
                    Type      = user.Type
                });
                i++;
            }
            return(userList);
        }
コード例 #23
0
ファイル: UserDB.cs プロジェクト: fabiolelis/mobileapps
        public int save()
        {
            var path = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "db.sqlite");

            using (SQLite.Net.SQLiteConnection conn = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), path))
            {
                var infoTable = conn.GetTableInfo("User");

                if (!infoTable.Any())
                {
                  //  conn.DropTable<User>();
                    conn.CreateTable<User>();

                }
                var info = conn.GetMapping(typeof(User));

                if (this._user.UserID == 0)
                { 
                    //var i = conn.InsertOrReplace(this._user);
                    var i = conn.Insert(this._user);
                    conn.Commit();
                   // this._user.UserID = i;
                    return i;
                }
                else
                {
                    var i = conn.Update(this._user);
                    return i;
                }
                

            }
        }
コード例 #24
0
 public MainPage()
 {
     this.InitializeComponent();
     path = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "database.sqlite");; //tên file,phía trc là đường dẫn
     conn = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), path); //tạo ra 1 form sqlite theo window
     conn.CreateTable <PhoneNumber>();                                                                  //tên bảng customer
 }
コード例 #25
0
 public MainPage()
 {
     this.InitializeComponent();
     path    = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "db.sqlite");
     connect = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), path);
     connect.CreateTable <Contact>();
 }
コード例 #26
0
ファイル: AcessoDados.cs プロジェクト: felipefabreu/Login
        public AcessoDados()
        {
            var config = DependencyService.Get<iConfig> ();
            _conexao = new SQLite.Net.SQLiteConnection (config.Plataforma, System.IO.Path.Combine (config.DiretorioDB, "bancodados.db3"));

            _conexao.CreateTable<User> ();
        }
コード例 #27
0
        public AcessoDados()
        {
            var config = DependencyService.Get <IConfig>();

            _connection = new SQLite.Net.SQLiteConnection(config.Plataforma, System.IO.Path.Combine(config.DiretorioBD, "bancodedados.db3"));
            _connection.CreateTable <Usuario>();
        }
コード例 #28
0
ファイル: ItemList.xaml.cs プロジェクト: nahidsaikat/EasyFood
 public ItemList()
 {
     this.InitializeComponent();
     path = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "db.sqlite");
     conn = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), path);
     conn.CreateTable <Category>();
     loadListView();
 }
コード例 #29
0
ファイル: AcessoDados.cs プロジェクト: marcomendoma/DPXamarin
        public AcessoDados()
        {
            var config = DependencyService.Get <IConfig>();

            _conexao = new SQLite.Net.SQLiteConnection(config.Plataforma, System.IO.Path.Combine(config.DiretorioDB, "comicDB.db3"));

            _conexao.CreateTable <Comic>();
        }
コード例 #30
0
 public upload_link()
 {
     this.InitializeComponent();
     this.NavigationCacheMode = Windows.UI.Xaml.Navigation.NavigationCacheMode.Enabled;
     path = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "db1.sqlite");
     conn = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), path);
     conn.CreateTable <irfan3>();
 }
コード例 #31
0
 public AccountViewModel()
 {
     conn = new Connection().GetConnection();
     conn.CreateTable <Account>();
     settings  = new SettingsViewModel();
     jtVM      = new JournalTypeViewModel();
     journalVM = new JournalViewModel();
 }
コード例 #32
0
        public AcessoDadosUsuario()
        {
            var config = DependencyService.Get <IConfig>();           //utiliza dependency para verificar qual plataforma esta sendo utilizada

            _conexao = new SQLite.Net.SQLiteConnection(config.Plataforma, System.IO.Path.Combine(config.DiretorioDB, "bancodados.db3"));

            _conexao.CreateTable <Usuario>();
        }
コード例 #33
0
        public MainPage()
        {
            this.InitializeComponent();

            path = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "db.sqlite");

            conn = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), path);

            conn.CreateTable<DatabaseModel>();

            timer = new DispatcherTimer();
            timer.Interval = TimeSpan.FromSeconds(1); // 1 sec
            timer.Tick += Timer_Tick;
            timer.Start();

            nisTime = NisTime.GetFastestNISTDate();
            System.Diagnostics.Debug.WriteLine(nisTime.ToString());
        }
コード例 #34
0
        public MainPage()
        {
            this.InitializeComponent();
            path = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "giamcandb.sqlite");
            connection = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), path);
            // tao bang NguoiDung
            connection.CreateTable<NguoiDung>();
            // tao bang MucTieu
            connection.CreateTable<MucTieu>();
            // tao bang MonAn
            connection.CreateTable<MonAn>();
            connection.CreateTable<ThongKeNgay>();
            connection.CreateTable<ThongKeBaiTap>();
            connection.CreateTable<ThucDon>();
            connection.CreateTable<BaiTap>();

        }
コード例 #35
0
        public MainPage()
        {
            this.InitializeComponent();
            path = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "db1.sqlite");
            conn = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), path);
            conn.CreateTable<MainTable>();
            Debug.WriteLine(path);

            //initialize timer
            currentTimer.name = "new timer";
            currentTimer.category = "default";
            currentTimer.start = DateTime.Now;
            currentTimer.end = DateTime.Now;
            currentTimer.timeElapse = TimeSpan.Zero;
            currentTimer.running = false;
            currentTimer.tag = 0;

            DispatcherTimerSetup();
        }
コード例 #36
0
ファイル: MainPage.xaml.cs プロジェクト: mleray/HCI
        /// <summary>
        /// Initialization of the page, empty constructor
        /// </summary>

        public MainPage()
        {
            this.InitializeComponent();
            localSettings = Windows.Storage.ApplicationData.Current.LocalSettings; //creates local settings for the application
            var bl = localSettings.Values["budgetLeft"];
            var b = localSettings.Values["budget"];
            var c = localSettings.Values["currency"];
            var t = localSettings.Values["thresh"];
            if (b != null && bl != null && c != null && t != null) //checks if settings are initialized
            {
                please.Visibility = Visibility.Collapsed;
                you_are_text.Visibility = Visibility.Visible;
                add_button.IsEnabled = true;
                currency = (int)c;
                budget = (int)b;
                budgetLeft = (int)bl;
                threshold = (int)t;

                if (currency == 1) // it means it is in euros
                {
                    euro.Visibility = Visibility.Visible;
                    ft.Visibility = Visibility.Collapsed;
                }
                else // it means it is in forints
                {
                    ft.Visibility = Visibility.Visible;
                    euro.Visibility = Visibility.Collapsed;
                }
                thresh.Text += " " + budgetLeft;
                canvas_left.Visibility = Visibility.Visible;
                if (DateTime.Today.Day == 1) //means that we need to reinitialize the budget
                {
                    budgetLeft = budget;
                    localSettings.Values["budgetLeft"] = budget;
                    thresh.Text = " ";
                    thresh.Text += budgetLeft;
                }
                if (budgetLeft <= threshold) // you are in the red
                {
                    green_text.Visibility = Visibility.Collapsed;
                    red_text.Visibility = Visibility.Visible;
                }
                else // you are in the green
                {
                    red_text.Visibility = Visibility.Collapsed;
                    green_text.Visibility = Visibility.Visible;
                }
            } else // settings must be initialized
            {
                you_are_text.Visibility = Visibility.Collapsed;
                green_text.Visibility = Visibility.Collapsed;
                red_text.Visibility = Visibility.Collapsed;
                canvas_left.Visibility = Visibility.Collapsed;
                please.Visibility = Visibility.Visible;
                add_button.IsEnabled = false;
            }
            SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Collapsed; // no back button
            path = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "db_spend"); // create database
            conn = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), path);
            conn.CreateTable<Spending>(); // create table for spendings
        }
コード例 #37
0
        /// <summary>
        /// Checks if the database exists, if not create one
        /// </summary>
        private void ChechIfDbExist()
        {
            var sqlpath = System.IO.Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "GameHistoryDB.sqlite"); //Path for the DB

            using (SQLite.Net.SQLiteConnection conn =
                new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), sqlpath))//The connection
            {
                var tableExistsQuery = "SELECT name FROM sqlite_master WHERE type='table' AND name='GameHistory'"; //SQL-Query
                var result = conn.ExecuteScalar<string>(tableExistsQuery);
                if (result == null)
                {
                    conn.CreateTable<GameHistory>();
                }
                connection = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), sqlpath);
            }
        }
コード例 #38
0
        public ApplicationSettings()
        {
            try
            {
                Connection = DependencyService.Get<IDBConnection>().GetConnection();

                var userTableInfo = Connection.GetTableInfo("User");

                if (userTableInfo == null || userTableInfo.Count < 1)
                {
                    Connection.CreateTable<User>();
                }

                var emationsInfo = Connection.GetTableInfo("Emotion");
                if (emationsInfo == null || emationsInfo.Count < 1)
                {
                    Connection.CreateTable<Emotion>();
                }

                var userEventInfo = Connection.GetTableInfo("UserEvent");
                if (userEventInfo == null || userEventInfo.Count < 1)
                {
                    Connection.CreateTable<UserEvent>();
                }
                var appSettingsTableInfo = Connection.GetTableInfo("GlobalSettings");
                if (appSettingsTableInfo == null ||appSettingsTableInfo.Count < 1)
                {
                    Connection.CreateTable<GlobalSettings>();
                }

				var gemsEventTitleInfo = Connection.GetTableInfo("EventTitle");
				if (gemsEventTitleInfo == null || gemsEventTitleInfo.Count < 1)
				{
					Connection.CreateTable<EventTitle>();
				}

				var gemsEventDateAndTime = Connection.GetTableInfo("EventDatetime");
				if (gemsEventDateAndTime == null || gemsEventDateAndTime.Count < 1)
				{
					Connection.CreateTable<EventDatetime>();
				}

				var gemsEventDetails = Connection.GetTableInfo("EventDetail");
				if (gemsEventDetails == null || gemsEventDetails.Count < 1)
				{
					Connection.CreateTable<EventDetail>();
				}

				var gemsEventMedia = Connection.GetTableInfo("EventMedia");
				if (gemsEventMedia == null || gemsEventMedia.Count < 1)
				{
					Connection.CreateTable<EventMedia>();
				}


				var gemsEmotions = Connection.GetTableInfo("GemsEmotionsDetailsDB");
				if (gemsEmotions == null || gemsEmotions.Count < 1)
				{
					Connection.CreateTable<GemsEmotionsDetailsDB>();
				}

				var gemsActionTitleInfo = Connection.GetTableInfo("ActionTitle");
				if (gemsActionTitleInfo == null || gemsActionTitleInfo.Count < 1)
				{
					Connection.CreateTable<ActionTitle>();
				}

				var gemsActionDateAndTime = Connection.GetTableInfo("ActionDatetime");
				if (gemsActionDateAndTime == null || gemsActionDateAndTime.Count < 1)
				{
					Connection.CreateTable<ActionDatetime>();
				}

				var gemsActionDetails = Connection.GetTableInfo("ActionDetail");
				if (gemsActionDetails == null || gemsActionDetails.Count < 1)
				{
					Connection.CreateTable<ActionDetail>();
				}

				var gemsActionMedia = Connection.GetTableInfo("ActionMedia");
				if (gemsActionMedia == null || gemsActionMedia.Count < 1)
				{
					Connection.CreateTable<ActionMedia>();
				}

				var gemsGoalsDetailsDB = Connection.GetTableInfo("GemsGoalsDetailsDB");
				if (gemsGoalsDetailsDB == null || gemsGoalsDetailsDB.Count < 1)
				{
					Connection.CreateTable<GemsGoalsDetailsDB>();
				}


                var pendingGoals = Connection.GetTableInfo("PendingGoalsDetailsDB");
                if (pendingGoals == null || pendingGoals.Count < 1)
                {
                    Connection.CreateTable<PendingGoalsDetailsDB>();
                }

                var pendingActionTitle = Connection.GetTableInfo("PendingActionTitle");
                if (pendingActionTitle == null || pendingActionTitle.Count < 1)
                {
                    Connection.CreateTable<PendingActionTitle>();
                }

                var completedGoals = Connection.GetTableInfo("CompletedGoalsDetailsDB");
                if (completedGoals == null || completedGoals.Count < 1)
                {
                    Connection.CreateTable<CompletedGoalsDetailsDB>();
                }

                var completedActionTitle = Connection.GetTableInfo("CompletedActionTitle");
                if (completedActionTitle == null || completedActionTitle.Count < 1)
                {
                    Connection.CreateTable<CompletedActionTitle>();
                }

				var communityGemsDetailsDB = Connection.GetTableInfo("CommunityGemsDetailsDB");
				if (communityGemsDetailsDB == null || communityGemsDetailsDB.Count < 1)
				{
					Connection.CreateTable<CommunityGemsDetailsDB>();
				}

				var gemMedia = Connection.GetTableInfo("GemMedia");
				if (gemMedia == null || gemMedia.Count < 1)
				{
					Connection.CreateTable<GemMedia>();
				}

				var eventITbl = Connection.GetTableInfo("EventWithImage");
				if (eventITbl == null || eventITbl.Count < 1) {
					Connection.CreateTable<EventWithImage>();
				}

				var actionITable = Connection.GetTableInfo("ActionWithImage");
				if (actionITable == null || actionITable.Count < 1) {
					Connection.CreateTable<ActionWithImage>();
				}
            }
            catch (Exception ex)
            {
                Debug.WriteLine("AplicationSettings :: " + ex.Message);
            }
        }