<%@ Page Language="C#" AutoEventWireup="True" CodeBehind="Admin_Product.aspx.cs" Inherits="TW.UI.Admin.Admin_Product" %>
<!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 runat="server">
<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/kindeditor/kindeditor-min.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">
    $(function(){
        if (<%=isabgos %>==1) {
            tomz();
        }
        if (<%=isagdscad %>==1) {
            added();
        }
    });
    var inhtml = "<%=inhtml%>";
    function addgds(tit, id) {
        if ($('#' + inhtml, window.parent.document).html() != "") {
            alert("一次只可添加一种点卡");
            return false;
        }
        $('#' + inhtml, window.parent.document).append('<a onclick="remv(this)" id="gds' + id + '" class="probtn">' + tit + '</a><input type="hidden" name="' + inhtml + '" value="' + id + '"/>');
    }
    $(function () {
        var hidThumb = $("#hidThumb").val();
        if (hidThumb != "") {
            UpReturn(hidThumb, "hidThumb");
        }
        EditorInit('txtContent');
        EditorInit('txtBuyAdviso');
    });
    function addparv(proid,id) {
        var proid = <%=id %>;
        if (proid<=0) {
            alert("请先保存商品才可添加面值");
            return false;
        }
        var tit = "添加面值";
        if (id>0) {
            tit = "修改面值";
        }
        art.dialog.open('/admin/Admin_Goods.aspx?proid='+proid+'&id='+id+'', {
            id: "e",
            title: tit,
            padding: 0,
            resize: false,
            lock: true,
            background: '#6ccff7', // 背景色
            opacity: 0.17,  	// 透明度
            width:700,
            close: function() {  
                var hasadd = $("#hasadd").val();
                var hasmodify = $("#hasmodify").val();
                if ((id==0 && hasadd=="1") || (id>0 && hasmodify=="1")) {
                    $("#btnGoodsRefresh").click();
                }
            } 
        },  
        false);

    }
    function tomz(){
        window.location.href="#mz";
    }
    function added(){ 
        if(confirm('该商品已含有面值，可以上架，确定上架？')){
            $("#btnAdded").click();
        }
    }
</script>
</head>
<body onload="setupZoom();">
<form id="form1" runat="server">
<input type="hidden" value="0" id="hasadd" />
<input type="hidden" value="0" id="hasmodify" />
<div class="nav"><h1>商品管理</h1></div>
<div class="cont">
        <asp:PlaceHolder ID="phExptGdsS" runat="server">
    <table class="table2">
        <tr>
            <th>商品名称：</th>
            <td>
                <asp:TextBox ID="txtTitle" runat="server"></asp:TextBox>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" 
                Display="Dynamic" ErrorMessage="*" SetFocusOnError="True" 
                ControlToValidate="txtTitle"></asp:RequiredFieldValidator>
            </td>
        </tr>
        <tr>
            <th>商品分类：</th>
            <td>
                <asp:DropDownList ID="ddlClassId" runat="server">
                </asp:DropDownList>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" 
                Display="Dynamic" ErrorMessage="*" SetFocusOnError="True" 
                ControlToValidate="ddlClassId" InitialValue="0"></asp:RequiredFieldValidator>
            </td>
        </tr>
        <tr>
		    <th>缩略图：</th>
            <td>
                建议尺寸：像素 宽x高=240x140<br />
                <asp:HiddenField ID="hidThumb" runat="server" />
		    	<iframe src="../inc/upload.aspx?dir=image&input=hidThumb" id="Iframe1" 
                width="300" height="25" scrolling="no" frameborder="0" allowtransparency="true"></iframe>
		    	<span id="hidThumb_Preview"></span>
            </td>
        </tr>
        <tr>
            <th>索引首字母：</th>
            <td>
                <TW:ReplaceBox ID="txtLetter" runat="server" ReplaceType="1"></TW:ReplaceBox>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server" 
                Display="Dynamic" ErrorMessage="*" SetFocusOnError="True" 
                ControlToValidate="txtLetter"></asp:RequiredFieldValidator>
                <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" 
                ErrorMessage="索引首字母必须为1位大小写字母" SetFocusOnError="True" Display="Dynamic" 
                ValidationExpression="^[a-zA-Z]{1}$" ControlToValidate="txtLetter">
                </asp:RegularExpressionValidator>
            </td>
        </tr>
        <tr>
            <th>首页滚动显示：</th>
            <td>
                <asp:CheckBox ID="chkIsInDPScroll" runat="server" Text="是否在首页滚动区域显示" />
            </td>
        </tr>
        <tr>
            <th>上架：</th>
            <td>
                <asp:CheckBox ID="chkIsAdded" runat="server" Text="是否上架" />
                <asp:Button ID="btnAdded" runat="server" Text="Button" CssClass="disnone" onclick="btnAdded_Click"/>
            </td>
        </tr>
        <tr>
            <th>商品描述：</th>
            <td>
                <asp:TextBox ID="txtContent" runat="server" TextMode="MultiLine" Height="400px" Width="680px"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <th>购买咨询：</th>
            <td>
                <asp:TextBox ID="txtBuyAdviso" runat="server" TextMode="MultiLine" Height="400px" Width="680px"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <th></th>
            <td class="abtn">
                <asp:Button ID="btnAdd" runat="server" Text="提交" onclick="btnAdd_Click" />
                <asp:Button ID="btnRetList" runat="server" Text="返回列表页" onclick="btnRetList_Click"/>
                <asp:Button ID="bntDel" runat="server" Text="删除该商品" CssClass="btn1 btn111" OnClientClick="return confirm('删除商品后将无法恢复，确定删除？');" onclick="btnDel_Click"/>
            </td>
        </tr>
        <tr id="mz">
            <th>点卡：</th>
            <td>
                <asp:Button ID="btnGoodsRefresh" runat="server" Text="Button" CssClass="disnone" onclick="btnGoodsRefresh_Click" />
                <input id="Button3" type="button" value="添加点卡" onclick="addparv(<%=id %>,0);" class="btn1 btn111" />
                <br />
                <br />   
        </asp:PlaceHolder>
                <%if (act == "addgds"){ %>
                <input id="Button1" type="button" value="返回商品列表" onclick="window.location.href='Admin_ProductList.aspx?act=<%=act %>&inhtml=<%=inhtml %>';;" class="btn1 btn111" />
                <%} %>
                <table class="table1">
                    <tr>
                        <td>标题</td>
                        <td>面值</td>
                        <td>充值类型</td>
                        <td>VIP价</td>
                        <td>普通会员价</td>
                        <td>原价</td>
                        <td>手续费比例</td>
                        <td>库存数量</td>
                        <td>销量</td>
                        <%if (act == ""){ %>
                        <td>商品编码</td>
                        <td>排序</td>
                        <%} %>
                        <td <%if (act != ""){ %> style="width:40px;"<%}else{ %>style="width:90px;"<%} %> >操作</td>
                    </tr>
                    <asp:Button ID="btnSaveGds" runat="server" Text="Button" CssClass="disnone" 
                    onclick="btnSaveGds_Click" />
                    <asp:Repeater ID="rptGoods" runat="server" onitemcommand="rptGoods_ItemCommand" 
                        onitemdatabound="rptGoods_ItemDataBound">
                    <ItemTemplate>
                    <asp:HiddenField ID="hidItemId" Value='<%#Eval("Id") %>' runat="server" />
                    <tr>
                        <td class="nor"><%#Eval("Thumb").ToString() == "" ? "<a href=\"/uploads/nopic.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><%#Eval("ParVal")%>元</td>
                        <td>
                            <%if (act == ""){ %>
                            <asp:DropDownList ID="ddlRecharType" runat="server" onchange="$('#btnSaveGds').click();">
                                <asp:ListItem Value="0">卡密</asp:ListItem>
                                <asp:ListItem Value="1">直充</asp:ListItem>
                            </asp:DropDownList>
                            <asp:LinkButton ID="LinkButton1" runat="server" CommandName="RecharType" Visible="False">保存</asp:LinkButton>
                            <%}else{ %>
                            <%#GetGoodsRecharType(Eval("RecharType"))%>
                            <%}%>
                        </td>
                        <td><%#Eval("VIPPrice")%>元</td>
                        <td><%#Eval("PTPrice")%>元</td>
                        <td><%#Eval("OrgPrice")%>元</td>
                        <td><%#Convert.ToInt32(Eval("FeeProp"))==0?"无手续费":Eval("FeeProp")+"%"%></td>
                        <td><%#Eval("StockNum")%></td>
                        <td><%#Eval("SaleNum")%></td>
                        <%if (act == ""){ %>
                        <td><%#Eval("GoodsNo")%></td>
                        <td>
                            <TW:ReplaceBox ID="txtPai" runat="server" Text='<%#Eval("Pai")%>' Width="50" onblur="$('#btnSaveGds').click();"></TW:ReplaceBox>
                            <asp:LinkButton ID="lbPai" runat="server" CommandName="Pai" Visible="False">保存</asp:LinkButton>
                        </td>
                        <%}%>
                        <td>   
                            <%if (act == ""){ %>
                            <a onclick="addparv(<%#Eval("ProId") %>,<%#Eval("Id") %>);">修改</a>  
                            <asp:LinkButton ID="btnDel" runat="server" CommandName="del" OnClientClick="return confirm('删除商品下所有点卡将自动下架，确定删除?')">删除?</asp:LinkButton>
                            <%}else{%>
                            <a onclick="addgds('<%#Eval("Title")%>','<%#Eval("Id")%>');">添加</a>    
                            <%}%>
                        </td>
                    </tr>
                    </ItemTemplate>
                    </asp:Repeater>
                </table>
                
        <asp:PlaceHolder ID="phExptGdsE" runat="server">
            </td>
        </tr>

        <asp:PlaceHolder ID="phJRCX" runat="server" Visible="False">
        <tr>
            <th>今日促销</th>
            <td>
                <input id="Button2" type="button" value="管理今日促销" onclick="window.location.href='Admin_DPTodayPromot.aspx?act=cx';" class="btn1 btn111" />
                <table class="table1">
                    <tr>
                        <td>标题</td>
                        <td>面值</td>
                        <td>充值类型</td>
                        <td>VIP价</td>
                        <td>促销价</td>
                        <td>原价</td>
                        <td>手续费比例</td>
                        <td>库存数量</td>
                        <td>销量</td>
                        <td>商品编码</td>
                    </tr>
                    <asp:Repeater ID="rptJRCXGds" runat="server">
                    <ItemTemplate>
                    <asp:HiddenField ID="hidItemId" Value='<%#Eval("Id") %>' runat="server" />
                    <tr>
                        <td class="nor"><%#Eval("Thumb").ToString() == "" ? "<a href=\"/uploads/nopic.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><%#Eval("ParVal")%>元</td>
                        <td><%#GetGoodsRecharType(Eval("RecharType"))%></td>
                        <td><%#Eval("VIPPrice")%>元</td>
                        <td><%#Eval("PTPrice")%>元</td>
                        <td><%#Eval("OrgPrice")%>元</td>
                        <td><%#Convert.ToInt32(Eval("FeeProp"))==0?"无手续费":Eval("FeeProp")+"%"%></td>
                        <td><%#Eval("StockNum")%></td>
                        <td><%#Eval("SaleNum")%></td>
                        <td><%#Eval("GoodsNo")%></td>
                    </tr>
                    </ItemTemplate>
                    </asp:Repeater>
                </table>
            </td>
        </tr>
        </asp:PlaceHolder>
        <asp:PlaceHolder ID="phJRMS" runat="server" Visible="False">
        <tr>
            <th>今日秒杀</th>
            <td>
                <input id="Button4" type="button" value="管理今日秒杀" onclick="window.location.href='Admin_DPTodayPromot.aspx?act=ms';" class="btn1 btn111" />
                <table class="table1">
                    <tr>
                        <td>标题</td>
                        <td>面值</td>
                        <td>充值类型</td>
                        <td>VIP价</td>
                        <td>秒杀价</td>
                        <td>秒杀日期</td>
                        <td>原价</td>
                        <td>手续费比例</td>
                        <td>库存数量</td>
                        <td>销量</td>
                        <td>商品编码</td>
                    </tr>
                    <asp:Repeater ID="rptJRMSGds" runat="server">
                    <ItemTemplate>
                    <asp:HiddenField ID="hidItemId" Value='<%#Eval("Id") %>' runat="server" />
                    <tr>
                        <td class="nor">
                            <%#Eval("Thumb").ToString() == "" ? "<a href=\"/uploads/nopic.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")%>
                            <%#Eval("DPMSThumb").ToString() == "" ? "<a href=\"/uploads/nopic.jpg\"><img src=\"images/tu0.gif\" border=\"0\" /></a>" : "<a href=\"/uploads/?" + Eval("DPMSThumb") + ".jpg\"><img src=\"images/tu1.gif\" border=\"0\" /></a>"%>
                        </td>
                        <td><%#Eval("ParVal")%>元</td>
                        <td><%#GetGoodsRecharType(Eval("RecharType"))%></td>
                        <td><%#Eval("VIPPrice")%>元</td>
                        <td><%#Eval("PTPrice")%>元</td>
                        <td><%#Convert.ToDateTime(Eval("SpikeDate")).ToString("yyyy-MM-dd")%></td>
                        <td><%#Eval("OrgPrice")%>元</td>
                        <td><%#Convert.ToInt32(Eval("FeeProp"))==0?"无手续费":Eval("FeeProp")+"%"%></td>
                        <td><%#Eval("StockNum")%></td>
                        <td><%#Eval("SaleNum")%></td>
                        <td><%#Eval("GoodsNo")%></td>
                    </tr>
                    </ItemTemplate>
                    </asp:Repeater>
                </table>
            </td>
        </tr>
        </asp:PlaceHolder>
    </table>
    </asp:PlaceHolder>
</div>
</form>
</body>
</html>
<script type="text/javascript">
    for (var j = 0; j < $('.table1').length; j++) {
        var oTab = $('.table1')[j];
        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>
