示例#1
0
        public OverdueBooks(DataSet dsOverdue)
        {
            InitializeComponent();

            ControlForm kontrol = new ControlForm();

            Panel[]           listPanel  = { pnlValue1, pnlValue2, pnlValue3, pnlValue4, pnlValue5 };
            PictureBox[]      listPbox   = { pictureBox1, pictureBox2, pictureBox3, pictureBox4, pictureBox5 };
            List <Peminjaman> listPinjam = new List <Peminjaman>();

            int counter = 0;

            for (int i = 0; i < dsOverdue.Tables["Lendings"].Rows.Count; i++)
            {
                Peminjaman temp = new Peminjaman();
                temp.username    = dsOverdue.Tables["Lendings"].Rows[i]["Username"].ToString();
                temp.bookId      = dsOverdue.Tables["Lendings"].Rows[i]["BookId"].ToString();
                temp.lendId      = dsOverdue.Tables["Lendings"].Rows[i]["LendId"].ToString();
                temp.strLendDate = dsOverdue.Tables["Lendings"].Rows[i]["LendDate"].ToString();
                temp.strDueDate  = dsOverdue.Tables["Lendings"].Rows[i]["DueDate"].ToString();
                temp.fineCount();
                string[] thumbnailList = dsOverdue.Tables["Lendings"].Rows[i]["PicturePath"].ToString().Split('|');
                //Done load data peminjaman//
                if (temp.fine > 0)
                {
                    kontrol.setFotoBuku(listPbox[counter % 5], thumbnailList[0]);
                    string fine = temp.fine.ToString();
                    listPanel[counter % 5].Controls.Add(new UcFineValue(fine));
                    listId.Add(temp.bookId);
                }
            }
        }
示例#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
        private bool checkOverdue()
        {
            if (Program.userSekarang.tipe == "Guest")
            {
                return(false);
            }
            bool overdue = false;

            koneksi = new koneksiSql();
            SqlConnection  conn = new SqlConnection(koneksi.getSqlConn());
            SqlCommand     cmd  = new SqlCommand($"SELECT * from Lendings INNER JOIN Booklist on Lendings.BookId = Booklist.BookID where Username = '******'", conn);
            SqlDataAdapter sda  = new SqlDataAdapter(cmd);

            sda.Fill(dsOverdue, "Lendings");
            try
            {
                for (int i = 0; i < dsOverdue.Tables["Lendings"].Rows.Count; i++)
                {
                    Peminjaman temp = new Peminjaman();
                    temp.username    = dsOverdue.Tables["Lendings"].Rows[i]["Username"].ToString();
                    temp.bookId      = dsOverdue.Tables["Lendings"].Rows[i]["BookId"].ToString();
                    temp.lendId      = dsOverdue.Tables["Lendings"].Rows[i]["LendId"].ToString();
                    temp.strLendDate = dsOverdue.Tables["Lendings"].Rows[i]["LendDate"].ToString();
                    temp.strDueDate  = dsOverdue.Tables["Lendings"].Rows[i]["DueDate"].ToString();
                    temp.fineCount();
                    if (temp.fine > 0)
                    {
                        overdue = true;
                        break;
                    }
                }
                conn.Close();
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
            }
            return(overdue);
        }
示例#4
0
        public Peminjaman returnLend(string username, string lendId)
        {
            Peminjaman temp = new Peminjaman();

            query = $"SELECT * FROM Lendings WHERE Username = '******' AND LendId ='{lendId}'";
            SqlDataReader sdr;
            SqlCommand    command = new SqlCommand(query, sqlConn);

            sqlConn.Open();
            sdr = command.ExecuteReader();

            //Get value
            sdr.Read();
            temp.lendId      = sdr.GetString(0).Trim();
            temp.username    = sdr.GetString(1).Trim();
            temp.bookId      = sdr.GetString(2).Trim();
            temp.strLendDate = sdr.GetString(3).Trim();
            temp.strDueDate  = sdr.GetString(4).Trim();
            temp.converToDateTime();
            temp.fineCount();
            //return class
            sqlConn.Close();
            return(temp);
        }
示例#5
0
        private void dgvBooks_SelectionChanged(object sender, EventArgs e)
        {
            try
            {
                string     idBuku       = dgvBooks.SelectedCells[3].Value.ToString();
                koneksiSql koneksi      = new koneksiSql();
                buku       bukuTerpilih = koneksi.returnBuku(idBuku);
                isiBuku(bukuTerpilih);

                Peminjaman pinjam = koneksi.returnLend(dgvBooks.SelectedCells[1].Value.ToString(), dgvBooks.SelectedCells[0].Value.ToString());
                isiPeminjaman(pinjam);
                if (pinjam.fine > 0)
                {
                    fined = true;
                }
            }
            catch (Exception)
            {
            }



            btnReturnBook.Enabled = true;
        }
示例#6
0
 private void isiPeminjaman(Peminjaman pinjam)
 {
     txtLendDate.Text   = pinjam.strLendDate;
     txtDeadline.Text   = pinjam.strDueDate;
     lblFineAmount.Text = "Rp. " + pinjam.fine.ToString();
 }