private void btnUpdate_Click(object sender, EventArgs e) { int selectIndex = dgvBookList.CurrentRow.Index; var bookID = dgvBookList.Rows[selectIndex].Cells[0].Value; var b = BooksHelper.GetBookByID(Convert.ToInt32(bookID)); b.NoOfCopies += Convert.ToInt32(txtNoOfCopies.Text); BooksHelper.Update(b); MessageBox.Show("Kitap Güncelleme Başarılı", "Library Management System", MessageBoxButtons.OK, MessageBoxIcon.Information); EnabledComponent(); ClearForm(); FillGrid(); }
private void btnReturnBook_Click(object sender, EventArgs e) { int selectIndex = dgvIssueBookList.CurrentRow.Index; var issueBookID = dgvIssueBookList.Rows[selectIndex].Cells[0].Value; var ib = IssueBooksHelper.GetIssueBookByID(Convert.ToInt32(issueBookID)); ib.Status = 0; IssueBooksHelper.Update(ib); if (DateTime.Now > ib.DateOfReturn) { gbFine.Enabled = true; Fines f = new Fines(); f.StudentID = ib.StudentID; f.BookID = ib.BookID; f.StaffID = _staffID; f.Date = DateTime.Now; f.FineAmount = Convert.ToInt32(txtTotalAmount.Text); f.RecivedAmount = 0; f.Status = 1; FinesHelper.Add(f); } ReturnBooks rb = new ReturnBooks(); rb.BookID = ib.BookID; rb.StudentID = ib.StudentID; rb.StaffID = _staffID; rb.IssueDate = ib.DateOfIssue; rb.ReturnDate = ib.DateOfReturn; rb.Date = DateTime.Now; ReturnBooksHelper.Add(rb); Books b = BooksHelper.GetBookByID(ib.BookID); b.NoOfCopies += 1; BooksHelper.Update(b); MessageBox.Show("Kitap iade başarılı!", "Library Management System", MessageBoxButtons.OK, MessageBoxIcon.Information); DisableComponent(); }
private void btnAddDgv_Click(object sender, EventArgs e) { if (btnSearchStudent.Enabled == false && btnSearchBook.Enabled == false) { if (FinesHelper.GetFineCount(Convert.ToInt32(txtStudentID.Text)) < 1) { if (!IssueBooksHelper.GetHaveBooks(Convert.ToInt32(txtStudentID.Text), Convert.ToInt32(txtBookID.Text))) { IssueBooks ib = new IssueBooks(); ib.StudentID = Convert.ToInt32(txtStudentID.Text); ib.BookID = Convert.ToInt32(txtBookID.Text); ib.StaffID = _staffID; ib.NoOfCopies = 1; ib.DateOfIssue = dtpIssueDate.Value; ib.DateOfReturn = dtpReturnDate.Value; ib.Status = 1; IssueBooksHelper.Add(ib); var b = BooksHelper.GetBookByID(Convert.ToInt32(txtBookID.Text)); b.NoOfCopies -= 1; BooksHelper.Update(b); MessageBox.Show("Kitap kiralama başarılı!", "Library Management System", MessageBoxButtons.OK, MessageBoxIcon.Information); EnableComponent(); } else { MessageBox.Show("Bir Öğrencinin Aynı Kitabı Birden Fazla Alma İhtimali Yoktur.", "Library Management System", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("Öğrencinin Birden Fazla Ödenmemiş Borcu Olduğundan Kitap Kiralama Olanağı Yoktur.", "Library Management System", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("Lütfen öğrenci ve kitap seçimini yapınız!", "Library Management System", MessageBoxButtons.OK, MessageBoxIcon.Error); } }