/
BookSearch.cs
85 lines (82 loc) · 3.23 KB
/
BookSearch.cs
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
75
76
77
78
79
80
81
82
83
84
85
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace SA_Team10bCAProject
{
public partial class BooksSearch : Form
{
SA47_Team10BCADatabaseEntities context = new SA47_Team10BCADatabaseEntities();
public BooksSearch()
{
InitializeComponent();
}
private void button2_Click(object sender, EventArgs e)
{
BooksSearchList a = new BooksSearchList();
DialogResult b = a.ShowDialog();
if(b==DialogResult.OK)
{
Book_NameBox.Text = a.Book_Name1;
AuthorBox.Text =a.Author1;
publisherBox.Text =a.Publisher1;
EditionBox.Text =a.Edition1;
CategoryBox.Text = a.Category1;
Total_QuantityBox.Text =a.Total_Quantity1;
Number_BorrowedBox.Text =a.Number_Borrowed1;
Retrieve_BookNumeric.Value = a.Book_ID1;
if(Total_QuantityBox.Text==Number_BorrowedBox.Text)
{
IssueReturn c = context.IssueReturn.Where(x => x.BookID == Retrieve_BookNumeric.Value).OrderBy(x => x.DateExpiry).First();
Can_Borrow_DateBox.Text = c.DateExpiry.ToLongDateString();
}
else
{
Can_Borrow_DateBox.Text = "now";
}
}
}
private void Retrieve_Book_Click(object sender, EventArgs e)
{
var BID = from x in context.Books where x.BookID == Retrieve_BookNumeric.Value select x;
List<Books> b = BID.ToList<Books>();
if (b.Count != 0)
{
Books c = context.Books.Where(x => x.BookID == Retrieve_BookNumeric.Value).First();
Book_NameBox.Text = c.BookName;
AuthorBox.Text = c.Author;
publisherBox.Text = c.Publisher;
EditionBox.Text = c.Edition;
CategoryBox.Text = c.Category;
Total_QuantityBox.Text = c.TotalQuantity.ToString();
Number_BorrowedBox.Text = c.NumberBorrowed.ToString();
if (Total_QuantityBox.Text == Number_BorrowedBox.Text)
{
IssueReturn q = context.IssueReturn.Where(x => x.BookID == Retrieve_BookNumeric.Value).OrderBy(x => x.DateExpiry).First();
Can_Borrow_DateBox.Text = q.DateExpiry.ToLongDateString();
}
else
{
Can_Borrow_DateBox.Text = "Now";
}
}
else
{
Book_NameBox.Text = "";
AuthorBox.Text = "";
publisherBox.Text = "";
EditionBox.Text = "";
CategoryBox.Text = "";
Total_QuantityBox.Text = "";
Number_BorrowedBox.Text = "";
Can_Borrow_DateBox.Text = "";
MessageBox.Show("Please re-enter BookID.");
}
}
}
}