Пример #1
0
 //        public static bool saveChanges()
 //        {
 //            // Save to db
 //            string dbPath = GetDBPath();
 //            var db = new SQLiteConnection(dbPath);
 //            db.DeleteAll<BNRItem>();
 //            db.BeginTransaction();
 //            db.InsertAll(allItems);
 //            db.Commit();
 //            db.Close();
 //            return true;
 // Archive method of saving
 //            // returns success or failure // For archiving method of saving
 //            string path = itemArchivePath(); // For archiving method of saving
 //            NSMutableArray newArray = new NSMutableArray(); // For archiving method of saving
 //            foreach (BNRItem item in allItems) { // For archiving method of saving
 //                newArray.Add(item); // For archiving method of saving
 //            } // For archiving method of saving
 //            return NSKeyedArchiver.ArchiveRootObjectToFile(newArray, path); // For archiving method of saving
 //        }
 public static void addAssetType(string assetType)
 {
     string dbPath = GetDBPath();
     SQLiteConnection db;
     if (File.Exists(dbPath)) {
         db = new SQLiteConnection(dbPath);
         db.BeginTransaction();
         var at = new BNRAssetType();
         at.assetType = assetType;
         allAssetTypes.Add(at);
         db.Insert(at);
         db.Commit();
         db.Close();
     }
 }
Пример #2
0
//		public static bool saveChanges()
//		{
//			// Save to db
//			string dbPath = GetDBPath();
//			var db = new SQLiteConnection(dbPath);
//			db.DeleteAll<BNRItem>();
//			db.BeginTransaction();
//			db.InsertAll(allItems);
//			db.Commit();
//			db.Close();
//			return true;

        // Archive method of saving
//			// returns success or failure // For archiving method of saving
//			string path = itemArchivePath(); // For archiving method of saving
//			NSMutableArray newArray = new NSMutableArray(); // For archiving method of saving
//			foreach (BNRItem item in allItems) { // For archiving method of saving
//				newArray.Add(item); // For archiving method of saving
//			} // For archiving method of saving
//			return NSKeyedArchiver.ArchiveRootObjectToFile(newArray, path); // For archiving method of saving
//		}

        public static void addAssetType(string assetType)
        {
            string           dbPath = GetDBPath();
            SQLiteConnection db;

            if (File.Exists(dbPath))
            {
                db = new SQLiteConnection(dbPath);
                db.BeginTransaction();
                var at = new BNRAssetType();
                at.assetType = assetType;
                allAssetTypes.Add(at);
                db.Insert(at);
                db.Commit();
                db.Close();
            }
        }
Пример #3
0
        public static void loadItemsFromDatabase()
        {
//			string path = itemArchivePath(); // Archiving method of saving
//			var unarchiver = (NSMutableArray)NSKeyedUnarchiver.UnarchiveFile(path); // Archiving method of saving
//			if (unarchiver != null) { // Archiving method of saving
//				for (int i = 0; i < unarchiver.Count; i++) { // Archiving method of saving
//					allItems.Add(unarchiver.GetItem<BNRItem>(i)); // Archiving method of saving
//				} // Archiving method of saving
//			} // Archiving method of saving

            string           dbPath = GetDBPath();
            SQLiteConnection db;

            if (!File.Exists(dbPath))
            {
                db = new SQLiteConnection(dbPath);
                db.CreateTable <BNRAssetType>();
                db.CreateTable <BNRItem>();
                db.BeginTransaction();
                var at = new BNRAssetType();
                at.assetType = "Furniture";
                db.Insert(at);
                at.assetType = "Computer";
                db.Insert(at);
                at.assetType = "Electronics";
                db.Insert(at);
                at.assetType = "Musical Instrument";
                db.Insert(at);
                at.assetType = "Tool";
                db.Insert(at);
                at.assetType = "Clothes";
                db.Insert(at);
                db.Commit();
                db.Close();
                db = null;
            }
            db            = new SQLiteConnection(dbPath);
            allAssetTypes = db.Query <BNRAssetType>("SELECT * FROM BNRAssetTypes ORDER BY assetType");
            allItems      = db.Query <BNRItem>("SELECT * FROM BNRItems ORDER BY orderingValue");
        }
Пример #4
0
        public static void loadItemsFromDatabase()
        {
            //			string path = itemArchivePath(); // Archiving method of saving
            //			var unarchiver = (NSMutableArray)NSKeyedUnarchiver.UnarchiveFile(path); // Archiving method of saving
            //			if (unarchiver != null) { // Archiving method of saving
            //				for (int i = 0; i < unarchiver.Count; i++) { // Archiving method of saving
            //					allItems.Add(unarchiver.GetItem<BNRItem>(i)); // Archiving method of saving
            //				} // Archiving method of saving
            //			} // Archiving method of saving

            string dbPath = GetDBPath();
            SQLiteConnection db;
            if (!File.Exists(dbPath)) {
                db = new SQLiteConnection(dbPath);
                db.CreateTable<BNRAssetType>();
                db.CreateTable<BNRItem>();
                db.BeginTransaction();
                var at = new BNRAssetType();
                at.assetType = "Furniture";
                db.Insert(at);
                at.assetType = "Computer";
                db.Insert(at);
                at.assetType = "Electronics";
                db.Insert(at);
                at.assetType = "Musical Instrument";
                db.Insert(at);
                at.assetType = "Tool";
                db.Insert(at);
                at.assetType = "Clothes";
                db.Insert(at);
                db.Commit();
                db.Close();
                db = null;
            }
            db = new SQLiteConnection(dbPath);
            allAssetTypes = db.Query<BNRAssetType>("SELECT * FROM BNRAssetTypes ORDER BY assetType");
            allItems = db.Query<BNRItem>("SELECT * FROM BNRItems ORDER BY orderingValue");
        }