예제 #1
0
        private void btnReturnBook_Click(object sender, EventArgs e)
        {
            koneksiSql koneksi = new koneksiSql();
            buku       temp    = new buku();

            temp = koneksi.returnBuku(dgvBooks.SelectedCells[3].Value.ToString());
            string fine = lblFineAmount.Text.Substring(4, lblFineAmount.Text.Length - 4);
            bool   yes  = koneksi.finishLend(dgvBooks.SelectedCells[0].Value.ToString());

            if (fined && yes)
            {
                DialogNormal denda = new DialogNormal($"Returned", $"You have been Fined {fine}", 43, 85);
                denda.ShowDialog();
                koneksi.updateFine(Program.userSekarang.user, fine);
                koneksi.updateStock(temp.bookId, temp.stock, "add");
            }
            else
            {
                koneksi.updateFine(Program.userSekarang.user, fine);
                koneksi.updateStock(temp.bookId, temp.stock, "add");
            }
            isiDgv(Program.userSekarang.user);
        }
예제 #2
0
 private void btnLend_Click(object sender, EventArgs e)
 {
     if ((Convert.ToInt32(Program.userSekarang.fine) <= 0))
     {
         if ((Convert.ToInt32(dgvBooks.SelectedCells[5].Value) > 0))
         {
             Peminjaman lend   = new Peminjaman();
             Random     rand   = new Random();
             string     user   = Program.userSekarang.user,
                        idBuku = dgvBooks.SelectedCells[0].Value.ToString();
             bool success      = false;
             lend.lendId   = randomDigit();
             lend.username = user;
             lend.bookId   = idBuku;
             lend.addLendDate();
             lend.addDueDate();
             lend.convertToString();
             koneksiSql koneksi = new koneksiSql();
             do
             {
                 try
                 {
                     koneksi.makeLend(lend.lendId, lend.username, lend.bookId, lend.strLendDate, lend.strDueDate);
                     koneksi.updateStock(idBuku, dgvBooks.SelectedCells[5].Value.ToString(), "remove");
                     success = true;
                 }
                 catch
                 {
                     lend.lendId = randomDigit();
                 }
             } while (!success);
         }
         else
         {
             DialogNormal dialog = new DialogNormal("Notice", "The stock currently Empty", 70, 85);
             dialog.ShowDialog();
         }
     }
     else
     {
         DialogNormal dialog = new DialogNormal("Notice", "You have unpaid Fine \n Please pay your fine first!", 70, 65);
         dialog.ShowDialog();
     }
     isiDgv(txtSearch.Text);
 }