<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ManagePolls.aspx.cs" Inherits="Admin_ManagePolls" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Manage Polls</title>
        <link href="../Styles/MSStyles_Main.css" type="text/css" rel="Stylesheet" />

</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server" />
    
    
<asp:Panel ID="pnlContent" runat="server" style="margin: 10px; padding: 10px;" HorizontalAlign="Left" Width="80%" BackColor="#233052">   

<h3>MurraySabrin.com - Poll Manager</h3>
    
<asp:Panel ID="pnlResults" runat="server" Visible="false" CssClass="NoticePanel"  >
    <asp:Label ID="lblResults" runat="server" />
</asp:Panel>

        <asp:Panel ID="pnlNew" runat="server" Visible="false" >
        <%-- For now we only allow one poll on the site --%>
            <b>Add New</b><br />
            Title:  <asp:TextBox ID="txtNewTitle" runat="server" Width="150"></asp:TextBox><br />
            Question: <asp:TextBox ID="txtNewQuestion" runat="server"  /><br />
            Answer List: <asp:TextBox ID="txtNewAnswerList" Rows="4" Width="350" TextMode="MultiLine" runat="server" /> <br />
            <asp:Button ID="btnAdd" runat="server" Text="Add Poll" OnClick="btnAdd_Click" />
            
        </asp:Panel>
    
    <asp:Panel ID="pnlDetails" runat="server">
    
        <asp:Table runat="server" ID="pollEditor">
        
            <asp:TableRow>
                <asp:TableCell>
                    Title
                </asp:TableCell>
                <asp:TableCell>
                    <asp:TextBox ID="txtTitle" runat="server" />
                </asp:TableCell>
            </asp:TableRow>
            
            <asp:TableRow>
                <asp:TableCell>
                    Question
                </asp:TableCell>
                <asp:TableCell>
                    <asp:TextBox ID="txtQuestion" runat="server" />
                </asp:TableCell>
            </asp:TableRow>

            <asp:TableRow>
                <asp:TableCell ColumnSpan="2" HorizontalAlign="Center">
                    <asp:Button ID="btnSavePoll" Text="Save Poll" runat="server" OnClick="btnSavePoll_Click" />
                </asp:TableCell>
            </asp:TableRow>

            <asp:TableRow>
                <asp:TableCell>
                    Answers
                </asp:TableCell>
                <asp:TableCell>
                    <asp:Panel ID="pnlAnswerControls" runat="server">
                        <asp:GridView ID="gvAnswers" runat="server" 
                            AutoGenerateDeleteButton="true" 
                            AutoGenerateEditButton="true"  
                            OnRowDeleting="gvAnswers_Delete" 
                            OnRowCancelingEdit="gvAnswers_CancelEdit" 
                            OnRowUpdated="gvAnswers_RowUpdated" 
                            OnRowCommand="gvAnswers_Command" 
                            OnRowUpdating="gvAnswers_RowUpdating" 
                            OnRowEditing="gvAnswers_RowEditing" 
                            DataKeyNames="ID" AutoGenerateColumns="false"
                        >
                        <Columns>
                            <asp:TemplateField HeaderText="Question">
                                <ItemTemplate>                                
                                    <asp:Label ID="lblAnswer" runat="server" Text='<%#Bind("Label") %>'/>
                                </ItemTemplate>
                                <EditItemTemplate>                                
                                    <asp:TextBox ID="txtAnswer" runat="server" Text='<%#Bind("Label") %>'/>
                                </EditItemTemplate>                            
                            </asp:TemplateField>
                            
                            <asp:BoundField HeaderText="Votes" DataField="Votes" />
                        </Columns>
                        </asp:GridView>
                        
                    </asp:Panel>
                </asp:TableCell>
            </asp:TableRow>
            
            <asp:TableRow>
                <asp:TableCell>
                    <asp:TextBox ID="txtNewAnswer" runat="server">
                    </asp:TextBox>
                </asp:TableCell>
                <asp:TableCell>
                    <asp:Button ID="btnAddAnswer" runat="server" Text="Add Answer" OnClick="btnAddAnswer_Click" />
                </asp:TableCell>
            </asp:TableRow>
            
        </asp:Table>
    
    </asp:Panel>
    
    
    <asp:Panel ID="pnlPollList" runat="server" Visible="false">
        <asp:GridView ID="gvPolls" runat="server" AutoGenerateColumns="false"
        AlternatingRowStyle-BackColor="#CCCCCC" AlternatingRowStyle-ForeColor="Black"
        AutoGenerateDeleteButton="true" AutoGenerateEditButton="true" OnRowEditing="gvPolls_RowEditing"
        GridLines="Horizontal" DataKeyNames="ID" CellPadding="5" CellSpacing="2" BorderColor="Gray" 
        BorderWidth="1" BorderStyle="Inset" Width="80%" 
        OnRowDeleting="gvPolls_Delete" 
        OnRowCancelingEdit="gvPolls_CancelEdit" 
        OnRowUpdated="gvPolls_RowUpdated" 
        OnRowCommand="gvPolls_Command" 
        OnRowUpdating="gvPolls_RowUpdating" 
        >
 
 <EmptyDataTemplate>
    There were no polls found
 </EmptyDataTemplate>       
            <Columns>
                <asp:TemplateField HeaderText="Event Date">
                    <EditItemTemplate>
                        <asp:TextBox ID="txtEventDate" runat="server" Text='<% #Eval("EventDateString") %>' />
                         <cc1:CalendarExtender ID="CalendarExtender1" runat="server" Animated="true" 
                                TargetControlID="txtEventDate"  />

                    </EditItemTemplate>
                    <ItemTemplate>                    
                        <asp:Label ID="lblEventDate" runat="server" Text='<% #Eval("EventDateString") %>' />
                    </ItemTemplate>
                
                </asp:TemplateField>

               <asp:TemplateField HeaderText="Title">
                    <EditItemTemplate>
                        <asp:TextBox ID="txtTitle" runat="server" Text='<% #Eval("Title") %>' />
                    </EditItemTemplate>
                    <ItemTemplate>                    
                        <asp:Label ID="lblTitle" runat="server" Text='<% #Eval("Title") %>' />
                    </ItemTemplate>                
                </asp:TemplateField>

               <asp:TemplateField HeaderText="Description">
                    <EditItemTemplate>
                        <asp:TextBox ID="txtDescription" TextMode="MultiLine" Width="400px" Rows="4" runat="server" Text='<% #Eval("Description") %>' />
                    </EditItemTemplate>
                    <ItemTemplate>                    
                        <asp:Label ID="lblDescription" runat="server" Text='<% #Eval("Description") %>' />
                    </ItemTemplate>                
                </asp:TemplateField>
            
            </Columns>
        </asp:GridView>
</asp:Panel>        
</asp:Panel>
    </form>
</body>
</html>
