<%@ Page Language="C#" MasterPageFile="MasterPage.Master" AutoEventWireup="true" CodeBehind="StandardAdd.aspx.cs" Inherits="SocoShop.Web.Admin.StandardAdd" %>
<%@ Register Namespace="SkyCES.EntLib" Assembly="SkyCES.EntLib" TagPrefix="SkyCES"%>
<%@ Import Namespace="SocoShop.Common" %>
<%@ Import Namespace="SocoShop.Entity" %>
<%@ Import Namespace="SocoShop.Business" %>
<asp:Content ID="MasterContent" ContentPlaceHolderID="ContentPlaceHolder" runat="server">
<script type="text/javascript" src="/Admin/Pop/lhgdialog_ex.js"></script>
<div class="position"><img src="/Admin/Style/Images/PositionIcon.png"  alt=""/>规格<%=ShopCommon.GetAddUpdate()%></div>
<div class="add"> 
	<ul>
		<li class="left">规格名称：</li>
		<li class="right"><SkyCES:TextBox ID="Name" CssClass="input" runat="server" Width="400px" /></li>
	</ul>
	<ul>
		<li class="left">显示方式：</li>
		<li class="right"><asp:RadioButtonList ID="DisplayTye" runat="server" RepeatDirection="Horizontal" onclick="selectType()" ></asp:RadioButtonList></li>
	</ul>
</div>
<div class="add">
    <ul>
		<li class="standardTitle">规格值 <img src="Style/Images/add.gif" style="vertical-align:bottom; cursor:pointer" title="添加" onclick="addStandard()" /></li>
	</ul>
	<table cellpadding="0" cellspacing="0" border="0" width="100%"  class="tableList" id="standardTable">
	    <tr class="tableHead">
            <td style="width:30%" id="NameColunm">规格值</td>
	        <td style="width:50%" id="PhotoColunm">图片</td>        
	        <td style="width:20%">管理</td>
	    </tr>
	    <% int i=0;if (standard.ValueList != string.Empty && standard.PhotoList != string.Empty){
            string[] valueArray = standard.ValueList.Split(',');
            string[] photoArray = standard.PhotoList.Split(',');
            for (i = 0; i < valueArray.Length; i++){        
            %>
	    <tr class="tableMain" id="standard<%=i %>">
	        <td style="width:30%" id="NameColunm<%=i %>"><input name="ValueList" class="input" type="text" style="width:100px" value="<%=valueArray[i] %>" /></td>
	        <td style="width:50%" id="PhotoColunm<%=i %>"><input name="PhotoList" type="hidden"  id="ctl00_ContentPlaceHolder_PhotoList<%=i %>" onpropertyChange="showPhoto(<%=i %>,this.value)" value="<%=photoArray[i]%>" /><img src="<%=photoArray[i].Replace("Original","25-25") %>" id="Photo<%=i%>" width="25" height="25"/>  <iframe src="UploadAdd.aspx?Control=PhotoList<%=i %>&TableID=<%=StandardBLL.TableID%>&FilePath=StandardPhoto/Original" width="300" height="30px" frameborder="0" allowTransparency="true" scrolling="no"></iframe></td>        
	        <td style="width:20%"><img src="Style/Images/delete.gif" alt="删除" onclick="deleteStandard(<%=i %>)" style="cursor:pointer" /></td>
	    </tr>
	    <%}} %>	    
	</table>
	<input type="hidden" id="StandardCount" value="<%=i %>" />
</div>
<div class="action">
    <asp:Button CssClass="button" ID="SubmitButton" Text=" 确 定 " runat="server"  OnClick="SubmitButton_Click" />
</div>
<script language="javascript" type="text/ecmascript">
    function deleteStandard(i){
        removeSelf(o("standard"+i));
    }
    function showPhoto(i,value){
        o("Photo"+i).src=value.replace("Original", "25-25");
    }
    function addStandard(){
         var standardCount=parseInt(o("StandardCount").value);
         o("StandardCount").value=standardCount+1;
         var objRow = standardTable.insertRow(standardTable.rows.length);
         objRow.className = "tableMain";
         objRow.id="standard"+standardCount;
         
         var objCel = objRow.insertCell(0);
         objCel.style.width="30%";
         objCel.id="NameColunm"+standardCount;
         objCel.innerHTML = "<input name=\"ValueList\" class=\"input\" type=\"text\" style=\"width:100px\" value=\"\" />";
         
         objCel = objRow.insertCell(1);
         objCel.style.width="50%";
         objCel.id="PhotoColunm"+standardCount;
         var displayTye=getRadioValue(os("name","ctl00$ContentPlaceHolder$DisplayTye"));
         if(displayTye=="1"){
            objCel.style.display="none";
         }
         objCel.innerHTML = "<input name=\"PhotoList\" type=\"hidden\"  id=\"ctl00_ContentPlaceHolder_PhotoList"+standardCount+"\" onpropertyChange=\"showPhoto("+standardCount+",this.value)\" value=\"\" /><img src=\"\" id=\"Photo"+standardCount+"\"  width=\"25\" height=\"25\"/>  <iframe src=\"UploadAdd.aspx?Control=PhotoList"+standardCount+"&TableID=<%=StandardBLL.TableID%>&FilePath=StandardPhoto/Original\" width=\"300\" height=\"30px\" frameborder=\"0\" allowTransparency=\"true\" scrolling=\"no\"></iframe>";
         
         objCel = objRow.insertCell(2);
         objCel.style.width="20%";
         objCel.innerHTML = "<img src=\"Style/Images/delete.gif\" alt=\"删除\" onclick=\"deleteStandard("+standardCount+")\" style=\"cursor:pointer\" />";  
    }
    function selectType(){
        var displayTye=getRadioValue(os("name","ctl00$ContentPlaceHolder$DisplayTye"));
        var standardCount=parseInt(o("StandardCount").value);
        if(displayTye=="1"){
             o("NameColunm").style.width="80%";
             o("PhotoColunm").style.display="none";
             for(var i=0;i<standardCount;i++){
                 o("NameColunm"+i).style.width="80%";
             }
              for(var i=0;i<standardCount;i++){
                 o("PhotoColunm"+i).style.display="none";
             }
        }
        else{
             o("NameColunm").style.width="30%";
             o("PhotoColunm").style.display="";
             for(var i=0;i<standardCount;i++){
                 o("NameColunm"+i).style.width="30%";
             }
             for(var i=0;i<standardCount;i++){
                 o("PhotoColunm"+i).style.display="";
             }
        }
    }
    selectType();
</script>
</asp:Content>
