Esempio n. 1
0
		// called every time the class is instantiated.
		public void SetDetailItem (Book newDetailItem)
		{

			if (DetailItem != newDetailItem) 
			{
				DetailItem = newDetailItem;

				this.Title = DetailItem.getTitle ();

				// set the photo until otherwise determined
				//coverImage.Image = UIImage.FromBundle ("unavailable.png");

				// Update the view
				ConfigureView ();
			}
		}
Esempio n. 2
0
        public void SetBookItem(Book newDetailItem)
        {
            if (newBook != newDetailItem) {
                newBook = newDetailItem;

                // attempt to set it manually
                newBook.title = newDetailItem.getTitle ();
                newBook.author = newDetailItem.getAuthor ();
                newBook.publisher = newDetailItem.getPublisher ();
                newBook.summary = newDetailItem.getSummary ();
                newBook.isbn = newDetailItem.getIsbn ();
                newBook.dateadded = newDetailItem.getDateAdded ();
                timeAdded = newDetailItem.getDateAdded ();
                Console.Out.WriteLine ("Time added: " + timeAdded.ToString ());

                Console.Out.WriteLine ("Set Book Item entered: " + newBook.getTitle ());
            }
        }
		async void scanIsbn()
		{
			// start the barcode scanner
			var scanner = new ZXing.Mobile.MobileBarcodeScanner();
			var result = await scanner.Scan();

			try
			{
				// create an object to hold the book.
				Book newBook = new Book (result.Text);
				Console.Out.WriteLine ("newbook title: " + newBook.getTitle ());

				// make sure it's actually a book before adding it.
				try
				{
					if (newBook.getAuthor().Length > 3) 
					{
						insertToDatabase (newBook);
						Console.Out.WriteLine("newbook added");
						dataSource.Objects.Insert (0, newBook);

						using (var indexPath = NSIndexPath.FromRowSection (0, 0))
							TableView.InsertRows (new [] { indexPath }, UITableViewRowAnimation.Automatic);

					} else
						Console.Out.WriteLine ("newbook seems to be null");
				}
				catch(Exception ex)
				{
					Console.Out.WriteLine ("Adding newbook error: " + ex.ToString ());
				}
			}
			catch(Exception ex)
			{
				Console.Out.WriteLine ("scanning was probably canceled.\n" + ex.ToString ());
			}
		}
			public void deleteFromDatabase(Book oldBook)
			{
				Console.Out.WriteLine("Book " + oldBook.getTitle() + " deleted from database.");

				using (var db = new SQLite.SQLiteConnection(_pathToDatabase))
				{
					Console.Out.WriteLine ("object deleted: " + oldBook.getDateAdded ());
					db.Delete (oldBook);
					//return Delete
				}
			}
		private void insertToDatabase(Book newBook)
		{
			using (var db = new SQLite.SQLiteConnection(_pathToDatabase ))
			{
				db.Insert(newBook);
			}
			Console.Out.WriteLine ("Book " + newBook.getTitle () + " inserted into database.");
		}