<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/ExhibitorMaster.Master" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>

<asp:Content ID="Content2" ContentPlaceHolderID="HeadContent" runat="server">
    <script type="text/javascript">
        $(function () {
            $("#CurrentPosition").html("撮合信息填写");
            $("#menu63").css("visibility", "visible");

            $("input[type='radio']").click(function () {
                if ($(this).attr("tag") == "0") {
                    $(this).attr("checked", true);
                    $(this).attr("tag", 1);
                } else {
                    $(this).attr("checked", false);
                    $(this).attr("tag", 0);
                }
            });

            var search = $("#SearchStr").val();
            if (search != "") {
                var strArray = search.split(";")
                for (var i = 0; i < strArray.length; i++) {
                    var strFull = strArray[i];
                    if (strFull != "") {
                        var str = strFull.split(":");
                        if (str[1] != "0") {
                            $("input[qus='" + str[0] + "'][value='" + str[1] + "']").attr("checked", true);
                        } else {
                            $("input[qus='" + str[0] + "']").val(str[2]);
                        }
                    }
                }
            }
        });

        function Save() {
            var str = "";
            $("input:checked").each(function () {
                str += $(this).attr("qus") + ":" + $(this).val() + ":;";
            });
            $("input[type='text']").each(function () {
                if ($(this).val() != "") {
                    str += $(this).attr("qus") + ":0:" + $(this).val().replace(":","：").replace(";","；") + ";";
                }
            });
            $("#SearchStr").val(str);

            $("#f1").submit();
        }
    </script>
</asp:Content>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
    <div>
        <center>
            <form id="f1" action="" method="post">
            <table width="100%" border="0" style="text-align: left" cellpadding="0" cellspacing="0" id="main">
                <tr>
                    <td>
                        以下信息能够让观众更有效、更准确的找到您，请务必根据实际情况尽可能的准确填写。
                    </td>
                </tr>
                <tr><td>&nbsp;</td></tr>
                <tr>
                    <td align="left">
                        <table width="100%" border="0" cellpadding="5" cellspacing="0">
            <% 
            Dictionary<System.Data.DataRow, System.Data.DataTable> diQus = ViewData["Di"] as Dictionary<System.Data.DataRow, System.Data.DataTable>;
            if(diQus.Keys.Count>0)
            {
                foreach (System.Data.DataRow drQus in diQus.Keys)
                {
            %>
                            <tr valign="top">
                                <td align="right" width="20%" style="border-top:1px solid rgb(98,98,98)">
                                    <%=Server.HtmlEncode(drQus["QusQuestion"].ToString()) %>：<br />
                                    （<%=Server.HtmlEncode(drQus["QtpName"].ToString()) %>）
                                </td>
                                <td align="left" width="80%" style="border-top:1px solid rgb(98,98,98)">
            <%
                    int qtpID = Convert.ToInt32(drQus["QtpID"]);
                    System.Data.DataTable dtAns = diQus[drQus];
                    if (qtpID == 1)
                    { 
            %>
                        <span><input type="text" name="txt<%=drQus["QusID"] %>" qus="<%=drQus["QusID"] %>" /></span>
            <%
                    }
                    if (qtpID == 2)
                    {
                        foreach (System.Data.DataRow drAns in dtAns.Rows)
                        {
            %>
                                    <span><input type="radio" name="rdo<%=drQus["QusID"] %>" tag="0" qus="<%=drQus["QusID"] %>" value="<%=drAns["AnsID"] %>" /><%=Server.HtmlEncode(drAns["AnsTitle"].ToString()) %></span>&nbsp;
            <%            
                        } 
                    }
                    if (qtpID == 3)
                    { 
                        foreach (System.Data.DataRow drAns in dtAns.Rows)
                        {
            %>
                                    <span><input type="checkbox" name="rdo<%=drQus["QusID"] %>" qus="<%=drQus["QusID"] %>" value="<%=drAns["AnsID"] %>" /><%=Server.HtmlEncode(drAns["AnsTitle"].ToString()) %></span>&nbsp;
            <%            
                        } 
                    }
            %>             
                                </td>
                            </tr>
            <%            
                }      
            %>
                            <tr><td>&nbsp;</td></tr>
                            <tr>
                                <td>
                                    <div class="button" onclick="Save()">保存</div>
                                </td>
                            </tr>
            <%          
            }
            else
            { 
            %>
                            <tr>
                                <td valign="middle" align="center" height="30px">还没有设置撮合问卷</td>
                            </tr>
            <%
            }
            %>
                        </table>
                    </td>
                </tr>
                <tr>
                    <td>
                        <input type="hidden" id="SearchStr" name="SearchStr" value="<%=ViewData["SearchStr"] %>" />
                        <%=ViewData["Message"]%>
                    </td>
                </tr>
            </table>
            </form>
        </center>
    </div>
</asp:Content>
