protected bool LoadBorrow() { SqlConnection conn = new SqlConnection(conString); SqlCommand comm = new SqlCommand(); comm.Connection = conn; comm.CommandType = CommandType.Text; comm.CommandText = "SELECT Borrowing.BorrowID,Borrowing.BookID,Book.Title,Borrowing.BorrowDate,Borrowing.ReturnDate FROM Borrowing " + "INNER JOIN Book ON Borrowing.BookID = Book.BookID WHERE Borrowing.MemberID = @MemberID AND Borrowing.Returned = 'false' " + "ORDER BY Borrowing.BorrowID DESC"; comm.Parameters.AddWithValue("@MemberID", txtUser.Text); conn.Open(); SqlDataReader reader = comm.ExecuteReader(); DataTable dt = new DataTable(); if (reader.HasRows) { PanelBorrow.Visible = true; dt.Load(reader); RepeaterBorrow.DataSource = dt; RepeaterBorrow.DataBind(); conn.Close(); return(true); } else { conn.Close(); return(false); } }
private void LoadBorrowData(string value) { SqlCommand comm = new SqlCommand(); comm.Connection = conn; comm.CommandType = CommandType.Text; if (value == "Borrowed") { comm.CommandText = "SELECT Borrowing.BorrowID,Borrowing.BookID,Book.Title,Borrowing.BorrowDate,Borrowing.ReturnDate,Borrowing.Returned FROM Borrowing " + "INNER JOIN Book ON Borrowing.BookID = Book.BookID WHERE Borrowing.MemberID = @MemberID AND Borrowing.Returned = 'False' " + "ORDER BY Borrowing.BorrowID DESC"; } else if (value == "Late") { comm.CommandText = "SELECT Borrowing.BorrowID,Borrowing.BookID,Book.Title,Borrowing.BorrowDate,Borrowing.ReturnDate,Borrowing.Returned FROM Borrowing " + "INNER JOIN Book ON Borrowing.BookID = Book.BookID WHERE Borrowing.MemberID = @MemberID AND Borrowing.Returned = 'False' AND Borrowing.ReturnDate < GETDATE() " + "ORDER BY Borrowing.BorrowID DESC"; } else if (value == "Returned") { comm.CommandText = "SELECT Borrowing.BorrowID,Borrowing.BookID,Book.Title,Borrowing.BorrowDate,Borrowing.ReturnDate,Borrowing.Returned FROM Borrowing " + "INNER JOIN Book ON Borrowing.BookID = Book.BookID WHERE Borrowing.MemberID = @MemberID AND Borrowing.Returned = 'True' " + "ORDER BY Borrowing.BorrowID DESC"; } else if (value == "All") { comm.CommandText = "SELECT Borrowing.BorrowID,Borrowing.BookID,Book.Title,Borrowing.BorrowDate,Borrowing.ReturnDate,Borrowing.Returned FROM Borrowing " + "INNER JOIN Book ON Borrowing.BookID = Book.BookID WHERE Borrowing.MemberID = @MemberID " + "ORDER BY Borrowing.BorrowID DESC"; } comm.Parameters.AddWithValue("@MemberID", Session["MemberID"]); conn.Open(); SqlDataReader reader = comm.ExecuteReader(); DataTable dt = new DataTable(); if (reader.HasRows) { dt.Load(reader); RepeaterBorrow.DataSource = dt; RepeaterBorrow.DataBind(); PanelAlertBorrow.Visible = false; } else { RepeaterBorrow.DataSource = null; RepeaterBorrow.DataBind(); PanelAlertBorrow.Visible = true; } reader.Close(); dt.Dispose(); }