예제 #1
0
        private void btnPay_Click(object sender, EventArgs e)
        {
            int selectIndex = dgvFineList.CurrentRow.Index;
            var fineID      = dgvFineList.Rows[selectIndex].Cells[0].Value;

            var f = FinesHelper.GetFinesByID(Convert.ToInt32(fineID));

            ep.Clear();
            if (txtFinePay.Text.Trim().Length == 0)
            {
                ep.SetError(txtFinePay, "Fine boş bırakılamaz!");
                txtFinePay.Focus();
                return;
            }

            if (Convert.ToInt32(txtFinePay.Text) <= (f.FineAmount + f.RecivedAmount))
            {
                f.FineAmount    -= Convert.ToInt32(txtFinePay.Text);
                f.RecivedAmount += Convert.ToInt32(txtFinePay.Text);

                if (f.FineAmount == 0)
                {
                    f.Status = 0;
                }

                FinesHelper.Update(f);
                MessageBox.Show("Borç Güncelleme Başarılı.", "Library Management System", MessageBoxButtons.OK, MessageBoxIcon.Information);
                FillGridFines();
            }
            else
            {
                MessageBox.Show("Girdiğimiz borç miktarı, Bu ID'ye ait öğrencideki kalan borç miktarından fazladır.", "Library Management System", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
예제 #2
0
 private void FillGridFines()
 {
     dgvFineList.Rows.Clear();
     foreach (var fine in FinesHelper.GetActiveFinesList())
     {
         int row = dgvFineList.Rows.Add();
         dgvFineList.Rows[row].Cells[0].Value = fine.FineID;
         dgvFineList.Rows[row].Cells[1].Value = fine.StudentID;
         dgvFineList.Rows[row].Cells[2].Value = fine.BookID;
         dgvFineList.Rows[row].Cells[3].Value = BooksHelper.GetBookNameByID(fine.BookID);
         dgvFineList.Rows[row].Cells[4].Value = fine.Date.ToString("dd MMMM yyyy");
         dgvFineList.Rows[row].Cells[5].Value = fine.FineAmount;
         dgvFineList.Rows[row].Cells[6].Value = fine.RecivedAmount;
         row++;
     }
 }
예제 #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);
            }
        }