public Window_Popup_ReturnBook(int _book_id)
        {
            InitializeComponent();
            this.FormBorderStyle = FormBorderStyle.FixedSingle; //make unresizable

            transaction = EntityBroker.getLastTransationByBookID(_book_id);
            book        = EntityBroker.getBookByBookID(_book_id);
            member      = EntityBroker.getMemberByMemberID(transaction.MemberID);
            bookmodel   = EntityBroker.getBookModelByID(book.BookModelID);

            calculateCharge();

            lblBookTitle.Text = bookmodel.BookTitle;

            lblBookIDValue.Text     = book.BookID.ToString();
            lblMemberNameValue.Text = member.MemberName;
            lblMemberIDValue.Text   = member.MemberID.ToString();
            lblRentDateValue.Text   = transaction.LendDate.ToString("dd MM, yyyy");
            lblChargeValue.Text     = charge.ToString();
        }
        private void dgvListOfCopies_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            DataGridView dgv = sender as DataGridView;

            if (dgv == null)
            {
                return;
            }

            if (dgv.CurrentRow.Selected)
            {
                int _book_id = Convert.ToInt32(dgv.SelectedRows[0].Cells["Book ID"].Value);

                Book _book = EntityBroker.getBookByBookID(_book_id);

                if (_book.BookStatus == 1)
                {
                    try
                    {
                        Window_Popup_LendBook w = new Window_Popup_LendBook(_book_id);
                        w.setMainWindowRefrence(MainWindowObject);
                        w.ShowDialog();
                        winObj.Close();
                    }
                    catch {
                        MessageBox.Show("Please close the window manually");
                    }
                }
                else
                {
                    Window_Popup_ReturnBook w = new Window_Popup_ReturnBook(_book_id);
                    w.setMainWindowRefrence(MainWindowObject);
                    w.ShowDialog();
                    winObj.Close();
                }
            }
        }
        private void btnSearchByBookID_Click(object sender, EventArgs e)
        {
            int _book_id = 0;

            try
            {
                _book_id = Convert.ToInt32(txtSearchByBookID.Text);
            }
            catch {
                MessageBox.Show("Book ID you entered is not valid type.");
                return;
            }

            Book _book = new Book();

            _book = EntityBroker.getBookByBookID(_book_id);

            if (_book == null)
            {
                MessageBox.Show("Book ID you entered is not in the library.");
                return;
            }

            if (_book.BookStatus == 1)
            {
                Window_Popup_LendBook w = new Window_Popup_LendBook(_book_id);
                w.setMainWindowRefrence(MainWindowObject);
                w.ShowDialog();
            }
            else if (_book.BookStatus == 0)
            {
                Window_Popup_ReturnBook w = new Window_Popup_ReturnBook(_book_id);
                w.setMainWindowRefrence(MainWindowObject);
                w.ShowDialog();
            }
        }
        private void btnRent_Click(object sender, EventArgs e)
        {
            //#TODO::ExceptionHandle
            LibraryDBEntities entity = new LibraryDBEntities();
            LibTran           t      = new LibTran();

            int member_id = 0;
            int book_id   = 0;

            try
            {
                book_id = Convert.ToInt32(txtBookID.Text);
            }
            catch
            {
                MessageBox.Show("BookID you entered is not valid type.");
                return;
            }

            try
            {
                member_id = Convert.ToInt32(txtMemberID.Text);
            }
            catch
            {
                MessageBox.Show("MemberID you entered is not valid type.");
                return;
            }

            Book book = EntityBroker.getBookByBookID(book_id);

            if (book == null)
            {
                MessageBox.Show("BookID doesn't exit.");
                return;
            }
            if (book.BookStatus != 1)
            {
                MessageBox.Show("Book is not avaiable to rent.");
                return;
            }

            Member member;

            member = EntityBroker.getMemberByMemberID(member_id);
            if (member == null)
            {
                MessageBox.Show("MemberID doesn't exit.");
                return;
            }

            t.MemberID = member_id;
            t.BookID   = book_id;
            t.LendDate = DateTime.Now;

            entity.AddToLibTrans(t);
            try
            {
                entity.SaveChanges();
            }catch {
                MessageBox.Show("User not exit");
            }
            Book b = entity.Books.Where(x => x.BookID == t.BookID).SingleOrDefault();

            b.BookStatus = 0;

            int i = entity.SaveChanges();

            if (i == 1)
            {
                try
                {
                    ucListBooks booklist = new ucListBooks();
                    booklist.setMainWindowRefrence(MainWindowObject);
                    MainWindowObject.RequestContentChange(booklist);
                }
                catch {
                    MessageBox.Show("Exception. Please close the window manually. Sorry for inconvenience");
                }
            }
            this.Close();
        }