Ejemplo n.º 1
0
        public List <resultsTally> getLastPlaceBook()
        {
            List <resultsTally> lrt = new List <resultsTally>();
            resultsTally        rt;

            using (SqlCommand cmd = new SqlCommand("sp_getWorstBook"))
            {
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Connection  = conn;
                conn.Open();

                SqlDataReader rdr = cmd.ExecuteReader();

                while (rdr.Read())
                {
                    rt             = new resultsTally();
                    rt.book_id     = rdr.GetInt32(0);
                    rt.numberVotes = rdr.GetInt32(1);
                    rt.bookTitle   = rdr.GetString(2);
                    rt.bookAuthor  = rdr.GetString(3);

                    lrt.Add(rt);
                }

                rdr.Close();
                conn.Close();
            }

            return(lrt);
        }
Ejemplo n.º 2
0
        public resultsTally evaluateTopBooks()
        {
            SQLFunctions conn = new SQLFunctions();

            List <resultsTally> lrt = conn.getNumberOneBook();
            resultsTally        rt;


            int book1 = lrt[0].numberVotes;
            int book2 = lrt[1].numberVotes;

            if (book1 > book2)
            {
                return(lrt[0]);
            }
            else if (book1 == book2)
            {
                rt         = new resultsTally();
                rt.book_id = -2;
                return(rt);
            }
            {
                rt         = new resultsTally();
                rt.book_id = -1;
                return(rt);
            }
        }
Ejemplo n.º 3
0
        //protected List<resultsTally> evaluateTopBookPlurality()
        //{
        //    SQLFunctions conn = new SQLFunctions();
        //    int X = -1;
        //    List<resultsTally> lrtresult = new List<resultsTally>();

        //    List<resultsTally> lrt = conn.getNumberOnePlurality();
        //    foreach (resultsTally rt in lrt)
        //    {
        //        // Check for a tie
        //        if (rt.numberVotes == 3)
        //        {

        //        }


        //        if (X > -1)
        //        {
        //            if (X == rt.numberVotes)
        //            {
        //                lrtresult.Add(rt);
        //            }
        //        } else
        //        {
        //            X = rt.numberVotes;
        //            lrtresult.Add(rt);
        //        }
        //    }

        //    return lrt;
        //}

        protected resultsTally evaluateBottomBooks()
        {
            SQLFunctions conn = new SQLFunctions();

            List <resultsTally> lrt = conn.getLastPlaceBook();
            resultsTally        rt;


            int book1 = lrt[0].numberVotes;
            int book2 = lrt[1].numberVotes;

            if (book1 > book2)
            {
                return(lrt[0]);
            }
            else
            {
                rt         = new resultsTally();
                rt.book_id = -1;
                return(rt);
            }
        }
Ejemplo n.º 4
0
        protected void draw_custom_table()
        {
            SQLFunctions conn = new SQLFunctions();
            TableRow     row;
            TableCell    cell;

            tableContent.Rows.Clear();

            resultsTally        rt  = evaluateTopBooks();
            List <resultsTally> lrt = new List <resultsTally>();


            row  = new TableRow();
            cell = new TableCell();

            if (rt.book_id > -1)
            {
                cell.Text = "With " + rt.numberVotes + " number one votes, the clear #1 is : " + rt.bookTitle;
                row.Cells.Add(cell);
            }
            else if (rt.book_id == -2)
            {
                lrt       = returnTiedTopBooks();
                cell.Text = "Tied with " + lrt[0].numberVotes + " number one votes, the two best books are : " + lrt[0].bookTitle + " and " + lrt[1].bookTitle;
                row.Cells.Add(cell);
            }
            else
            {
                cell.Text = "There no was no clear #1 pick for best book!";
                row.Cells.Add(cell);

                //cell = new TableCell();
                //List<resultsTally> lrt = evaluateTopBookPlurality();
                //cell.Text = "With " + lrt[0].numberVotes + " the plurality of people voted #1 as : " + lrt[0].bookTitle;
            }

            tableContent.Rows.Add(row);


            rt = new resultsTally();
            rt = evaluateBottomBooks();

            row  = new TableRow();
            cell = new TableCell();

            if (rt.book_id > -1)
            {
                cell.Text = "With " + rt.numberVotes + " number seven votes, the most disliked book is : " + rt.bookTitle;
                row.Cells.Add(cell);
            }
            else if (rt.book_id == -2)
            {
                lrt = new List <resultsTally>();
                //lrt = returnTiedBottomBooks();
                cell.Text = "Tied with " + lrt[0].numberVotes + " number seven votes, the two worst books are : " + lrt[0].bookTitle + " and " + lrt[1].bookTitle;
                row.Cells.Add(cell);
            }
            else
            {
                cell.Text = "There no was no clear #1 pick for worst book!";
                row.Cells.Add(cell);
            }

            tableContent.Rows.Add(row);

            int pages = conn.getTotalPagesRead(2018);

            if (pages > -1)
            {
                row       = new TableRow();
                cell      = new TableCell();
                cell.Text = "We have read " + pages + " number of pages in 2018";
                row.Cells.Add(cell);
                tableContent.Rows.Add(row);
            }

            bookModel highCount = conn.getHighPageCount();

            if (highCount.bookPageLength > -1)
            {
                row  = new TableRow();
                cell = new TableCell();

                cell.Text = "The high page count is " + highCount.bookTitle + " with " + highCount.bookPageLength + " pages.";
                row.Cells.Add(cell);
                tableContent.Rows.Add(row);
            }

            bookModel lowCount = conn.getLowPageCount();

            if (highCount.bookPageLength > -1)
            {
                row  = new TableRow();
                cell = new TableCell();

                cell.Text = "The low page count is " + lowCount.bookTitle + " with " + lowCount.bookPageLength + " pages.";
                row.Cells.Add(cell);
                tableContent.Rows.Add(row);
            }

            int pubdate = conn.getAvgBookPublishYear(2018);

            if (pubdate > -1)
            {
                row       = new TableRow();
                cell      = new TableCell();
                cell.Text = "The average first published year is " + pubdate;
                row.Cells.Add(cell);
                tableContent.Rows.Add(row);
            }
        }