Пример #1
0
        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;
                }
                

            }
        }
Пример #2
0
        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);
                }
            }
        }
Пример #3
0
        public SQLite.Net.SQLiteConnection GetConnection()
        {
            // Create the connection
            var plat = new SQLite.Net.Platform.XamarinIOS.SQLitePlatformIOS ();
            var conn = new SQLite.Net.SQLiteConnection (plat, FilePath);
            // Return the database connection

            var d = conn.GetTableInfo ("Person");

            var m = conn.Table<Person> ().Table;

            return conn;
        }
Пример #4
0
        public SQLite.Net.SQLiteConnection GetConnection()
        {
            // Create the connection
            var plat = new SQLite.Net.Platform.XamarinIOS.SQLitePlatformIOS();
            var conn = new SQLite.Net.SQLiteConnection(plat, FilePath);
            // Return the database connection

            var d = conn.GetTableInfo("Person");

            var m = conn.Table <Person> ().Table;

            return(conn);
        }
Пример #5
0
        public bool TableExists(string tableName)
        {
            using (SQLite.Net.SQLiteConnection con = GetConnection()) {
                var tableInfo = con.GetTableInfo(tableName);

                if (tableInfo != null && tableInfo.Count > 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
        }
        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);
            }
        }