<%@ 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("电源");
            $("#menu31").css("visibility", "visible");

            CountTotalPrice();
        });

        function Save() {
            var orderStr = "";
            $("input[type='text'][name^='Num']").each(function () {
                var num = $(this).val().replace(/[^\d]/g, '');
                if ($.trim(num) != "" && $.trim(num) != "0") {
                    var id = $(this).attr("name").substring(3);
                    orderStr += id + ":" + num + ";";
                }
            });
            //保存联系人
            if (!SaveLinkPerson()) {
                return;
            }

            $("#OrderStr").val(orderStr);
            $("#f1").submit();
        }

        var regNum = /^\d+$/;
        var regPrice = /^\d+(\.\d+)?$/;
        function CountTotalPrice() {
            $("input[id^='Num']").each(function () {
                $(this).val($(this).val().replace(/[^\d]/g, ''));
                var num = $(this).val();
                var numOk = $(this).parent().parent().find("td[id^='NumOK']").html();
                var price = $(this).parent().parent().find("td[price]").attr("price");

                var total = 0;
                if (regNum.test(num) && regPrice.test(price)) {
                    total += parseInt(num) * parseFloat(price);
                }
                if (regNum.test(numOk) && regPrice.test(price)) {
                    total += parseInt(numOk) * parseFloat(price);
                }
                $(this).parent().parent().find("td[total]").html(total);
            });

            var allTotalPrice = 0;
            $("td[total]").each(function () {
                var totalPrice = $(this).html();
                if (regPrice.test(totalPrice)) {
                    allTotalPrice += parseFloat(totalPrice);
                }
            });
            $("td[alltotal]").html(allTotalPrice);
        }
    </script>
</asp:Content>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
    <div>
        <center>
            <form id="f1" action="" method="post">
            <table width="100%" border="0" cellpadding="0" cellspacing="0">
                <tr>
                    <td align="left">
                        <font color="red">展位搭建商现场申请展位用电的必填项。</font>
                    </td>
                </tr>
                <tr>
                    <td align="left">
                        <% Html.RenderPartial("ViewLinkPersonSet", "电源"); %>
                    </td>
                </tr>
                <tr><td>&nbsp;</td></tr>
                <tr>
                    <td align="left" style="color:Red;">
                        申请数 为展商新申请的未被确定的服务数量<br />
                        确定数 为展商申请的主办已确定的服务数量
                    </td>
                </tr>
                <tr>
                    <td align="left">
                        <table width="100%" border="0" cellpadding="1" cellspacing="0">
                            <tr>
                                <td class="td01" width="16%" align="center">名称</td>
                                <td class="td01" width="15%" align="center">规格</td>
                                <td class="td01" width="10%" align="center">单位</td>
                                <td class="td01" width="10%" align="center">价格</td>
                                <td class="td01" width="25%" align="center">服务内容</td>
                                <td class="td01" width="7%" align="center">申请数</td>
                                <td class="td01" width="7%" align="center">确定数</td>
                                <td class="td01" width="10%" align="center">小计</td>
                            </tr>
                        <% 
                            System.Data.DataTable dt = ViewData["DataTable"] as System.Data.DataTable;
                            if (dt.Rows.Count > 0)
                            {
                                foreach (System.Data.DataRow dr in dt.Rows)
                                {
                        %>
                            <tr>
                                <td class="td03" align="center"><%=Server.HtmlEncode(dr["SrjName"].ToString()) %></td>
                                <td class="td03" align="center"><%=Server.HtmlEncode(dr["SrjScale"].ToString()) %></td>
                                <td class="td03" align="center"><%=Server.HtmlEncode(dr["SrjUnit"].ToString()) %></td>
                                <td class="td03" align="center" price="<%=dr["SrjSalePrice"] %>"><%=Server.HtmlEncode(dr["SrjSalePrice"].ToString()) %></td>
                                <td class="td03" align="center"><%=Server.HtmlEncode(dr["SrjIntro"].ToString()) %></td>
                                <td class="td03" align="center">
                                    <input type="text" class="text" id="Num<%=dr["SrjID"] %>" name="Num<%=dr["SrjID"] %>" value="<%=Server.HtmlEncode(dr["OddNum"].ToString()) %>" style="text-align:center; line-height:14px; width:50px; height:14px" onkeyup="CountTotalPrice()" />
                                </td>
                                <td class="td03" align="center" id="NumOK<%=dr["SrjID"] %>" style="color:Red"><%=Server.HtmlEncode(dr["OddNumOK"].ToString()) %></td>
                                <td class="td03" align="center" total="total"></td>
                            </tr>
                        <%            
                                }
                        %>
                            <tr>
                                <td class="td03" align="center" colspan="1">费用合计:</td>
                                <td class="td03" align="center" colspan="7" alltotal="alltotal"></td>
                            </tr>
                            <tr><td>&nbsp;</td></tr>
                            <tr>
                                <td colspan="7">
                                    <div class="button" onclick="Save()">保存</div>
                                </td>
                            </tr>
                        <%
                            }
                            else
                            { 
                        %>
                            <tr>
                                <td colspan="7" class="td03" align="center" valign="middle" height="40" width="100%">暂无信息</td>
                            </tr>
                        <%      
                            } 
                        %>
                        </table>
                    </td>
                </tr>
                <tr>
                    <td>
                        <input type="hidden" id="OrderStr" name="OrderStr" />
                        <script type="text/javascript">
                            var message = "<%=ViewData["Message"] %>";
                            if (message != "") {
                                showMsg(message);
                            }
                        </script>
                    </td>
                </tr>
            </table>
            </form>
        </center>
    </div>
</asp:Content>
