<%@ Page Language="C#" MasterPageFile="~/admin/admin_page.master" AutoEventWireup="true"
    CodeBehind="product_batch_edit.aspx.cs" Inherits="YXShop.Web.admin.product.product_batch_edit" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <link rel="stylesheet" href="../style/validator.css" type="text/css" />

    <script type="text/javascript" src="../../scripts/validate.js"></script>

    <link rel="stylesheet" href="../style/toolbar.css" type="text/css" />

    <script src="../scripts/public.js" type="text/javascript"></script>

    <script src="../scripts/images.js" type="text/javascript"></script>

    <script type="text/javascript" src="../../scripts/calendar.js"></script>

    <script type="text/javascript">
    function SearchProduct()
    {
        var productName=document.getElementById("<%=txtProductName.ClientID %>").value;
        var productCId=document.getElementById("<%=hfcid.ClientID %>").value;
        var productBrandId=document.getElementById("<%=ddlProductBrand.ClientID %>").value;
        var productNo=document.getElementById("<%=txtProductNO.ClientID %>").value;
        var param = "Option=SearchProduct&productCId="+productCId+"&productNo="+productNo+"&productBrandId="+productBrandId+"&Name="+ productName;
        var options={
            method:'post',
            parameters:param,
            onComplete:
            function(transport)
	        {
                 var retv=transport.responseText;
                 document.getElementById("divSeleted").innerHTML=retv;
		    }     
	      }
	    new  Ajax.Request('product_batch_edit.aspx',options);
    }
    //添加选中的项目
    function AddItem(sel,seled)
    {   
       var selectItemID=document.getElementById(sel).options.selectedIndex;
       var selectItemValue=document.getElementById(sel).options;
       var Selected=document.getElementById(seled);
       
       if  (selectItemID!=-1)
       {        
            for(var i = 0,j=0; i < selectItemValue.length,j<selectItemValue.length; i++) 
            {
              if(selectItemValue[i].selected)
               {
                    var exist=false;
                    for(var k = 0; k < Selected.options.length; k++) 
                    {
                        if(Selected.options[k].value == selectItemValue[i].value) 
                        {
                            exist=true;
                            break;
                        }
                    }
                    if  (exist==false)
                    {  
                        Selected.options.add(new Option(selectItemValue[i].text, selectItemValue[i].value, true,true)); 
                        j++;
                    }
                }
            }
       }
    }
    //全部添加
    function AddAllItem(sel,seled)
    {
        //备选项列表
        var selectItemValue=document.getElementById(sel).options;
        //已列表
        var Selected=document.getElementById(seled);
        for(var i = 1,j = 0; i < selectItemValue.length,j < selectItemValue.length; i++) 
        {           
            var exist=false;
            for(var k = 0; k < Selected.options.length; k++) 
            {
                if(Selected.options[k].value == selectItemValue[i].value) 
                {
                    exist=true;
                    break;
                }
            }
            if  (exist==false)
            {  
                Selected.options.add(new Option(selectItemValue[i].text, selectItemValue[i].value, true,true)); 
                j++;
            }
        }
    }
    //移除所选项
    function DelItem(selName)
    {
        var Selected=document.getElementById(selName).options;
        for(var i = 0; i < Selected.length; i++) 
        {        
            if(Selected[i].selected==true)
            {
                Selected.remove(i);
            }
        }
    }

    //移除所有已经选择好的项目
    function DelAllItem(selName)
    {
        var colls = [];       //对select标记options的引用
        var selectTag = document.getElementById(selName); //获取select标记        
        colls = selectTag.options; //获取引用
        if(colls.length > 0)
        {
             clearOptions(colls);
        }   
    }
    //清空options集合
    function clearOptions(colls)
    {
        var length = colls.length;
        for(var i=length-1;i>=0;i--)
        {
               colls.remove(i);
        }
    }
    function isSubmit()
    {
        var productId=document.getElementById("Selects").value;
        var field=document.getElementById("SelRequiredField").value;
        if(productId=="")
        {
            alert("请选择您要批量修改的商品！");
            return false;
        }
        if(field=="")
        {
            alert("请选择您要批量修改的字段！");
            return false;
        }
    }
    </script>

</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="pagetitle" runat="server">
    批量编辑商品
    <asp:Button ID="butEdit" runat="server" CssClass="inputbutton" Text="进入编辑" onMouseOver="javascript:document.getElementById(this.id).className='inputbutton_a'"
        
        onMouseOut="javascript:document.getElementById(this.id).className='inputbutton'" 
        onclick="butEdit_Click" OnClientClick="return isSubmit()"  />
    <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl="product_list.aspx" CssClass="inputbutton"
        Width="65px" Height="24px" onMouseOver="javascript:document.getElementById(this.id).className='inputbutton_a'"
        onMouseOut="javascript:document.getElementById(this.id).className='inputbutton'">返回列表</asp:HyperLink>
</asp:Content>
<asp:Content ID="ContentMain" runat="server" ContentPlaceHolderID="workspace">
    <table class="form_table_input" border="0" cellpadding="0" cellspacing="0">
        <tr>
            <td class="form_table_input_info">
                选择商品分类：
            </td>
            <td>
                <asp:TextBox ID="txtProductClass" runat="server" Text="请选择..." CssClass="inputCSS"></asp:TextBox>
                <asp:HiddenField runat="server" ID="hfcid" />
            </td>
            <td class="form_table_input_info">
                选择商品品牌：
            </td>
            <td>
                <asp:DropDownList ID="ddlProductBrand" runat="server">
                </asp:DropDownList>
            </td>
            <td>
            </td>
        </tr>
        <tr>
            <td align="right" class="form_table_input_info">
                商品名称：
            </td>
            <td>
                <asp:TextBox ID="txtProductName" runat="server"></asp:TextBox>
            </td>
            <td align="right" class="form_table_input_info">
                商品货号：
            </td>
            <td>
                <asp:TextBox ID="txtProductNO" runat="server"></asp:TextBox>
            </td>
            <td>
                <input type="button" value="查询" onclick="SearchProduct()" />
            </td>
        </tr>
        <tr>
            <td colspan="2">
                待选列表
                <div id="divSeleted">
                    <select size="14" id="Seleted" style="width: 98%">
                    </select>
                </div>
            </td>
            <td>
                <input type="button" style="width: 60%" value=">>>" onclick="AddAllItem('Seleted','Selects');" />
                <br />
                <br />
                <br />
                <input type="button" style="width: 60%" value=">" onclick="AddItem('Seleted','Selects');" />
                <br />
                <br />
                <br />
                <input type="button" style="width: 60%" value="<<<" onclick="DelAllItem('Selects');" />
                <br />
                <br />
                <br />
                <input type="button" style="width: 60%" value="<" onclick="DelItem('Selects');" />
            </td>
            <td colspan="2">
                选定列表
                <div id="divSeletes">
                    <asp:Literal ID="ltProductSelected" runat="server"></asp:Literal>
                </div>
            </td>
        </tr>
        <tr>
            <td class="form_table_input_info">需要编辑的字段</td>
            <td colspan="4"></td>
        </tr>
        <tr>
            <td colspan="5">
                <select size="14" id="SelRequiredField" name="SelRequiredField" style="width: 50%" multiple="multiple">
                    <option value="1">商品品牌</option>
                    <option value="2">计量单位</option>
                    <option value="3">商品重量</option>
                    <option value="4">是否上架销售</option>
                    <option value="5">上架时间</option>
                    <option value="6">下架时间</option>
                    <option value="7">上架数量</option>
                    <option value="8">赠送积分</option>
                    <option value="9">市场价格</option>
                    <option value="10">商品成本价</option>
                    <option value="11">报警数量</option>
                    <option value="12">内容模板</option>
                    <option value="13">商品标签</option>
                    <option value="14">商品标识</option>
                    <option value="15">库存</option>
                    <option value="16">积分购买额度</option>
                    <option value="17">销售价格</option>
                    <option value="18">商品简介</option>
                    <option value="19">详细介绍</option>
                    <option value="20">所属地区</option>
                </select>
            </td>
        </tr>
    </table>
</asp:Content>
<asp:Content ContentPlaceHolderID="pagebottom" runat="server" ID="contentBottom">
    <asp:Button ID="Button2" runat="server" CssClass="inputbutton" Text="进入编辑" onMouseOver="javascript:document.getElementById(this.id).className='inputbutton_a'"
        
        onMouseOut="javascript:document.getElementById(this.id).className='inputbutton'" 
        onclick="butEdit_Click" OnClientClick="return isSubmit()" />
</asp:Content>
