Beispiel #1
0
        public static bool CreateBorrowTransaction(Dictionary <string, string> queries)
        {
            string   RFID      = queries["RFID"];
            long     memberID  = long.Parse(queries["MemberID"]);
            DateTime issueDate = DateTime.Parse(queries["DateIssued"]);
            DateTime dueDate   = DateTime.Parse(queries["DateDue"]);

            SA45Team07B_LibraryEntities context = new SA45Team07B_LibraryEntities();

            RFIDTag rFIDTag = context.RFIDs.Where(x => x.RFID == RFID).First();

            /*This transaction combines three sequences:
             * - create new issue tran in IssueTrans
             * - increment of member's loan qty in Members
             * - change the availability of RFID in RFIDs
             * */
            using (TransactionScope ts = new TransactionScope())
            {
                IssueTran tran = new IssueTran
                {
                    RFID       = RFID,
                    MemberID   = memberID,
                    DateIssued = issueDate,
                    DateDue    = dueDate
                };

                context.IssueTrans.Add(tran);

                Member member = context.Members.Where(x => x.MemberID == memberID).First();
                member.LoanedQty += 1;

                rFIDTag.Availability = "n";

                try
                {
                    context.SaveChanges();
                    ts.Complete();
                }
                catch (Exception e)
                {
                    return(false);
                }
            }

            //After the transaction succeeded, update the trans id in RDIDs
            var query = (from x in context.IssueTrans orderby x.TransactionID descending select x).Take(1);

            rFIDTag.LastTransactionID = query.First().TransactionID;
            context.SaveChanges();
            return(true);
        }
Beispiel #2
0
        public static RFIDTag GetRFIDTag(string RFID)
        {
            SA45Team07B_LibraryEntities context = new SA45Team07B_LibraryEntities();

            try
            {
                RFIDTag tag = context.RFIDs.Where(x => x.RFID == RFID).First();
                return(tag);
            }
            catch (InvalidOperationException e)
            {
                return(null);
            }
        }
Beispiel #3
0
        public static Member GetMember(long memberID)
        {
            SA45Team07B_LibraryEntities context = new SA45Team07B_LibraryEntities();

            try
            {
                Member member = context.Members.Where(x => x.MemberID == memberID).First();
                return(member);
            }
            catch (InvalidOperationException e)
            {
                return(null);
            }
        }
Beispiel #4
0
        private void ValidatetxtbRFID()
        {
            using (SA45Team07B_LibraryEntities context = new SA45Team07B_LibraryEntities())
            {
                string inputRFID = txtbRFID.Text.ToString();

                this.RFIDofReturnBook = (from x in context.RFIDs
                                         where x.RFID == inputRFID
                                         select x).FirstOrDefault();

                if (RFIDofReturnBook != null)
                {
                    this.returnBook = RFIDofReturnBook.Books;

                    lastTransaction = (from x in context.IssueTrans
                                       where x.TransactionID == RFIDofReturnBook.LastTransactionID
                                       select x).FirstOrDefault();

                    if (lastTransaction == null)
                    {
                        ClearTextboxData();
                        MessageBox.Show("No last transaction record.");
                    }
                    else if (lastTransaction.Status == "in")
                    {
                        ClearTextboxData();
                        MessageBox.Show("No active transaction record.");
                    }
                    else
                    {
                        borrower           = lastTransaction.Members;
                        borrowerMemberType = borrower.MemberCategories;
                        borrowerFaculty    = borrower.Faculties;

                        DisplayTextboxData();

                        errorProviderForRFID.SetError(txtbRFID, "");
                        toolStripStatusLabel1.Text = "1 record is found.";
                        btnSubmit.Enabled          = true;
                    }
                }
                else
                {
                    errorProviderForRFID.SetError(txtbRFID, "Invalid RFID");
                    toolStripStatusLabel1.Text = "Invalid RFID";
                    ClearTextboxData();
                    btnSubmit.Enabled = false;
                }
            }
        }
Beispiel #5
0
        private void BookPopUpSearch_Load(object sender, EventArgs e)
        {
            using (SA45Team07B_LibraryEntities context = new SA45Team07B_LibraryEntities())
            {
                var subjectNameList = (from x in context.BookSubjects
                                       select x.SubjectName).ToList();

                subjectNameList.Insert(0, "");

                cbSubject.DataSource = subjectNameList;

                SearchAndDisplayBook(false);
                isFirstLoad = true;
            }
        }
Beispiel #6
0
        //true means "in"
        public static bool CheckRFIDAvailability(string RFID)
        {
            SA45Team07B_LibraryEntities context = new SA45Team07B_LibraryEntities();
            RFIDTag   tag     = context.RFIDs.Where(x => x.RFID == RFID).First();
            long?     transID = tag.LastTransactionID;
            IssueTran trans   = context.IssueTrans.Where(x => x.TransactionID == transID).First();

            if (trans.Status == "out")
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
        private void btnSaveChanges_Click(object sender, EventArgs e)
        {
            IssueTran selectedTransaction = null;

            if (dataGridViewTransactionRecords.RowCount != 0)
            {
                long transactionID = Int64.Parse(dataGridViewTransactionRecords.CurrentRow.Cells["TransactionIDColumn"].Value.ToString());

                using (SA45Team07B_LibraryEntities context = new SA45Team07B_LibraryEntities())
                {
                    selectedTransaction = (from x in context.IssueTrans
                                           where x.TransactionID == transactionID
                                           select x).First();

                    if (selectedTransaction != null)
                    {
                        using (TransactionScope ts = new TransactionScope())
                        {
                            if (txtbRemarksOfSelectedTransaction.Text.Length > 255)
                            {
                                // should no happen as the textbox max length is 255
                                MessageBox.Show("Remarks exceed maximum length.");
                            }
                            else
                            {
                                selectedTransaction.Remarks = txtbRemarksOfSelectedTransaction.Text.ToString();
                                int i = context.SaveChanges();
                                ts.Complete();

                                if (i > 0)
                                {
                                    submitSuccessful = true;
                                }
                                else
                                {
                                    submitSuccessful = false;
                                }

                                this.ActiveControl = txtbRemarksOfSelectedTransaction;
                            }
                        }
                    }
                }
            }

            DisplayDGVData();
        }
Beispiel #8
0
        private void maskedTextBoxSchoolID_Validating(object sender, CancelEventArgs e)
        {
            SA45Team07B_LibraryEntities context1 = new SA45Team07B_LibraryEntities();
            var matchingRecord = context1.Members.Where(x => x.SchoolID == maskedTextBoxSchoolID.Text).FirstOrDefault();

            if (matchingRecord != null)
            {
                errorProviderSchoolID.SetError(maskedTextBoxSchoolID, "Member already exists.");
            }
            else if (!maskedTextBoxSchoolID.MaskFull)
            {
                errorProviderSchoolID.SetError(maskedTextBoxSchoolID, "Number of characters should be 9.");
            }
            else
            {
                errorProviderSchoolID.SetError(maskedTextBoxSchoolID, "");
            }
        }
Beispiel #9
0
        //Add for Add Publisher
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            SA45Team07B_LibraryEntities context2 = new SA45Team07B_LibraryEntities();
            Publisher pb             = new Publisher();
            var       matchingRecord = context2.Publishers.Where(x => x.PublisherID == textBoxPublisherID.Text.Trim()).FirstOrDefault();

            if (matchingRecord != null)
            {
                errorProviderPublisherID.SetError(textBoxPublisherID, "Member already exists.");
            }
            else
            {
                pb.PublisherID = textBoxPublisherID.Text.Trim();

                pb.PublisherName = textBoxPublisherName.Text.Trim();
                if (comboBoxCountry.SelectedItem != null && (comboBoxCountry.SelectedItem.ToString() != "Not Applicable"))
                {
                    pb.Country = comboBoxCountry.SelectedItem.ToString();
                }
                else
                {
                    pb.Country = "";
                }

                DialogResult dr = MessageBox.Show("Confirm add new publisher?", "Confirmation", MessageBoxButtons.YesNoCancel);
                if (dr == DialogResult.Yes)
                {
                    context2.Publishers.Add(pb);
                    context2.SaveChanges();
                    MessageBox.Show(string.Format("Successfully added Publisher <<{0}>>.", pb.PublisherName));
                    SA45Team07B_LibraryEntities context = new SA45Team07B_LibraryEntities();
                    var query = from x in context.Publishers select new { x.PublisherID, x.PublisherName, x.Country };
                    dataGridViewPublishers.DataSource = query.ToList();
                }
                else if (dr == DialogResult.No)
                {
                    DialogResult = 0;
                }
                else if (dr == DialogResult.Cancel)
                {
                    DialogResult = 0;
                }
            }
        }
Beispiel #10
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            using (SA45Team07B_LibraryEntities context = new SA45Team07B_LibraryEntities())
            {
                string selectedRFID = dataGridViewBookList.CurrentRow.Cells["RFIDColumn"].Value.ToString();

                // tag can never be null since this button is disable when there is no selected row
                this.tagFound = (from x in context.RFIDs
                                 where x.RFID == selectedRFID
                                 select x).First();

                this.bookFound            = RFIDFound.Books;
                this.tagsOfBookFound      = BookFound.RFIDs.ToList();
                this.subjectOfBookFound   = BookFound.BookSubjects;
                this.publisherOfBookFound = BookFound.Publishers;
            }

            this.DialogResult = DialogResult.OK;
        }
        private void btnSubmit_Click(object sender, EventArgs e)
        {
            //Submission validation
            if (!this.ValidateChildren() || lbxRFID.Items.Count == 0)
            {
                MessageBox.Show("Not able to modify this book. Please refer to individual error message");
            }
            else
            {
                //trim the lbox into list<string> newRFID and add to this book

                List <string> newRFID = new List <string>();

                foreach (var item in lbxRFID.Items)
                {
                    newRFID.Add(item.ToString());
                }
                newRFID.RemoveRange(0, bookFound.RFIDs.Count());
                bookModified.AddRFID(newRFID);


                using (SA45Team07B_LibraryEntities context = new SA45Team07B_LibraryEntities())
                {
                    Book bookToBeModified = context.Books.Where(x => x.BookID == bookFound.BookID).First();
                    bookToBeModified.ISBN          = bookModified.ISBN;
                    bookToBeModified.BookTitle     = bookModified.BookTitle;
                    bookToBeModified.BookSubjects  = context.BookSubjects.Where(x => x.SubjectName == cbxSubjectName.Text).First();
                    bookToBeModified.CallNumber    = bookModified.CallNumber;
                    bookToBeModified.Author        = txtbAuthor.Text.Trim(); //Author not require validation
                    bookToBeModified.PublisherID   = context.Publishers.Where(x => x.PublisherName == cbxPublisher.Text).First().PublisherID.ToString();
                    bookToBeModified.Price         = bookModified.Price;
                    bookToBeModified.Edition       = bookModified.Edition;
                    bookToBeModified.PublishedYear = bookModified.PublishedYear;

                    bookToBeModified.RFIDs = bookModified.RFIDs;

                    bookToBeModified.TotalCopy = (Int16)bookToBeModified.RFIDs.Count();
                    context.SaveChanges();
                    MessageBox.Show("Saved");
                    Close();
                }
            }
        }
 private void DisplayTextboxData()
 {
     using (SA45Team07B_LibraryEntities context = new SA45Team07B_LibraryEntities())
     {
         if (memberFound != null)
         {
             txtbMemberID.Text        = memberFound.MemberID.ToString();
             txtbMemberName.Text      = memberFound.MemberName;
             txtbSchoolID.Text        = memberFound.SchoolID;
             txtbFacultyName.Text     = facultyOfMemberFound.FacultyName;
             txtbEmail.Text           = memberFound.Email.ToString();
             txtbMemberType.Text      = memberTypeOfMemberFound.CategoryName;
             txtbLoanEntitlement.Text = memberTypeOfMemberFound.LoanEntitlement.ToString();
             txtbLoanPeriod.Text      = memberTypeOfMemberFound.LoanPeriod.ToString();
             txtbFinePerDay.Text      = memberTypeOfMemberFound.FinePerDay.ToString();
             txtbContactNumber.Text   = memberFound.ContactNumber.ToString();
         }
     }
 }
Beispiel #13
0
        //Add for Add Member
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            SA45Team07B_LibraryEntities context2 = new SA45Team07B_LibraryEntities();

            Member newMember = new Member();

            newMember.SchoolID   = maskedTextBoxSchoolID.Text.ToUpper();
            newMember.MemberName = textBoxMemberName.Text.Trim();

            MemberCategories cat = new MemberCategories();

            cat = context2.MemberCategories.Where(x => x.CategoryName == comboBoxMemberType.SelectedItem.ToString()).FirstOrDefault();
            newMember.MemberCategories = cat;

            Faculty fac = new Faculty();

            fac = context2.Faculties.Where(x => x.FacultyName == comboBoxFacultyName.SelectedItem.ToString()).FirstOrDefault();
            newMember.Faculties = fac;

            newMember.ContactNumber = textBoxContactNumber.Text.Trim();
            newMember.Email         = textBoxEmail.Text.ToLower().Trim();
            newMember.Discontinued  = "N";
            newMember.LoanedQty     = 0;

            DialogResult dr = MessageBox.Show("Confirm add new member?", "Confirmation", MessageBoxButtons.YesNoCancel);

            if (dr == DialogResult.Yes)
            {
                context2.Members.Add(newMember);
                context2.SaveChanges();
                MessageBox.Show(string.Format("Successfully added <<{0}>>.", newMember.MemberName));
                Close();
            }
            else if (dr == DialogResult.No)
            {
                DialogResult = 0;
            }
            else if (dr == DialogResult.Cancel)
            {
                DialogResult = 0;
            }
        }
Beispiel #14
0
        public static void MakeRFIDAdjusment(string RFID, bool discontinued, string remarks)
        {
            SA45Team07B_LibraryEntities context = new SA45Team07B_LibraryEntities();

            RFIDTag tag = context.RFIDs.Where(x => x.RFID == RFID).First();

            tag.Discontinued = discontinued ? "y" : "n";

            StockAdjustment adj = new StockAdjustment
            {
                RFID         = RFID,
                DateAdjusted = DateTime.Now,
                QtyAdjusted  = discontinued ? (short)-1 : (short)1,
                Remarks      = remarks
            };

            context.StockAdjustments.Add(adj);

            context.SaveChanges();
        }
        private void btnFindBk_Click(object sender, EventArgs e)
        {
            using (BookSearchForm popsearch = new BookSearchForm())
            {
                if (popsearch.ShowDialog() == DialogResult.OK)
                {
                    bookFound     = popsearch.BookFound;
                    txtbBkId.Text = bookFound.BookID.ToString();
                    mtbISBN.Text  = bookFound.ISBN.ToString();

                    txtbBkTitle.Text = bookFound.BookTitle.ToString();
                    txtbAuthor.Text  = bookFound.Author.ToString();

                    toolStripStatusLabel1.Text = string.Format("<<{0}>>", bookFound.BookTitle.ToString());

                    using (SA45Team07B_LibraryEntities context = new SA45Team07B_LibraryEntities())
                    {
                        cbxPublisher.DataSource     = context.Publishers.Select(x => x.PublisherName).ToList();
                        cbxPublisher.SelectedItem   = context.Publishers.Where(x => x.PublisherID == bookFound.PublisherID).First().PublisherName.ToString();
                        cbxSubjectName.DataSource   = context.BookSubjects.Select(x => x.SubjectName).ToList();
                        cbxSubjectName.SelectedItem = context.BookSubjects.Where(x => x.SubjectCode == bookFound.SubjectCode).First().SubjectName.ToString();
                    }
                    txtbCallNum.Text = bookFound.CallNumber.ToString();
                    txtbPrice.Text   = bookFound.Price.ToString();
                    if (bookFound.Edition != null)
                    {
                        txtbEd.Text = bookFound.Edition.ToString();
                    }
                    if (bookFound.PublishedYear != null)
                    {
                        mtbYear.Text = bookFound.PublishedYear.ToString();
                    }
                    bookFound.RFIDs = popsearch.RFIDsOfBookFound;
                    foreach (RFIDTag rfid in bookFound.RFIDs)
                    {
                        lbxRFID.Items.Add(rfid.RFID.ToString().ToUpper());
                    }
                }
            }
            bookModified = new SA45Team07B.Book();
        }
Beispiel #16
0
        /// <summary>
        /// Apply criteria search and display the value to datagridview.
        /// </summary>
        private void SearchAndDisplayMember()
        {
            using (SA45Team07B_LibraryEntities context = new SA45Team07B_LibraryEntities())
            {
                List <Member> searchResult = new List <Member>();

                // Start with a list of all member
                searchResult = context.Members.ToList();

                // Result is refined after calling CriteriaSearch
                searchResult = CriteriaSeach(searchResult, txtbMemberName, "MemberName");
                searchResult = CriteriaSeach(searchResult, txtbSchoolID, "SchoolID");
                searchResult = CriteriaSeach(searchResult, txtbEmail, "Email");

                // Select desired columns
                var displayList = from m in searchResult
                                  select new { m.MemberID, m.MemberName, m.MemberType, m.FacultyCode, m.SchoolID, m.ContactNumber, m.Email, m.LoanedQty };

                // Bind datasource to displayList
                dataGridViewMemberList.DataSource = displayList.ToList();
            }
        }
Beispiel #17
0
 public bool CallNumValidation(Control txtb, ErrorProvider ep)
 {
     using (SA45Team07B_LibraryEntities context = new SA45Team07B_LibraryEntities())
     {
         //check for existing call number
         if (context.Books.Where(x => x.CallNumber == txtb.Text.Trim()).FirstOrDefault() != null)
         {
             ep.SetError(txtb, "Book with the same Call Number already exists");
             return(false);
         }
         else if (txtb.Text.Trim().Length == 0)
         {
             ep.SetError(txtb, "Please enter a call number");
             return(false);
         }
         else
         {
             ep.SetError(txtb, "");
             return(true);
         }
     }
 }
Beispiel #18
0
        private void MemberPopUpSearch_Load(object sender, EventArgs e)
        {
            // Lazy loading - load the first 25 rows first
            using (SA45Team07B_LibraryEntities context = new SA45Team07B_LibraryEntities())
            {
                var displayList = (from m in context.Members
                                   select new
                {
                    m.MemberID,
                    m.MemberName,
                    m.MemberType,
                    m.FacultyCode,
                    m.SchoolID,
                    m.ContactNumber,
                    m.Email,
                    m.LoanedQty
                }).Take(25).ToList();

                dataGridViewMemberList.DataSource = displayList.ToList();

                isFirstLoad = true;
            }
        }
Beispiel #19
0
 public bool ISBNValidation(Control mtb, ErrorProvider ep)
 {
     using (SA45Team07B_LibraryEntities context = new SA45Team07B_LibraryEntities())
     {
         //validate length of isbn
         if (mtb.Text.Trim().Length != 13)
         {
             ep.SetError(mtb, "Please enter a valid ISBN consists of 13 digits");
             return(false);
         }
         //validate if an existing isbn
         else if (context.Books.Where(x => x.ISBN == mtb.Text.Trim()).FirstOrDefault() != null)
         {
             ep.SetError(mtb, "ISBN already exists");
             return(false);
         }
         else
         {
             ep.SetError(mtb, "");
             return(true);
         }
     }
 }
Beispiel #20
0
        private void textBoxPublisherID_Validating(object sender, CancelEventArgs e)
        {
            SA45Team07B_LibraryEntities context1 = new SA45Team07B_LibraryEntities();
            var matchingRecord = context1.Publishers.Where(x => x.PublisherID == textBoxPublisherID.Text.Trim()).FirstOrDefault();

            if (matchingRecord != null)
            {
                errorProviderPublisherID.SetError(textBoxPublisherID, "Member already exists.");
            }
            else if (textBoxPublisherID.Text.Trim() == "")
            {
                errorProviderPublisherID.SetError(textBoxPublisherID, "Please enter Publisher ID. Field cannot be empty. Ignore if not adding new.");
            }
            else if (textBoxPublisherID.Text.Length > 25)
            {
                errorProviderPublisherID.SetError(textBoxPublisherID, "Too many characters. Maximum number of characters = 25.");
            }

            else
            {
                errorProviderPublisherID.SetError(textBoxPublisherID, "");
            }
        }
Beispiel #21
0
        private void textBoxEmail_Validating(object sender, CancelEventArgs e)
        {
            SA45Team07B_LibraryEntities context2 = new SA45Team07B_LibraryEntities();
            var matchingRecord = context2.Members.Where(x => x.Email == textBoxEmail.Text.Trim()).FirstOrDefault();

            if (matchingRecord != null)
            {
                errorProviderEmail.SetError(textBoxEmail, "Email already exists.");
            }
            else if (textBoxEmail.Text.Trim() == "")
            {
                errorProviderEmail.SetError(textBoxEmail, "Please enter email. Field cannot be empty.");
            }

            else if (textBoxEmail.Text.Length > 50)
            {
                errorProviderEmail.SetError(textBoxEmail, "Too many characters. Maximum number of characters = 50.");
            }
            else
            {
                errorProviderEmail.SetError(textBoxEmail, "");
            }
        }
Beispiel #22
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            long memberID;

            using (SA45Team07B_LibraryEntities context = new SA45Team07B_LibraryEntities())
            {
                if (Int64.TryParse(dataGridViewMemberList.CurrentRow.Cells["MemberIDColumn"].Value.ToString(), out memberID))
                {
                    this.memberFound = (from m in context.Members
                                        where m.MemberID == memberID
                                        select m).First();

                    this.facultyofMemberFound    = memberFound.Faculties;
                    this.memberTypeOfMemberFound = memberFound.MemberCategories;
                }
                else
                {
                    // should no happen
                    throw new Exception("No member is selected");
                }
            }

            this.DialogResult = DialogResult.OK;
        }
Beispiel #23
0
        //Save Changes for Modify Publisher
        private void buttonSaveChanges_Click(object sender, EventArgs e)
        {
            SA45Team07B_LibraryEntities context2 = new SA45Team07B_LibraryEntities();
            Publisher pb = new Publisher();

            pb = context2.Publishers.Where(x => x.PublisherID == textBoxModPublisherID.Text).First();
            pb.PublisherName = textBoxModPublisherName.Text.Trim();
            if (comboBoxModCountry.SelectedItem != null && (comboBoxModCountry.SelectedItem.ToString() != "Not Applicable"))
            {
                pb.Country = comboBoxModCountry.SelectedItem.ToString();
            }
            else
            {
                pb.Country = "";
            }

            DialogResult dr = MessageBox.Show("Confirm update?", "Confirmation", MessageBoxButtons.YesNoCancel);

            if (dr == DialogResult.Yes)
            {
                context2.SaveChanges();
                MessageBox.Show(string.Format("Successfully updated <<{0}>>.", pb.PublisherName));
                toolStripStatusLabel1.Text = "Publisher list updated.";
                SA45Team07B_LibraryEntities context = new SA45Team07B_LibraryEntities();
                var query = from x in context.Publishers select new { x.PublisherID, x.PublisherName, x.Country };
                dataGridViewPublishers.DataSource = query.ToList();
            }
            else if (dr == DialogResult.No)
            {
                DialogResult = 0;
            }
            else if (dr == DialogResult.Cancel)
            {
                DialogResult = 0;
            }
        }
Beispiel #24
0
        /// <summary>
        /// showAll will display all records. If showAll is false, display only the first 25 records.
        /// </summary>
        /// <param name="showAll"></param>
        private void SearchAndDisplayBook(bool showAll = true)
        {
            using (SA45Team07B_LibraryEntities context = new SA45Team07B_LibraryEntities())
            {
                List <RFIDTag> RFIDList = new List <RFIDTag>();
                RFIDList = (from x in context.RFIDs
                            select x).ToList();

                if (rbtnAll.Checked == true)
                {
                    RFIDList = (from x in RFIDList
                                select x).ToList();
                }
                else if (rbtnAvailable.Checked == true)
                {
                    RFIDList = (from x in RFIDList
                                where (x.Availability == "y" && x.Discontinued == "n")
                                select x).ToList();
                }
                else if (rbtnOnLoan.Checked == true)
                {
                    RFIDList = (from x in RFIDList
                                where (x.Availability == "n" && x.Discontinued == "n")
                                select x).ToList();
                }
                else if (rbtnDiscontinued.Checked == true)
                {
                    RFIDList = (from x in RFIDList
                                where (x.Discontinued == "y")
                                select x).ToList();
                }

                List <Book> searchResult = new List <Book>();
                searchResult = (from x in RFIDList
                                select x.Books).ToList();

                searchResult = CriteriaSeach(searchResult, txtbBookTitle, "BookTitle");
                searchResult = CriteriaSeach(searchResult, txtbISBN, "ISBN");

                // cannot apply CriteriaSeach for Author as it is allowed null
                if (txtbAuthor.Text != string.Empty)
                {
                    List <Book> searchResultByAuthor = (from x in context.Books
                                                        where x.Author.ToLower().Contains(txtbAuthor.Text.ToString().ToLower().Trim())
                                                        select x).ToList();

                    searchResult = searchResult.Intersect(searchResultByAuthor).ToList();
                }

                if (cbSubject.Text != "")
                {
                    searchResult = (from x in searchResult
                                    where x.BookSubjects.SubjectName == cbSubject.Text
                                    select x).ToList();
                }

                if (showAll)
                {
                    var displayList = from x in RFIDList
                                      where searchResult.Contains(x.Books)
                                      orderby x.Books.BookID, x.Availability descending
                        select new
                    {
                        x.Books.BookID,
                        x.Books.BookTitle,
                        x.Availability,
                        x.Books.Edition,
                        x.Books.Author,
                        x.Books.ISBN,
                        x.Books.CallNumber,
                        x.RFID,
                        x.Books.BookSubjects.SubjectName,
                        x.Books.Publishers.PublisherName,
                        x.Books.PublishedYear,
                        x.Books.Price,
                        x.Discontinued
                    };

                    dataGridViewBookList.DataSource = displayList.ToList();
                }
                else
                {
                    var displayList = (from x in RFIDList
                                       where searchResult.Contains(x.Books)
                                       orderby x.Books.BookID, x.Availability descending
                                       select new
                    {
                        x.Books.BookID,
                        x.Books.BookTitle,
                        x.Availability,
                        x.Books.Edition,
                        x.Books.Author,
                        x.Books.ISBN,
                        x.Books.CallNumber,
                        x.RFID,
                        x.Books.BookSubjects.SubjectName,
                        x.Books.Publishers.PublisherName,
                        x.Books.PublishedYear,
                        x.Books.Price,
                        x.Discontinued
                    }).Take(25);

                    dataGridViewBookList.DataSource = displayList.ToList();
                }
            }
        }
        private void DisplayDGVData()
        {
            using (SA45Team07B_LibraryEntities context = new SA45Team07B_LibraryEntities())
            {
                List <TransactionInformationToDisplay> displayList = new List <TransactionInformationToDisplay>();

                if (memberFound != null)
                {
                    if (rbtnOnLoan.Checked == true)
                    {
                        onLoanTransactionRecords = (from x in context.IssueTrans
                                                    where x.MemberID == memberFound.MemberID && x.Status == "out"
                                                    select x).ToList();

                        displayList = (from x in onLoanTransactionRecords
                                       orderby x.DateIssued ascending
                                       select new TransactionInformationToDisplay
                        {
                            DateIssued = x.DateIssued,
                            DateDue = x.DateDue,
                            DateActualReturned = x.DateActualReturned,
                            BookID = x.RFIDs.BookID,
                            BookTitle = x.RFIDs.Books.BookTitle,
                            RFID = x.RFIDs.RFID,
                            TransactionID = x.TransactionID,
                            Status = x.Status,
                            Remarks = x.Remarks
                        }).ToList();

                        dataGridViewTransactionRecords.DataSource = displayList;
                    }
                    else if (rbtnReturned.Checked == true)
                    {
                        returnedTransactionRecords = (from x in context.IssueTrans
                                                      where x.MemberID == memberFound.MemberID && x.Status == "in"
                                                      select x).ToList();


                        displayList = (from x in returnedTransactionRecords
                                       orderby x.DateIssued ascending
                                       select new TransactionInformationToDisplay
                        {
                            DateIssued = x.DateIssued,
                            DateDue = x.DateDue,
                            DateActualReturned = x.DateActualReturned,
                            BookID = x.RFIDs.BookID,
                            BookTitle = x.RFIDs.Books.BookTitle,
                            RFID = x.RFIDs.RFID,
                            TransactionID = x.TransactionID,
                            Status = x.Status,
                            Remarks = x.Remarks
                        }).ToList();

                        dataGridViewTransactionRecords.DataSource = displayList;

                        txtbLoanedQty.Text  = string.Empty;
                        txtbOverdueQty.Text = string.Empty;
                        txtbUnpaidFine.Text = string.Empty;
                    }


                    CalculateFine();
                }
                else
                {
                    displayList.Clear();
                    dataGridViewTransactionRecords.DataSource = displayList;
                }
            }
        }