public int createNewCategory(Categories c) {
     int rows = conn.Insert(c);
     return rows;
 }
Пример #2
0
        //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
        //SQLITE
        private void createSqliteDb() {
            string path = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "db3.sqlite");
            SQLiteConnection conn = new SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), path);

            conn.CreateTable<Account>();
            conn.CreateTable<Categories>();
            conn.CreateTable<TransactionMod>();
            conn.CreateTable<DebtMod>();
            conn.CreateTable<LendMod>();

            try {

                List<Categories> cats = (from c in conn.Table<Categories>()
                                         select c).ToList();

                if (cats.Count == 0) {
                    Categories c = new Categories();
                    List<string> names = c.getListOfCategories();
                    foreach(string name in names) {
                        c = new Categories(name);
                        conn.Insert(c);
                    }
                }
            }
            catch (SQLiteException) {

            }
        }