-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCheckoutPage.xaml.cs
More file actions
74 lines (62 loc) · 1.79 KB
/
CheckoutPage.xaml.cs
File metadata and controls
74 lines (62 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
namespace LibraryOne;
using LibraryOne.DataBase;
using LibraryOne.BookClass;
public partial class CheckoutPage : ContentPage
{
//Add Database functionality
public SqlDatabase Database { get; set; }
// Added for picker function in checkout page
private Book selectedBook;
public Book SelectedBook
{
get { return selectedBook; }
set
{
selectedBook = value;
OnPropertyChanged();
}
}
private string authorFullName;
public string AuthorFullName
{
get { return authorFullName; }
set
{
authorFullName = value;
OnPropertyChanged();
}
}
private bool availability;
public bool Availability
{
get { return availability; }
set
{
availability = value;
OnPropertyChanged();
}
}
public CheckoutPage(Book book)
{
InitializeComponent();
SelectedBook = book;
AuthorFullName = book.AuthorFirstName + " " + book.AuthorLastName;
Availability = !book.IsCheckedOut;
this.BindingContext = this;
// Create connection to database
this.Database = new SqlDatabase();
this.Database.Open();
}
private async void GoToMainPage(object sender, EventArgs e)
{
await Navigation.PushAsync(new MainPage());
}
private async void ClickSubmitCheckOut(object sender, EventArgs e)
{
// Update the database to mark the book as checked out and set the CheckedOutDate to the current date
this.Database.UpdateBook(SelectedBook.Isbn, true);
await Navigation.PushAsync(new MainPage());
// Tell the user the book was checked out
this.DisplayAlert("Success!", "Book checked out", "OK");
}
}