Пример #1
0
        private void BtnEdit_Click(object sender, EventArgs e)
        {
            if (dgvBookList.Rows.Count > 0)
            {
                if (dgvBookList.SelectedRows.Count == 1)
                {
                    int selectIndex = dgvBookList.CurrentRow.Index;
                    var bookID      = dgvBookList.Rows[selectIndex].Cells[0].Value;

                    var book = BooksHelper.GetBookByID(Convert.ToInt32(bookID));

                    cmbDepartment.SelectedItem = DepartmentsHelper.GetByNameFromID(book.DepartmentID);
                    cmbCategory.SelectedItem   = BookCategoriesHelper.GetByNameFromID(book.BookCategoryID);
                    txtBookName.Text           = book.BookName;
                    txtTitle.Text    = book.Title;
                    txtAuthor.Text   = book.Author;
                    txtEdition.Text  = book.Edition;
                    txtEdition.Text  = string.Empty;
                    dtpRegDate.Value = book.DateOfRegister;
                    txtPrice.Text    = book.Price.ToString();

                    DisableComponent();
                }
            }
        }
Пример #2
0
        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();
        }
Пример #3
0
        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();
        }
Пример #4
0
        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);
            }
        }
Пример #5
0
        private void BtnSearchBook_Click(object sender, EventArgs e)
        {
            ep.Clear();
            if (txtBookID.Text.Trim().Length == 0)
            {
                ep.SetError(txtBookID, "Book ID giriniz!");
                txtBookID.Focus();
                return;
            }

            try
            {
                var b = BooksHelper.GetBookByID(Convert.ToInt32(txtBookID.Text));
                if (b.NoOfCopies > 0)
                {
                    FillGridBook(b);
                    btnSearchBook.Enabled = false;
                    txtBookID.Enabled     = false;
                }
                else
                {
                    MessageBox.Show("Bu ID'ye ait kitap stokta kalmadı.", "Library Management System", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Bu ID'ye ait kitap bulunamadı", "Library Management System", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            if (btnSearchBook.Enabled == false || btnSearchStudent.Enabled == false)
            {
                btnCancel.Enabled = true;
            }
            if (btnSearchBook.Enabled == false && btnSearchStudent.Enabled == false)
            {
                btnAdd.Enabled = true;
            }
        }