Example #1
0
        public static bool SaveAll()
        {
            try
            {
                DatabaseServices.DeleteAll <UserDB>(Database.connection);

                foreach (var user in Model.Users)
                {
                    var row = new UserDB();
                    row.UserName  = user.UserName;
                    row.Password  = user.Password;
                    row.ServerURL = user.ServerURL;
                    row.FirstName = user.FirstName;
                    row.Surname   = user.Surname;

                    Database.connection.Insert(row);
                }
            }
            catch
            {
                return(false);
            }

            return(true);
        }
        public static bool SaveAll()
        {
            try
            {
                DatabaseServices.DeleteAll <ItemDB>(Database.connection);

                foreach (var item in Model.Items)
                {
                    var row = new ItemDB();
                    row.id         = item.id;
                    row.Name       = item.Name;
                    row.Address    = item.Address;
                    row.Detail     = item.Detail;
                    row.IconSource = item.Icon.Source as FileImageSource;

                    Database.connection.Insert(row);
                }
            }
            catch
            {
                return(false);
            }

            return(true);
        }
Example #3
0
        protected override void OnStart()
        {
            // Handle when your app starts

            Database.connection = DatabaseServices.OpenDatabase(Database.dbName);
            Database.LoadModel();
        }
Example #4
0
        public App()
        {
            if (!DatabaseServices.DatabaseExists(Database.dbName))
            {
                //	This is the first time so create the DB
                Database.CreateDatabase(Database.dbName);
            }

            //MainPage = new NavigationPage(new MyListPage());

            MainPage = new NavigationPage(new TabController()
            {
                // Tab bar format
                BarBackgroundColor = Color.FromHex("c0c0c0"),
                BarTextColor       = Color.White
            })
            {
                // Navigation page format
                BarBackgroundColor = Color.FromHex("1275bb"),
                BarTextColor       = Color.White
            };

            //MainPage = new NavigationPage(new TabController()
            //{
            //	// Tab bar format
            //	BarBackgroundColor = Color.Blue,
            //	BarTextColor = Color.White
            //});
        }
Example #5
0
        public App()
        {
            if (!DatabaseServices.DatabaseExists(Database.dbName))
            {
                //	This is the first time so create the DB
                Database.CreateDatabase(Database.dbName);
            }

            MainPage = new NavigationPage(new MyListPage());
        }
        public static bool LoadAll()
        {
            try
            {
                var q = DatabaseServices.Query <ItemDB>(Database.connection);
                Model.Items.Clear();
                foreach (var itemDB in q)
                {
                    Item item = new Item();
                    item.id          = itemDB.id;
                    item.Name        = itemDB.Name;
                    item.Address     = itemDB.Address;
                    item.Detail      = itemDB.Detail;
                    item.Icon.Source = itemDB.IconSource;

                    Model.Items.Add(item);
                }
            }
            catch
            {
                return(false);
            }
            return(true);
        }
Example #7
0
        public static bool LoadAll()
        {
            try
            {
                var q = DatabaseServices.Query <UserDB>(Database.connection);
                Model.Users.Clear();
                foreach (var row in q)
                {
                    User user = new User();
                    user.UserName  = row.UserName;
                    user.Password  = row.Password;
                    user.ServerURL = row.ServerURL;
                    user.FirstName = row.FirstName;
                    user.Surname   = row.Surname;

                    Model.Users.Add(user);
                }
            }
            catch
            {
                return(false);
            }
            return(true);
        }
Example #8
0
 public static void CreateDatabase(String dbname)
 {
     connection = DatabaseServices.OpenDatabase(dbName);
     DatabaseServices.CreateTable <ItemDB>(connection);
     DatabaseServices.CreateTable <UserDB>(connection);
 }
Example #9
0
 protected override void OnSleep()
 {
     // Handle when your app sleeps
     Database.SaveModel();
     DatabaseServices.CloseDatabase(Database.connection);
 }