private void borrowBtn_Click(object sender, EventArgs e)
        {
            LibraryDataContext dbContext = new LibraryDataContext();
            String             borrowStr = borrowTxt.Text;

            Book book = null;

            if (borrowCombo.SelectedItem.ToString().Equals("Name"))
            {
                book = dbContext.Books.SingleOrDefault(x => x.B_NAME == borrowStr);
            }
            else if (borrowCombo.SelectedItem.ToString().Equals("Book ID"))
            {
                book = dbContext.Books.SingleOrDefault(x => x.B_ID == borrowStr);
            }
            Borrow borrow = new Borrow();

            borrow.ID     = ID;
            borrow.B_ID   = book.B_ID;
            borrow.B_NAME = book.B_NAME;
            borrow.TOPIC  = book.TOPIC;
            dbContext.Borrows.InsertOnSubmit(borrow);
            dbContext.SubmitChanges();
            MessageBox.Show("Book borrowed!");
            table.DataSource = dbContext.Books;
        }
        private void button1_Click(object sender, EventArgs e)
        {
            LibraryDataContext dbContext = new LibraryDataContext();

            var result = dbContext.Borrows.Where(x => x.ID == ID);

            table.DataSource = result;
        }
        public AdminForm()
        {
            InitializeComponent();

            LibraryDataContext dbContext = new LibraryDataContext();

            table.DataSource = dbContext.Books;
        }
        public AdminForm(bool loggedIn, String ID)
        {
            InitializeComponent();
            this.loggedIn        = loggedIn;
            this.ID              = ID;
            this.adminIDTxt.Text = ID;
            LibraryDataContext dbContext = new LibraryDataContext();

            table.DataSource = dbContext.Books;
        }
        private void removeBtn_Click(object sender, EventArgs e)
        {
            String bookID = bookIDTxt.Text;

            LibraryDataContext dbContext = new LibraryDataContext();
            Book book = dbContext.Books.SingleOrDefault(x => x.B_ID == bookID);

            dbContext.Books.DeleteOnSubmit(book);
            dbContext.SubmitChanges();
            MessageBox.Show("Book Removed!");
            table.DataSource = dbContext.Books;
        }
        private void updateBtn_Click(object sender, EventArgs e)
        {
            String bookID = bookIDTxt.Text;

            LibraryDataContext dbContext = new LibraryDataContext();
            Book book = dbContext.Books.SingleOrDefault(x => x.B_ID == bookID);

            book.B_NAME = bookNameTxt.Text;
            book.TOPIC  = bookTopicTxt.Text;
            book.T_QTY  = Int32.Parse(tQtyTxt.Text);
            book.A_QTY  = Int32.Parse(aQtyTxt.Text);
            dbContext.SubmitChanges();
            MessageBox.Show("Information Updated!");
            table.DataSource = dbContext.Books;
        }
        private void addBtn_Click(object sender, EventArgs e)
        {
            LibraryDataContext dbContext = new LibraryDataContext();
            Book book = new Book();

            book.B_ID   = bookIDTxt.Text;
            book.B_NAME = bookNameTxt.Text;
            book.TOPIC  = bookTopicTxt.Text;
            book.T_QTY  = Int32.Parse(tQtyTxt.Text);
            book.A_QTY  = Int32.Parse(aQtyTxt.Text);
            dbContext.Books.InsertOnSubmit(book);
            dbContext.SubmitChanges();
            MessageBox.Show("Book Added!");
            table.DataSource = dbContext.Books;
        }
        private void registerBtn_Click(object sender, EventArgs e)
        {
            Credential cred = new Credential();

            cred.ID = idTxt.Text;
            String p1 = passTxt.Text;
            String p2 = passReTxt.Text;

            if (!p1.Equals(p2))
            {
                MessageBox.Show("Password do not match!");
                return;
            }
            cred.PASS = passTxt.Text;
            cred.ROLE = "STUDENT";
            LibraryDataContext dbContext = new LibraryDataContext();

            dbContext.Credentials.InsertOnSubmit(cred);
            dbContext.SubmitChanges();
            MessageBox.Show("Registration Successful!");
        }
        private void searchBtn_Click(object sender, EventArgs e)
        {
            LibraryDataContext dbContext = new LibraryDataContext();
            String             searchStr = searchTxt.Text;

            if (searchCombo.SelectedItem.ToString().Equals("Topic"))
            {
                var result = dbContext.Books.Where(x => x.TOPIC == searchStr);
                table.DataSource = result;
            }
            else if (searchCombo.SelectedItem.ToString().Equals("Name"))
            {
                var result = dbContext.Books.Where(x => x.B_NAME == searchStr);
                table.DataSource = result;
            }
            else if (searchCombo.SelectedItem.ToString().Equals("Book ID"))
            {
                var result = dbContext.Books.Where(x => x.B_ID == searchStr);
                table.DataSource = result;
            }
        }
        private void loginBtn_Click(object sender, EventArgs e)
        {
            String inpID = null, inpPass = null;

            inpID   = loginIDTxt.Text;
            inpPass = loginPassTxt.Text;

            LibraryDataContext dbContext = new LibraryDataContext();
            Credential         cred      = null;

            try
            {
                cred = dbContext.Credentials.SingleOrDefault(x => x.ID == inpID);
            }
            catch (Exception)
            {
                MessageBox.Show("Invalid Input!");
            }
            String role = cred.ROLE;

            if (cred.PASS.Equals(inpPass))
            {
                if (role.Equals("STUDENT"))
                {
                    this.Visible = false;
                    new StudentForm(true, inpID).ShowDialog();
                }
                else if (role.Equals("ADMIN"))
                {
                    this.Visible = false;
                    new AdminForm(true, inpID).ShowDialog();
                }
            }
            else
            {
                MessageBox.Show("Wrong Input!");
            }
        }