private void tb_CourseSearch_TextChanged(object sender, EventArgs e) { using (RRSContext ctx = new RRSContext()) { researchBookBindingSource.DataSource = ctx.ResearchBooks.Where(x => x.CourseNameRb.Contains(tb_CourseSearch.Text)).ToList(); } }
private void LoadThesis() { using (RRSContext ctx = new RRSContext()) { researchBookBindingSource.DataSource = ctx.ResearchBooks.ToList(); } }
private void ReturnABorrowedBook_Load(object sender, EventArgs e) { using (RRSContext ctx = new RRSContext()) { borrowBindingSource.DataSource = ctx.Borrows.ToList(); } }
private void LoadBorrower() { using (RRSContext ctx = new RRSContext()) { /* var query = from p1 in ctx.ResearchBooks * //from p2 in ctx.Borrows * * //select new { p1.Title, p2.BFullaName, p2.BContactNumber, p2.BookBorrowedDate, p2.BookReturnedDate }; * select new { p1.Title, p1.Borrower.BFullName, p1.Borrower.BookBorrowedDate, p1.Borrower.DateWillRetrun }; * //foreach (var item in query) * //{ * // dataGridView_Borrow.DataSource = query.ToList(); * //} * * * dataGridView_Borrow.DataSource = query.ToList(); * dataGridView_Borrow.Columns[0].HeaderCell.Value = "Title"; * //dataGridView_Borrow.Columns[1].HeaderCell.Value = "Published Year"; * //dataGridView_Borrow.Columns[2].HeaderCell.Value = "Course"; * * dataGridView_Borrow.Columns[1].HeaderCell.Value = "Borrower Name"; * dataGridView_Borrow.Columns[2].HeaderCell.Value = "Borrowed Date"; * dataGridView_Borrow.Columns[3].HeaderCell.Value = "Retrurn Date"; * ////dataGridView_Thesis.Columns[4].HeaderCell.Value = "Author Last Name"; * * * dataGridView_Borrow.BeginEdit(true); */ researchBookBindingSource.DataSource = ctx.ResearchBooks.ToList(); } }
private void LoadBorrowedBooks() { using (RRSContext ctx = new RRSContext()) { //borrowBindingSource.DataSource = ctx.Borrows.ToList(); dataGridView1.AutoGenerateColumns = true; dataGridView1.DataSource = null; dataGridView1.Columns.Clear(); dataGridView1.Rows.Clear(); var query = from p1 in ctx.Borrows join f1 in ctx.ResearchBooks on p1.BorrowerId equals f1.ThesisTitleId select new { p1.BFullName, p1.BContactNumber, p1.BookBorrowedDate, p1.DateWillRetrun, f1.Title, p1.NoOfBookBorrowed /*, f1.AuthorLName*/ }; dataGridView1.DataSource = query.ToList(); //dataGridView1.DataSource = query.ToList(); //dataGridView1.Columns[1].HeaderCell.Value = "Borrower"; //dataGridView1.Columns[2].HeaderCell.Value = "Contact No"; //dataGridView1.Columns[3].HeaderCell.Value = "Date Borrowed"; //dataGridView1.Columns[4].HeaderCell.Value = "Date will return"; //dataGridView1.Columns[5].HeaderCell.Value = "No of Copies Borrowed"; //dataGridView1.Columns[6].HeaderCell.Value = "Title"; ////dataGridView_Thesis.Columns[4].HeaderCell.Value = "Author Last Name"; } }
private void ValidateUser() { using (RRSContext ctx = new RRSContext()) { var user = ctx.UserAccounts.Where(u => u.Username.Equals(tb_Username.Text)).FirstOrDefault(); if (user != null) { if (user.UserPassword != tb_UserPassword.Text) { MessageBox.Show("Invalid Password."); } else if (user.IsActive == false) { MessageBox.Show("Your Account is suspended. Please contact the administraor"); } else if (user.UserRole == "Clerk") { LoginAsClerk = true; this.Close(); this.Dispose(); } else { this.Close(); this.Dispose(); } } else { MessageBox.Show("No (" + tb_Username.Text + ") user found"); } } }
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 textBox1_TextChanged(object sender, EventArgs e) { using (RRSContext ctx = new RRSContext()) { researchBookBindingSource.DataSource = ctx.ResearchBooks.Where(x => x.Title.Contains(textBox1.Text) || x.PublishedYear.Contains(textBox1.Text) || x.CourseNameRb.Contains(textBox1.Text) || x.Remarks.Contains(textBox1.Text)).ToList(); } }
private void ClassificationOfThesis_Load(object sender, EventArgs e) { using (RRSContext ctx = new RRSContext()) { int tempId = Int32.Parse(dgvr.Cells[0].Value.ToString()); classifacationBindingSource.DataSource = ctx.Classifacations.Where(x => x.CourseId == tempId).ToList(); } tb_Course.Text = dgvr.Cells[1].Value.ToString(); }
private void LoadCourse() { using (RRSContext ctx = new RRSContext()) { var course_List = ctx.Courses.Where(x => x.IsActive == true).ToList(); if (course_List.Count > 0) { cb_Course.DataSource = course_List; //cb_Course.Items.Add(cb_Course.DataSource = ctx.Courses.ToString()); cb_Course.DisplayMember = "CourseName"; cb_Course.ValueMember = "CourseId"; } } }
private void ViewBorrowBook_Load(object sender, EventArgs e) { tb_vTitle.Text = dgvr1.Cells[1].Value.ToString(); tb_vPublishYear.Text = dgvr1.Cells[2].Value.ToString(); tb_vRemarks.Text = dgvr1.Cells[3].Value.ToString(); tb_vCourse.Text = dgvr1.Cells[4].Value.ToString(); tb_vCataloging.Text = dgvr1.Cells[6].Value.ToString(); using (RRSContext ctx = new RRSContext()) { int tempId = Int32.Parse(dgvr1.Cells[0].Value.ToString()); authorBindingSource.DataSource = ctx.Authors.Where(x => x.ThesisTitleId == tempId).ToList(); } }
private void ViewBookInformation_Load(object sender, EventArgs e) { tb_vTitle.Text = dgvr.Cells[1].Value.ToString(); tb_vPublishYear.Text = dgvr.Cells[2].Value.ToString(); tb_vRemarks.Text = dgvr.Cells[3].Value.ToString(); tb_vCourse.Text = dgvr.Cells[4].Value.ToString(); tb_vCataloging.Text = dgvr.Cells[5].Value.ToString(); tb_vCategory.Text = dgvr.Cells[6].Value.ToString(); abstractName = dgvr.Cells[7].Value.ToString(); approvalSheetName = dgvr.Cells[8].Value.ToString(); using (RRSContext ctx = new RRSContext()) { int tempId = Int32.Parse(dgvr.Cells[0].Value.ToString()); authorBindingSource.DataSource = ctx.Authors.Where(x => x.ThesisTitleId == tempId).ToList(); } }
private void LoadSearch() { using (RRSContext ctx = new RRSContext()) { var query = from p1 in ctx.ResearchBooks join f1 in ctx.Authors on p1.ThesisTitleId equals f1.AuthorId select new { p1.Title, p1.PublishedYear, p1.CourseNameRb, p1.Remarks, f1.AuthorName /*, f1.AuthorLName*/ }; dataGridViewSearch.DataSource = query.ToList(); dataGridViewSearch.Columns[0].HeaderCell.Value = "Title"; dataGridViewSearch.Columns[1].HeaderCell.Value = "Published Year"; dataGridViewSearch.Columns[2].HeaderCell.Value = "Course"; dataGridViewSearch.Columns[3].HeaderCell.Value = "Remarks"; dataGridViewSearch.Columns[4].HeaderCell.Value = "Author Name"; } }
private void bt_Search_Click(object sender, EventArgs e) { using (RRSContext ctx = new RRSContext()) { //researchBookBindingSource.DataSource = ctx.ResearchBooks // .Where(x => x.Title.Contains(tb_Search.Text) || // x.PublishedYear.Contains(tb_Search.Text) || // x.CourseNameRb.Contains(tb_Search.Text) || // x.Remarks.Contains(tb_Search.Text)).ToList() // .Select(x => new // { // Title = x.Title, // Publis = x.PublishedYear, // Course = x.CourseNameRb // }).ToList(); researchBookBindingSource.DataSource = ctx.ResearchBooks.ToList(); } }
private void bt_AddAuthor_Click(object sender, EventArgs e) { if (dataGridView1.SelectedRows.Count > 0) { foreach (DataGridViewRow br in dataGridView1.SelectedRows) { using (RRSContext ctx = new RRSContext()) { Borrow usr = ctx.Borrows.Find(br.Cells["borrowerIdDataGridViewTextBoxColumn"].Value); ctx.Borrows.Remove(usr); ctx.SaveChanges(); MessageBox.Show("Return Succesfully"); ///// dataGridView1.DataSource = ctx.Borrows.ToList(); } } } }
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"); } } }