private void btnSelectIssueBook_Click(object sender, EventArgs e) { dgvIssueBookList.Enabled = false; int selectIndex = dgvIssueBookList.CurrentRow.Index; var issueBookID = dgvIssueBookList.Rows[selectIndex].Cells[0].Value; var ib = IssueBooksHelper.GetIssueBookByID(Convert.ToInt32(issueBookID)); if (DateTime.Now > ib.DateOfReturn) { int day = Convert.ToInt32((DateTime.Now - ib.DateOfReturn).TotalDays); txtTotalDay.Text = day.ToString(); int fine = Convert.ToInt32(txtFinePerDay.Text); int totalAmount = day * fine; txtTotalAmount.Text = totalAmount.ToString(); gbFine.Enabled = true; } btnSearchStudent.Enabled = false; btnSelectIssueBook.Enabled = false; btnReturnBook.Enabled = true; btnCancel.Enabled = true; dgvIssueBookList.Enabled = false; }
private void FillGridBook(int studentID) { dgvIssueBookList.Rows.Clear(); foreach (var issueBook in IssueBooksHelper.GetIssueBookListFromStudentID(studentID)) { int row = dgvIssueBookList.Rows.Add(); dgvIssueBookList.Rows[row].Cells[0].Value = issueBook.IssueID; dgvIssueBookList.Rows[row].Cells[1].Value = issueBook.BookID; dgvIssueBookList.Rows[row].Cells[2].Value = BooksHelper.GetBookNameByID(issueBook.BookID); dgvIssueBookList.Rows[row].Cells[3].Value = StaffsHelper.GetByNameFromID(issueBook.StaffID); dgvIssueBookList.Rows[row].Cells[4].Value = issueBook.NoOfCopies; dgvIssueBookList.Rows[row].Cells[5].Value = issueBook.DateOfIssue.ToString("dd MMMM yyyy"); dgvIssueBookList.Rows[row].Cells[6].Value = issueBook.DateOfReturn.ToString("dd MMMM yyyy"); row++; } }
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); } }