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); } } }
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); }
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); }