<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Admin_ProductList.aspx.cs" Inherits="TW.UI.Admin.Admin_ProductList" %>
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<link href="css/default.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../js/jquery-1.10.2.min.js"></script>
<script type="text/javascript" src="../js/public.js"></script>
<script type="text/javascript" src="../js/My97DatePicker/WdatePicker.js"></script>
<script type="text/javascript" src="../js/artDialog/artDialog.js?skin=default"></script>
<script type="text/javascript" src="../js/artDialog/plugins/iframeTools.js"></script>

<script type="text/javascript" src="../js/FancyZoom/FancyZoom.js"></script>
<script type="text/javascript" src="../js/FancyZoom/FancyZoomHTML.js"></script>
<script type="text/javascript">
    var inhtml = "<%=inhtml%>";
    function addpro(tit, id) {
        var soaddstr = "";
        if (inhtml == "gmlsthotsp" || "<%=act %>" == "addpplpro" || "<%=act %>" == "addcxsssp") {
            var inhtmlcont = $.trim($('#' + inhtml, window.parent.document).html());
            if (inhtmlcont != "") {
                alert("一次只能添加一个商品");
                return false;
            }
            if ("<%=act %>" == "addcxsssp") {
                soaddstr = ";$('#hidProId').val('');$('#hidProTit').val('');";
            }
            if ("<%=act %>" == "addpplpro") {
                var smpplprolen = $('#' + inhtml, window.parent.document).parent().parent().parent().parent().parent().prev().find("input[type='hidden'][value='"+id+"']").length;
                if (smpplprolen > 0) {
                    alert("该商品已存在");
                    return false;
                }
                var prolen = $('#' + inhtml, window.parent.document).parent().parent().parent().parent().parent().prev().find(".populprobox").length;
                if (prolen >= 4) {
                    alert("最多添加4个商品");
                    return false;
                }
            }
        } else if (inhtml == "gmlsthotsp") {
            if ($("input[type='hidden'][name='" + inhtml + "_id'][value='" + id + "']", window.parent.document).length > 0) {
                alert("该商品已添加");
                return false;
            }
            if ($("input[type='hidden'][name='" + inhtml + "_id']", window.parent.document).length >= 8) {
                alert("最多添加8个热门商品");
                return false;
            }
        }
        if ($('#' + inhtml + ' a#pro' + id, window.parent.document).length > 0) {
            alert("该商品已存在");
            return false;
        }
        $('#' + inhtml, window.parent.document).append('<a onclick="remv(this)'+soaddstr+'" id="pro' + id + '" class="probtn">' + tit + '</a><input type="hidden" name="' + inhtml + '" value="' + id + '"/>');
        if ("<%=act %>" == "addcxsssp") {
            $("#hidProId", window.parent.document).val(id);
            $("#hidProTit", window.parent.document).val(tit);
        }
        if (inhtml == "gmlsthotsp" || "<%=act %>" == "addpplpro" || "<%=act %>" == "addcxsssp") {
            art.dialog.close();
        }
    }
    function savepai(obj) {
        $("#btnSavePai").click();
    }
</script>
</head>
<body onload="setupZoom();"<%if (act != "") { Response.Write(" style=\"width:600px;height:300px;\""); } %>>
<form id="form1" runat="server">
<div class="nav"><h1>商品列表</h1></div>

<div class="cont">
    <div class="opera">
        <table class="seletable">
            <tr>
                <td><img src="images/fdj.gif" class="fdj" /></td>
                <td>
                    名称：<asp:TextBox ID="txtTitleKey" runat="server"></asp:TextBox>
                    分类：<asp:DropDownList ID="ddlClass" runat="server" CssClass="mgrgt5px">
                    </asp:DropDownList>
                    首页滚动区域显示：<asp:DropDownList ID="ddlIsInDPScroll" runat="server" CssClass="mgrgt5px">
                        <asp:ListItem Value="-1">全部</asp:ListItem>
                        <asp:ListItem Value="0">否</asp:ListItem>
                        <asp:ListItem Value="1">是</asp:ListItem>
                    </asp:DropDownList>
                    是否上架：<asp:DropDownList ID="ddlIsAdded" runat="server" CssClass="mgrgt5px">
                        <asp:ListItem Value="-1">全部</asp:ListItem>
                        <asp:ListItem Value="0">否</asp:ListItem>
                        <asp:ListItem Value="1">是</asp:ListItem>
                    </asp:DropDownList>
                    索引首字母：<TW:ReplaceBox ID="txtLetter" runat="server" ReplaceType="1" Width="50px"></TW:ReplaceBox>
                    <asp:Button ID="btnSearch" runat="server" Text="搜索" CssClass="btn1" 
                        onclick="btnSearch_Click" />
                </td>
            </tr>
            <%if(act==""){ %>
            <tr>
                <td>
                    &nbsp;</td>
                <td>
                    <input id="Button3" type="button" value="新增" onclick="location.href='Admin_Product.aspx';" class="btn1 btn111" />
                    <asp:Button ID="Button7" runat="server" Text="删除?" 
                        OnClientClick="return (CheckLen()&&confirm('确定删除?'));" CssClass="btn1 btn111" 
                        onclick="btnDel_Click" />
                        
                    <asp:Button ID="btnSavePai" runat="server" Text="批量保存排序" 
                        CssClass="btn1 btn111 disnone" onclick="btnSavePai_Click"/>
                </td>
            </tr>
            <%} %>
        </table>
    </div>

<table class="table1">
<tr>
    <%if(act==""){ %>
    <td width="5%"><input id="chkall" onclick="CheckAll('chkBox')" type="checkbox" title="全选/全不选"/></td>
    <%} %>
    <td>标题</td>
    <td>分类</td>
    <td>索引首字母</td>
    <td>首页滚动区域显示</td>
    <%if(act==""){ %>
    <td>排序号</td>
    <%} %>
    <td>是否上架</td>
    <%if (act == ""){%>
    <td>时间</td>
    <%} %>
    <td>操作</td>
</tr>
    <asp:Repeater ID="Repeater1" runat="server" onitemcommand="Repeater1_ItemCommand">
    <ItemTemplate>
    <asp:HiddenField ID="hidItemId" Value='<%#Eval("Id") %>' runat="server" />
<tr>
    <%if(act==""){ %>
    <td><asp:CheckBox ID="chkBox" runat="server" /></td>
    <%} %>
    <td class="nor"><%#Eval("Thumb").ToString() == "" ? "<a href=\"uploads/no.jpg\"><img src=\"images/tu0.gif\" border=\"0\" /></a>" : "<a href=\"/uploads/?" + Eval("Thumb") + ".jpg\"><img src=\"images/tu1.gif\" border=\"0\" /></a>"%><%#Eval("Title")%></td>
    <td><%#GetProClassTit(Eval("ClassId"))%></td>
    <td><%#Eval("Letter")%></td>
    <td>
        <asp:LinkButton ID="LinkButton1" runat="server" CommandName="IsInDPScroll">
        <%#Convert.ToBoolean(Eval("IsInDPScroll")) == true ? "<font color=green>是</font>" : "<font color=red>否</font>"%>
        </asp:LinkButton>
    </td>
    <%if(act==""){ %>
    <td>
        <TW:ReplaceBox ID="txtPai" runat="server" Text='<%#Eval("Pai")%>' onblur="savepai(this);"></TW:ReplaceBox>
    </td>
    <%} %>
    <td>
        <asp:LinkButton ID="LinkButton2" runat="server" CommandName="IsAdded">
        <%#Convert.ToBoolean(Eval("IsAdded")) == true ? "<font color=green>是</font>" : "<font color=red>否</font>"%>
        </asp:LinkButton>
    </td>
    <%if (act == ""){%>
    <td><%#Convert.ToDateTime(Eval("AddTime")).ToString("yyyy-MM-dd HH:mm:ssss")%></td>
    <%} %>
    <td>   
        <%if (act == "addpro" || act == "addpplpro" || act == "addcxsssp"){%>
        <a onclick="addpro('<%#Eval("Title")%>','<%#Eval("Id")%>');">添加</a>    
        <%}else if (act == "addgds"){%>
        <a href="Admin_Product.aspx?id=<%#Eval("Id") %>&act=<%=act%>&inhtml=<%=inhtml %>" class="clrrd fwbld">查看点卡</a>   
        <%} else{%>
        <a href="Admin_Product.aspx?id=<%#Eval("Id") %>">修改</a>              
        <asp:LinkButton ID="btnDel" runat="server" CommandName="del" OnClientClick="return confirm('确定删除?')">删除?</asp:LinkButton>
        <%}%>
    </td>
</tr>
    </ItemTemplate>
    </asp:Repeater>
</table>
<TW:Pager ID="Pager1" runat="server" CssClass="page" 
        onchangepageclick="Pager1_ChangePageClick" />
</div>

</form>

<script type="text/javascript">
    var oTab = $('.table1')[0];
    var oldBgColor = '';
    var i = 0;
    for (i = 0; i < oTab.tBodies[0].rows.length; i++) {
        oTab.tBodies[0].rows[i].style.background = i % 2 ? '#ffffff' : 'url(images/line2.png) repeat-x';
        oTab.tBodies[0].rows[i].onmouseover = function () {
            oldBgColor = this.style.background;
            this.style.background = '#ffffd4 url(images/line.png) repeat-x';
        };
        oTab.tBodies[0].rows[i].onmouseout = function () {
            this.style.background = oldBgColor;
        };
    }
</script>
</body>
</html>
