Example #1
0
        public List <string> GetOverdue()
        {
            SqlConnection conn = DB.Connection();

            conn.Open();

            SqlCommand cmd = new SqlCommand("SELECT copy_id, due_date FROM checkout WHERE patron_id = @PatronId AND current_checkout = 1 AND due_date < @Today;", conn);

            cmd.Parameters.Add(new SqlParameter("@PatronId", this.GetId().ToString()));
            cmd.Parameters.Add(new SqlParameter("@Today", "2017-03-02"));

            SqlDataReader rdr = cmd.ExecuteReader();

            List <string> allDue = new List <string> {
            };

            while (rdr.Read())
            {
                int    copyId     = rdr.GetInt32(0);
                Copy   foundCopy  = Copy.Find(copyId);
                string foundTitle = foundCopy.GetBookTitle();
                allDue.Add(foundTitle);
                string dueDate = rdr.GetDateTime(1).ToString("yyyy-MM-dd");
                allDue.Add(dueDate);
            }

            DB.CloseSqlConnection(rdr, conn);

            return(allDue);
        }