Esempio n. 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //Load Book information

            HtmlTableRow  row;
            HtmlTableCell cell;
            TextBox       txtBox;
            int           x = 0;



            row  = new HtmlTableRow();
            cell = new HtmlTableCell();

            cell.InnerText = "Vote Preference";
            row.Cells.Add(cell);

            cell           = new HtmlTableCell();
            cell.InnerText = "Author";
            row.Cells.Add(cell);

            cell           = new HtmlTableCell();
            cell.InnerText = "Title";
            row.Cells.Add(cell);

            tableContent.Rows.Add(row);


            SQLFunctions conn = new SQLFunctions();

            //Check if user has already voted
            string currentUser = HttpContext.Current.User.Identity.Name;
            int    userId      = conn.getUserID(currentUser);

            if (conn.hasUserVoted(userId, 2019))
            {
                tableContent.Visible      = false;
                btnSubmit.Visible         = false;
                ThankYouForVoting.Text    = "You have already voted!";
                ThankYouForVoting.Visible = true;
            }
            else
            {
                //int count = conn.getBookCount();
                List <bookModel> book = conn.getBookAuthorTitle(2018);


                foreach (bookModel items in book)
                {
                    x++;
                    row    = new HtmlTableRow();
                    cell   = new HtmlTableCell();
                    txtBox = new TextBox();
                    //txtBox.ID = x.ToString();

                    txtBox.Width = 50;
                    cell.Controls.Add(txtBox);
                    row.Cells.Add(cell);
                    //cell.InnerText = "Vote!";
                    //row.Cells.Add(txtBox);

                    cell           = new HtmlTableCell();
                    cell.InnerText = items.bookAuthor;
                    row.Cells.Add(cell);

                    cell           = new HtmlTableCell();
                    cell.InnerText = items.bookTitle;
                    row.Cells.Add(cell);

                    tableContent.Rows.Add(row);
                }
            }
        }