<%@ 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 () {
            selectMenu("《名家具》杂志广告", "");

            CountTotalPrice();
        });

        function Save() {
            var orderStr = "";
            $("input[type='text'][name^='Num']").each(function () {
                var num = $(this).val().replace(/[^\d]/g, '');
                var price = $(this).attr("price");
                if ($.trim(num) != "" && $.trim(num) != "0") {
                    var totalPrice = parseInt(num) * parseFloat(price);
                    var id = $(this).attr("name").substring(3);
                    orderStr += id + ":" + num + ":" + totalPrice + ";";
                }
            });
            $("#OrderStr").val(orderStr);

            MsgTip.show({ ico: 'loading', during: 0, msg: '正在处理请求，请稍等...' });

            $("#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 price = $(this).attr("price");

                var total = 0;
                if (regNum.test(num) && regPrice.test(price)) {
                    total += parseInt(num) * 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="right">
                        <table border="0" cellpadding="0" cellspacing="0">
                            <tr>
                                <td align="left" style="width:80px;">截止日期：</td>
                                <td align="left" style="width:80px;"><%=ViewData["EndDate"] %></td>
                                <td align="left" style="width:80px;">提交日期：</td>
                                <td align="left" style="width:80px;"><%=ViewData["SubDate"] %></td>
                            </tr>
                        </table>
                    </td>
                </tr>
                <tr><td>&nbsp;</td></tr>
                <tr>
                    <td align="left">
                      
                    </td>
                </tr>
                <tr><td><img src="<%=FamousFurnitureExpo.Models.Helper.VRoot %>/Content/images/zazhi.png" /></td></tr>
                <tr>
                    <td align="left">
                        <strong>《名家具》杂志广告：</strong>
                    </td>
                </tr>
                <tr>
                    <td align="left">
                        <table width="100%" border="0" cellpadding="1" cellspacing="0">
                            <tr>
                                <td class="td01" width="20%" align="center">版面</td>
                                <td class="td01" width="15%" align="center">尺寸 (宽*高) </td>
                              <%--  <td class="td01" width="25%" align="center">位置与形式 </td>
                                <td class="td01" width="10%" align="center">单位</td>--%>
                                <td class="td01" width="10%" align="center">收费</td>
                                <td class="td01" width="10%" 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)
                                {
                                    string scale = dr["SrjScale"].ToString().Trim();
                        %>
                            <tr>
                                <td class="td03" align="left"><%=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["SrjIntro"].ToString()) %></td>
                                <td class="td03" align="center"><%=Server.HtmlEncode(dr["SrjUnit"].ToString()) %></td>--%>
                                <% if (scale != "联系我们")
                                   { %>
                                <td class="td03" align="center"><%=Server.HtmlEncode(dr["SrjSalePrice"].ToString()) %></td>
                                <%
                                    if (dr["SrjTotalNum"].ToString() != "0")
                                    {
                                 %>
                                <td class="td03" align="center">
                                    <input type="text" class="text" id="Num<%=dr["SrjID"] %>" name="Num<%=dr["SrjID"] %>" price="<%=dr["SrjSalePrice"] %>" value="<%=Server.HtmlEncode(dr["OddTotalNum"].ToString()) %>" style="text-align:center; line-height:14px; width:50px; height:14px" onkeyup="CountTotalPrice()" />
                                </td>
                                <%}
                                    else
                                    { %>
                                    <td class="td03" align="center"></td>
                                    <%} %>
                                <%
                                    if (dr["SrjTotalNum"].ToString() == "0")
                                    {
                                 %>
                                <td class="td03" align="center" total="total">已售</td>
                                <%}
                                    else
                                    { %>

                                    <td class="td03" align="center" total="total"></td>

                                    <%} %>
                                <% }
                                   else
                                   { %>
                                <td class="td03" align="center">-</td>
                                <td class="td03" align="center">-</td>
                                <td class="td03" align="center">-</td>
                                <% } %>
                            </tr>
                        <%            
                                }
                        %>
                            <tr>
                                <td class="td03" align="center" colspan="1">费用合计：</td>
                                <td class="td03" align="center" colspan="6" alltotal="alltotal"></td>
                            </tr>
                            <tr><td>&nbsp;</td></tr>
                            <tr>
                                <td align="right" colspan="7">
                                    <table border="0" cellpadding="0" cellspacing="0">
                                        <tr>
                                            <td><div class="button" onclick="Save()">提交</div></td>
                                        </tr>
                                    </table>
                                </td>
                            </tr>
                        <%
                            }
                            else
                            { 
                        %>
                            <tr>
                                <td colspan="7" class="td03" align="center" valign="middle" height="40" width="100%">暂无信息</td>
                            </tr>
                        <%      
                            } 
                        %>
                        <tr>
                            <td colspan="7"><span>《名家具》杂志每月一期，展会期间为会刊。连续刊登广告三期，广告价九折，连续六期，八折，连续十二期，七折。</span></td>
                        </tr>
                        </table>
                    </td>
                </tr>
                <tr>
                    <td>
                        <input type="hidden" id="OrderStr" name="OrderStr" />
                    </td>
                </tr>
            </table>
            <script type="text/javascript">
                $(function () {
                    var message = $("#Message").val();
                    if (message != "") {
                        showMsg(message);
                    }
                });
            </script>
            <input type="hidden" id="Message" name="Message" value="<%=ViewData["Message"] %>" />
            </form>
        </center>
    </div>
</asp:Content>
