<%@ control language="C#" autoeventwireup="true" inherits="Admin_UserControl_AddAttribute, ShopWe" %>
<%@ Register Assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
    Namespace="System.Web.UI" TagPrefix="asp" %>

<script type="text/javascript">
    //添加名称
    function AddAttributeName(name)
    {
       var ObjID=generateMixed(10);
       var DivID=document.getElementById("AttributeGroup");
       DivID.innerHTML+="<div class=\"din_all\" id=\""+ObjID+"\">"+
       "<div class=\"come_title_hui\">"+
       "<table width=\"100%\" height=\"24px\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">"+
       "<tr><td><h1><strong>"+name+"</strong></h1></td><td style=\"width: 60px\">"+
       "<div class=\"img_button\"><img src=\"../css/images/add_img.gif\" alt=\"添加\" />"+
       "<a href='javascript:AddAttributeValue(\""+ObjID+"\",\""+name+"\")' class=\"grey\">添加</a></div></td>"+
       "<td style=\"width: 60px\">"+
       "<div class=\"img_button\"><img src=\"../css/images/del_imgred.gif\" alt=\"清空\" width=\"14\" height=\"10\" />"+
       "<a href='javascript:Delete(\""+ObjID+"\")' class=\"grey\">清空</a></div></td>"+
       "</tr></table></div>"+
       "<input name=\"AttributeName\" type=\"hidden\" value=\""+name+"\" />"+
       "</div>";
       
       AddAttributeValue(ObjID,name);
    }
    //添加规格名称
    function AddAttributeValue(ParentID,PatentName)
    {
    var ObjID=generateMixed(10);
    var DivID=document.getElementById(ParentID);
    DivID.innerHTML+="<div class=\"din_all_body\" id=\""+ObjID+"\">"+
                     "<div class=\"din_all_title\">"+
                     "<span class=\"h7ys\">规格值：</span>"+
                     "<input name=\"AttributeValue\" type=\"text\" class=\"input\" />"+
                     "<span class=\"h7ys\">&nbsp;&nbsp;&nbsp;规格图片(可选)：</span><input name=\"AttributeImage\" type=\"file\" class=\"input\" height=\"20px\" />"+
                     "<div class=\"img_button\"><img src=\"../css/images/del_imgred.gif\" alt=\"删除\" width=\"14\" height=\"10\" />"+
                     "<a href='javascript:Delete(\""+ObjID+"\")' class=\"grey\">删除</a></div>"+
                     "</div>"+
                     "<input name=\"ParentName\" type=\"hidden\" value=\""+PatentName+"\" />"+
                     "</div>";
    }
 //清空规格值
function AttributeClear()
{
var div=document.getElementById("AttributeGroup");
div.innerHTML="";
}

 
</script>

<asp:UpdatePanel ID="UpdatePanelAttribute" runat="server" UpdateMode="Conditional">
    <ContentTemplate>
        <div class="come_title_3">
            <table width="100%" height="30" border="0" cellpadding="0" cellspacing="0">
                <tr>
                    <td>
                        <h2>
                            商品属性：</h2>
                        <input id="AttName" type="text" style="height: 18px" class="input" />
                        <input type="button" value="添加一个属性组" class="butt_tle" onclick="AddAttributeName(document.getElementById('AttName').value);HideDiv('AttributeTip');"
                            style="height: 20px; width: 110px" />
                        <input type="button" value="全部清空" class="butt_tle" onclick="AttributeClear()" style="height: 20px;
                            width: 70px" />
                    </td>
                    <td>
                        <asp:TextBox ID="SelectGroupName" runat="server" CssClass="input" Width="150" Height="18"
                            Text="添加快速选择组" MaxLength="7"></asp:TextBox>
                        <asp:Button ID="AddGroup" runat="server" CssClass="butt_tle" Height="20px" Width="120px"
                            CausesValidation="false" Text="添加到快速选择组" OnClick="AddGroup_Click" />
                    </td>
                </tr>
            </table>
        </div>
        <div class="k_all1">
            <asp:Repeater ID="RepeaterSelectGroup" runat="server" OnItemCommand="RepeaterSelectGroup_ItemCommand">
                <ItemTemplate>
                    <div class="Template2_button">
                        <asp:ImageButton ID="DeleteGroup" runat="server" ImageUrl="~/Admin/css/images/del_imgred.gif"
                            CommandName="Delete" CommandArgument='<%# Eval("File") %>' CausesValidation="false"
                            ToolTip="删除" OnClientClick="return confirm('你真的要删除?');" /><asp:LinkButton ID="LinkButtonSelectGroup"
                                runat="server" CssClass="blue" CommandName="Select" CommandArgument='<%# Eval("File") %>'
                                CausesValidation="false"><%# Eval("Name") %></asp:LinkButton>
                    </div>
                    <!--<img src="../css/images/bj.png" alt="导出" />
                <a href='../xml/Attribute/<%# Eval("File")%>' class="grey" target="_blank">导出</a>-->
                </ItemTemplate>
            </asp:Repeater>
        </div>
    </ContentTemplate>
</asp:UpdatePanel>
<asp:UpdatePanel ID="UpdatePanelAttributeBody" runat="server" UpdateMode="Conditional">
    <ContentTemplate>
        <div class="k_all1" id="AttributeGroup">
            <asp:Panel ID="PanelTip" runat="server">
                <div id="AttributeTip">
                    <div class="ys_bf_eeor">
                        <table>
                            <tr>
                                <td align="center" style="height: 30px">
                                    你还未添加属性组，请<a href="#" onclick="AddAttributeName(document.getElementById('AttName').value);HideDiv('AttributeTip');"
                                        class="blue"> 添加一个规格组 </a>或者快速导入。</td>
                            </tr>
                        </table>
                    </div>
                </div>
            </asp:Panel>
            <asp:Literal ID="AttributeBody" runat="server"></asp:Literal>
        </div>
    </ContentTemplate>
</asp:UpdatePanel>
<div id="AssemblyDiv" class="k_all8">
    <div class="ys_bf_bj">
        <table>
            <tr>
                <td style="width: 220px">
                    <h1>
                        点击升级商品：</h1>
                    <div class="bin_button">
                        <asp:LinkButton ID="AttributeAssemble" CssClass="blue" runat="server" OnClick="AttributeAssemble_Click"
                            CausesValidation="False">生成商品</asp:LinkButton>
                    </div>
                </td>
                <td style="width: 140px">
                    <h1>
                        默认库存：</h1>
                    <asp:TextBox ID="DefaultStock" Width="50px" runat="server" Text="0"></asp:TextBox>
                </td>
                <td>
                    <div class="bin_button">
                        <asp:LinkButton ID="ClearAssemble" CssClass="blue" runat="server" OnClick="ClearAssemble_Click"
                            CausesValidation="False">清空属性</asp:LinkButton></div>
                </td>
            </tr>
        </table>
    </div>
</div>
<asp:UpdatePanel ID="UpdatePanelAssemble" runat="server" UpdateMode="Conditional">
    <ContentTemplate>
        <div class="k_all1">
            <asp:Panel ID="PanelAssembleTip" runat="server">
                <div class="ys_bf_eeor">
                    <table>
                        <tr>
                            <td align="center" style="height: 30px">
                                填写属性完成后配搭商品，点击配搭即可，注：可以统一填写库存和价格。</td>
                        </tr>
                    </table>
                </div>
            </asp:Panel>
            <asp:Repeater ID="RepeaterAssemble" runat="server">
                <HeaderTemplate>
                    <table width="100%" border="0" cellspacing="0" cellpadding="0" class="bin_tle">
                        <tr>
                            <th style="width: 100px">
                                搭配值
                            </th>
                            <th style="width: 150px">
                                商品货号
                            </th>
                            <th>
                                库存
                            </th>
                        </tr>
                </HeaderTemplate>
                <ItemTemplate>
                    <tr>
                        <td style="height: 30px">
                            <asp:Label ID="AssembleValue" runat="server" Text='<%#Eval("AssembleValue")%>'></asp:Label>
                        </td>
                        <td style="height: 30px; width: 80px">
                            <asp:TextBox ID="AssembleNumber" runat="server" CssClass="input" Text='<%#Eval("Number")%>'></asp:TextBox>
                        </td>
                        <td>
                            <asp:TextBox ID="AssembleStock" runat="server" CssClass="input" Text='<%#Eval("Stock")%>'></asp:TextBox>
                        </td>
                    </tr>
                </ItemTemplate>
                <FooterTemplate>
                    </table>
                </FooterTemplate>
            </asp:Repeater>
        </div>
    </ContentTemplate>
    <Triggers>
        <asp:AsyncPostBackTrigger ControlID="AttributeAssemble" EventName="Click" />
        <asp:AsyncPostBackTrigger ControlID="ClearAssemble" EventName="Click" />
    </Triggers>
</asp:UpdatePanel>
