예제 #1
0
        private void btnPay_Click(object sender, EventArgs e)
        {
            string username = txtUsername.Text;

            if (Convert.ToInt32(txtFine.Text) > 0)
            {
                koneksi.UserPayFine(username);
                txtFine.Text = "0";
            }
            else
            {
                DialogNormal dialog = new DialogNormal("Error", "No Fine to Pay", 127, 85);
                dialog.ShowDialog();
            }
        }
예제 #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);
 }
예제 #3
0
        public bool removeQuery(string qCommand, string successMsg, int sucX, int sucY)
        {
            DialogYesNo yesno = new DialogYesNo();

            yesno.ShowDialog();
            if (yesno.getresult())
            {
                query = qCommand;
                SqlCommand command = new SqlCommand(query, sqlConn);
                sqlConn.Open();
                command.ExecuteNonQuery();
                DialogNormal dialog = new DialogNormal("Notice", successMsg, sucX, sucY);
                dialog.ShowDialog();
                sqlConn.Close();
                return(true);
            }
            return(false);
        }
예제 #4
0
 private bool executeSQL(string qCommand, string successMsg, string failMsg, int sucX, int sucY, int faiX, int faiY)
 {
     try
     {
         query = qCommand;
         SqlCommand command = new SqlCommand(query, sqlConn);
         sqlConn.Open();
         command.ExecuteNonQuery();
         DialogNormal dialog = new DialogNormal("Success", successMsg, sucX, sucY);
         dialog.ShowDialog();
         sqlConn.Close();
         return(true);
     }
     catch (Exception)
     {
         DialogNormal dialogErr = new DialogNormal("Error", failMsg, faiX, faiY);
         dialogErr.ShowDialog();
         return(false);
     }
 }
예제 #5
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);
        }