private void AddBorrower()
        {
            try
            {
                if (!(tb_BFName.Text == ""))
                {
                    using (var ctx = new RRSContext())
                    {
                        int tempId = Int32.Parse(dataGridView_Borrow.SelectedRows[0].Cells[0].Value.ToString());


                        var categoryid = (from cats in ctx.ResearchBooks
                                          where cats.ThesisTitleId.Equals(tempId)
                                          select cats.NumberOfCopies).SingleOrDefault();

                        var bookBorrowed = categoryid - 1;

                        var rb = new ResearchBook()
                        {
                            ThesisTitleId = tempId, NumberOfCopies = bookBorrowed
                        };
                        ctx.ResearchBooks.Attach(rb);
                        ctx.Entry(rb).Property(x => x.NumberOfCopies).IsModified = true;
                        ctx.SaveChanges();


                        var borrow = new Borrow
                        {
                            BFullName        = tb_BFName.Text,
                            BContactNumber   = tb_BContactNumber.Text,
                            BookBorrowedDate = DateTime.Now,
                            DateWillRetrun   = dateTimePicker_Return.Value.Date,
                            ThesisTitleId    = tempId,
                            NoOfBookBorrowed = 1,
                        };
                        ctx.Borrows.AddOrUpdate(borrow);
                        ctx.SaveChanges();

                        tb_BFName.Clear();
                        tb_BContactNumber.Clear();
                        dateTimePicker_Return.Value = DateTime.Now;

                        LoadBorrower();

                        ListofBorrowedBooks listofBorrowedBooks = new ListofBorrowedBooks();
                        listofBorrowedBooks.ShowDialog();
                    }
                }
                else
                {
                    MessageBox.Show("Add a borrower name");
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
        private void SaveAll()
        {
            int tempId = Int32.Parse(dgvr.Cells[0].Value.ToString());

            using (RRSContext ctx = new RRSContext())
            {
                //if (tb_ClassificationName.Text == "")
                //{

                //var classfication = new Classifacation()
                //{
                //    ClassificationName = tb_ClassificationName.Text,
                //    CourseId = tempId,
                //};

                //ctx.Classifacations.Add(classfication);
                //ctx.SaveChanges();
                //tb_ClassificationName.Clear();
                //ClassificationOfThesis_Load(null, null);
                //}


                if (dataGridView1.SelectedRows.Count > 0)
                {
                    foreach (var item in classifacationBindingSource.List)
                    {
                        var classifacation = (Classifacation)item;
                        if (classifacation.ClassificationId <= 0)
                        {
                            ctx.Classifacations.Add(classifacation);
                        }
                        else
                        {
                            ctx.Classifacations.Attach(classifacation);
                            ctx.Entry(classifacation).State = System.Data.Entity.EntityState.Modified;
                        }
                    }

                    ctx.SaveChanges();
                    MessageBox.Show(this, "Update Successfull");
                }
            }
        }