<%@ 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("新品上传", "");
        });

        function Add(id) {
            if (parseInt(id) >= 10) {
                alert("最多只能上传10个新品信息！");
                return;
            }
            else {
                window.location = "<%=FamousFurnitureExpo.Models.Helper.VRoot %>/Exhibitor/ProductEdit?Type=Add";
            }
        }
        function Edit(id) {
            //window.location = "<%=FamousFurnitureExpo.Models.Helper.VRoot %>/Exhibitor/ProductEdit?Type=Edit&ID=" + id;
            $("#ID").val(id);
            $("#Type").val("Edit");
            $("#f1").submit();
        }
        function Delete(id) {
            if (confirm("确定要删除吗？")) {
                $("#ID").val(id);
                $("#Type").val("Delete");
                $("#f1").submit();
            }
        }
    </script>
    <style type="text/css">
        .picBorder
        {  
            width:160px;
            height:120px; 
            padding:5px;
        }
        .introBorder
        {
            width:380px;
            height:90px; 
            padding:5px;
        }
        .buttonBorder
        {
            border:2px solid #4EB0AE;
            height:22px; 
            width:100px;
            padding-top:5px;
            text-align:center;
            cursor:pointer;
        }
        
        .lineDiv
        {
            height:1px;
            background-color:#4EB0AE;    
        }
    </style>
</asp:Content>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
    <div>
        <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 style="padding-left:10px"><br />
                    <strong>展品列表：</strong><br />
                </td>
            </tr>
            <tr><td>&nbsp;</td></tr>
                    <% 
                        string imgLogo = FamousFurnitureExpo.Models.Helper.VRoot + "/Content/Images/default.jpg";
                        string imgLogoSmall = FamousFurnitureExpo.Models.Helper.VRoot + "/Content/Images/default.jpg";
                        if (ViewData["ImgLogo"] != null && ViewData["ImgLogoSmall"] != null)
                        {
                            imgLogo = FamousFurnitureExpo.Models.Helper.GetWebConfig("ActorImageVRoot") + ViewData["ImgLogo"].ToString();
                            imgLogoSmall = FamousFurnitureExpo.Models.Helper.GetWebConfig("ActorImageVRoot") + ViewData["ImgLogoSmall"].ToString();
                        }

                        System.Data.DataTable dt = ViewData["DataTable"] as System.Data.DataTable;
                        if (dt != null && dt.Rows.Count > 0)
                        {
                            for (int i = 0; i < dt.Rows.Count; i++)
                            {
                                System.Data.DataRow dr = dt.Rows[i];
                                string id = dr["ID"].ToString();
                                string pdtType = Server.HtmlEncode(dr["TypName"].ToString());
                                string bthCode = Server.HtmlEncode(dr["BthCode"].ToString());

                                string atrName = Server.HtmlEncode(dr["AtrName"].ToString());
                                string pdtName = Server.HtmlEncode(dr["PdtName"].ToString());
                                string intro = Server.HtmlEncode(dr["PdtIntro"].ToString()).Replace("\n", " ").TrimStart('$').TrimEnd('$').Replace("$$$", "。").Replace("$$", "。").Replace("$", "。").Replace("&lt;", "<").Replace("&gt;", ">");
                                string introLong = "";
                                string introShort = "";
                                if (intro.Length > 150)
                                {
                                    introLong = intro.Replace("<br>", " ");
                                    introShort = intro.Substring(0, 150) + "...";
                                }
                                else
                                {
                                    string[] Arrintro = intro.Replace("<br>", "#").Split('#');
                                    if (Arrintro.Length > 2)
                                    {
                                        introShort = Arrintro[0] + "<br>" + Arrintro[1] + "<br>...";
                                        introLong = intro.Replace("<br>", " ");
                                    }
                                    else
                                    {
                                        introShort = intro;
                                    }
                                }

                                string atrEName = Server.HtmlEncode(dr["AtrEName"].ToString());
                                string pdtEName = Server.HtmlEncode(dr["PdtEName"].ToString());
                                string eIntro = Server.HtmlEncode(dr["PdtEIntro"].ToString()).Replace("\n", " ").TrimStart('$').TrimEnd('$').Replace("$$$", ".").Replace("$$", ".").Replace("$", ".").Replace("&lt;", "<").Replace("&gt;", ">");
                                string eIntroLong = "";
                                string eIntroShort = "";
                                if (eIntro.Length > 200)
                                {
                                    eIntroLong = eIntro.Replace("<br>", " ");
                                    eIntroShort = eIntro.Substring(0, 200) + "...";
                                }
                                else
                                {
                                    string[] Arreintro = eIntro.Replace("<br>", "#").Split('#');
                                    if (Arreintro.Length > 2)
                                    {
                                        eIntroShort = Arreintro[0] + "<br>" + Arreintro[1] + "<br>...";
                                        eIntroLong = eIntro.Replace("<br>", " ");
                                    }
                                    else
                                    {
                                        eIntroShort = eIntro;
                                    }
                                }

                                string img = FamousFurnitureExpo.Models.Helper.GetWebConfig("ActorImageVRoot") + dr["FilSPath"];
                                string imgBig = FamousFurnitureExpo.Models.Helper.GetWebConfig("ActorImageVRoot") + dr["FilPath"];

                                string Vote = CommonBasic.Data.SqlHelper.ExecuteScalar("select count(1) as VoteCount from BodyProduct bp inner join PersonJoin pj on pj.PsnID=bp.PsnID and pj.PsjPreExhID=bp.ExhID where bp.ExhID='" + dr["ExhID"].ToString() + "' and bp.ComID='" + dr["ComID"].ToString() + "' and bp.BypType='收藏'  and pj.PsjJoinType='预登记' and bp.BypRevid='" + dr["ID"].ToString() + "'");

                                string VoteCount = (Int32.Parse(dr["PdtVoteCount"].ToString()) + Int32.Parse(Vote)).ToString();
                    %>
            
            <tr>
                <td style="width:100%">
                    <table border="0" cellpadding="0" cellspacing="0" width="100%">
                        <tr>
                            <td align="left" style="padding-left:10px">
                                
                                <div id="line" class="lineDiv"></div>
                                <table border="0" cellpadding="0" cellspacing="0" width="100%">
                                    <tr>
                                        <td align="center" valign="top" rowspan="2">
                                            <div class="picBorder" style="margin-right:5px;">
                                                <a title="点击看原图" href="<%=imgBig %>" target="_blank">
                                                    <img alt="" src="<%=img %>" style="border:0px;" />
                                                </a>
                                                <br /><br />
                                              <%--  被关注数：<%=VoteCount%>--%>
                                            </div>
                                        </td>
                                        <td align="left">
                                            <div style="padding:5px;">
                                                公司：<%=atrName%>&nbsp;&nbsp;&nbsp;&nbsp;<br />
                                                展位号：<%=bthCode%>
                                            </div>
                                        </td>
                                        <td rowspan="2">
                                            <table border="0" cellpadding="0" cellspacing="0">
                                                <tr>
                                                    <td><div class="buttonBorder" style="margin-left:5px; margin-bottom:5px;" onclick="Edit(<%=id %>)">修改</div></td>
                                                </tr>
                                                <tr>
                                                    <td><div class="buttonBorder" style="margin-left:5px; margin-bottom:5px;" onclick="Delete(<%=id %>)">删除</div></td>
                                                </tr>
                                            </table>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            <div title="<%=introLong %>" class="introBorder">
                                                产品描述：<br><%=introShort%>
                                            </div>
                                        </td>
                                    </tr>
                                </table>
                                <br />
                            </td>
                        </tr>
                        <tr><td style=" height:2px"></td></tr>
                        <tr><td>&nbsp;</td></tr>
                        <tr>
                            <td>
                                
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
            <% 
}
                        }
                        else
                        { 
            %>
            <tr><td align="center" valign="top" style="height:80px;">您没有上传展品信息</td></tr>
            
            <%            
}                
            %>
            <tr>
                <td align="left" style="padding-left:10px">
                    <table border="0" cellpadding="0" cellspacing="0">
                        <tr>
                            <td><div class="button" onclick="Add(<%=ViewData["PdtCount"] %>)">新增</div>
                            <input type="hidden" id="ID" name="ID" />
                                <input type="hidden" id="Type" name="Type" />
                            
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
        </table>
        <script type="text/javascript">
        $(function () {
            var message = $("#Message").val();
            if (message != "") {
                MsgTip.show({ msg: message, ico: "warning" });
            }
        });
        </script>
        <input type="hidden" id="Message" name="Message" value="<%=ViewData["Message"] %>" />
        </form>
    </div>
</asp:Content>
