<%@ Page language="c#" Codebehind="ProductField.aspx.cs" AutoEventWireup="false" Inherits="XpShop.WebUI.Admin.ProductField" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<HTML>
	<HEAD>
	    <!--#include file="inc/head.inc"-->
		<title>ProductField</title>
		<script type="text/javascript">
			function advsearch()
			{
				if(document.Form1.cbAddToAdvSearch.checked)
				{
					document.getElementById("AdvSearch").style.display = "";
				}
				else
				{
					document.getElementById("AdvSearch").style.display = "none";
				}
			}
			function choice(obj)
			{
			    if(obj.id == 'chkChoice')
			    {
			        if(!obj.checked)
				    {
					    document.getElementById("cbAddToAdvSearch").checked = false;
					    document.getElementById("chkIsUseImg").checked = false;				    
					    document.getElementById("FieldValues").style.display = "";
				        document.getElementById("FileCollection").style.display = "none";
				        document.getElementById("btnAddFile").style.display = "none";
				        if(document.getElementById("dlAlreadyImgs")){
							document.getElementById("dlAlreadyImgs").style.display = "none";
						}
				    }
				}
				else
				{
				    if(obj.checked)
				    {
				        document.getElementById("FieldValues").style.display = "none";
				        document.getElementById("FileCollection").style.display = "";
				        document.getElementById("btnAddFile").style.display = "";
				        document.getElementById("chkChoice").checked = true;
				        if(document.getElementById("dlAlreadyImgs")){
							document.getElementById("dlAlreadyImgs").style.display = "";
						}
				    }
				    else
				    {
				        document.getElementById("FieldValues").style.display = "";
				        document.getElementById("FileCollection").style.display = "none";
				        document.getElementById("btnAddFile").style.display = "none";
				        if(document.getElementById("dlAlreadyImgs")){
							document.getElementById("dlAlreadyImgs").style.display = "none";
						}
				    }
				}
			}
			function addFileControl()
            {
                var str = "<br /><span>预设值：</span><span> <input name='txtFieldValue' type='text' style='width:50px;' /></span>" + 
                    "<span style='width:20px;'></span>" + 
                    "<span> 图片：</span><span> <input type='file' name='File' style='width:150px;' /></span>";
                document.getElementById('FileCollection').insertAdjacentHTML("beforeEnd",str)
            }  
        </script>
	</HEAD>
	<body>
	    <div class="container">
		<div class="sub_container">
		<div class="sub_container_title"><a href="../default.aspx" target="_blank">桌面</a><img src="images/admin_title.jpg" height=9px width=8px align="absmiddle" />
		    <% if(this.Request.QueryString["Action"] == "Manage"){%>管理扩展属性<%}if(this.Request.QueryString["Action"] == "Add" | this.Request.QueryString["Action"] == "Modify"){%>添加扩展属性<%}%>
		</div>
		<div class="sub_container_content">
		<form id="Form1" method="post" runat="server">
			<% if(this.Request.QueryString["Action"] == "Manage"){%>
			<div class="frame">
		        <div class="frame_title">扩展商品属性管理　　　　当设置用户可选后，系统将默认不能加入高级搜索　　　　<a href='ProductField.aspx?Action=Add'>返回到添加</a></div>
		        <div class="frame_content">
		            <table class="tableBorder" cellSpacing="1" cellPadding="1" width="100%" align="center" border="0"  id="Table2">
				        <tr>
					        <td class="forumRowHighlight">
					            <asp:datagrid id="dgCustomField" runat="server" Width="100%" HeaderStyle-CssClass="summary-title"
							        HorizontalAlign="Left" DataKeyField="ProductFieldID" AutoGenerateColumns="False" PagerStyle-Mode="NumericPages" AllowPaging="False">
							        <Columns>
								        <asp:TemplateColumn HeaderText="扩展商品属性" HeaderStyle-Width="80px" ItemStyle-Width="80px" ItemStyle-HorizontalAlign="Left"
									        HeaderStyle-HorizontalAlign="Left">
									        <HeaderStyle></HeaderStyle>
									        <ItemTemplate>
										        <%# DataBinder.Eval(Container.DataItem, "FieldName") %>
									        </ItemTemplate>
									        <EditItemTemplate>
										        <asp:TextBox ID="fieldName" Runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "FieldName") %>' Width="80px">
										        </asp:TextBox>
									        </EditItemTemplate>
								        </asp:TemplateColumn>
								        <asp:TemplateColumn HeaderText="所属类别" HeaderStyle-Width="100px" ItemStyle-Width="100px" ItemStyle-HorizontalAlign="Left" HeaderStyle-HorizontalAlign="Left">
									        <HeaderStyle></HeaderStyle>
									        <ItemTemplate>
										        <%# GetCategoryFieldName(int.Parse(DataBinder.Eval(Container.DataItem, "CategoryFieldID").ToString()))%>
									        </ItemTemplate>
								        </asp:TemplateColumn>
								        <asp:TemplateColumn HeaderText="高级搜索" HeaderStyle-Width="100px" ItemStyle-Width="100px" ItemStyle-HorizontalAlign="Center"
									        HeaderStyle-HorizontalAlign="Center">
									        <HeaderStyle></HeaderStyle>
									        <ItemTemplate>
										        <asp:CheckBox ID="cbxAddToAdvSearch" Runat="server" Checked='<%# DataBinder.Eval(Container.DataItem, "AddToAdvSearch").ToString() == "1" ? true : false %>' Text='加入高级搜索'>
										        </asp:CheckBox><br>
										        <asp:RadioButton ID="rbtNotMultiple" Runat="server" Checked='<%# DataBinder.Eval(Container.DataItem, "IsMultiple").ToString() == "0" ? true : false %>' GroupName='ChooseType' Text="单选">
										        </asp:RadioButton>
										        <asp:RadioButton ID="rbtIsMultiple" Runat="server" Checked='<%# DataBinder.Eval(Container.DataItem, "IsMultiple").ToString() == "1" ? true : false %>' GroupName='ChooseType' Text="多选">
										        </asp:RadioButton>
									        </ItemTemplate>
								        </asp:TemplateColumn>
								        <asp:TemplateColumn HeaderText="预设可选值" ItemStyle-HorizontalAlign="Left" HeaderStyle-HorizontalAlign="Left">
									        <HeaderStyle></HeaderStyle>
									        <ItemTemplate>
										        <%# DataBinder.Eval(Container.DataItem, "FieldValues") %>
									        </ItemTemplate>
									        <EditItemTemplate>
										        <asp:TextBox ID="fieldValues" Runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "FieldValues") %>' TextMode="MultiLine" Width="240px">
										        </asp:TextBox>
									        </EditItemTemplate>
								        </asp:TemplateColumn>
								        <asp:TemplateColumn HeaderText="用户是否可选" HeaderStyle-Width="100px" ItemStyle-Width="100px" ItemStyle-HorizontalAlign="Center"
									        HeaderStyle-HorizontalAlign="Center">
									        <HeaderStyle></HeaderStyle>
									        <ItemTemplate>
										        <asp:CheckBox ID="choice" Runat="server" Checked='<%# DataBinder.Eval(Container.DataItem, "IsChoice").ToString() == "1" ? true : false %>' Text='是'>
										        </asp:CheckBox>
									        </ItemTemplate>
								        </asp:TemplateColumn>
								        
                                        <asp:TemplateColumn HeaderText="管理" HeaderStyle-Width="30px" ItemStyle-Width="30px" ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center">
                                            <ItemTemplate>
                                                <a href='ProductField.aspx?Action=Add&ProductFieldID=<%# DataBinder.Eval(Container.DataItem, "ProductFieldID") %>'>修改</a>
                                            </ItemTemplate>
                                        </asp:TemplateColumn>
								        
								        <asp:ButtonColumn HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" HeaderText="删除"
									        HeaderStyle-Width="30px" ItemStyle-Width="30" CommandName="Delete" Text="&lt;div id=&quot;de&quot; onclick=&quot;javascript:return confirm('真的要删除吗？')&quot;&gt;删除&lt;/div&gt;"></asp:ButtonColumn>
							        </Columns>
						        </asp:datagrid></td>
				        </tr>
			        </table>
		        </div>
	        </div>
			<%}if(this.Request.QueryString["Action"] == "Add" | this.Request.QueryString["Action"] == "Modify"){%>
			    <div class="frame">
		        <div class="frame_title">扩展商品属性添加</div>
		        <div class="frame_content">
		            <table class="tableBorder" cellSpacing="1" cellPadding="1" width="100%" align="center" border="0" id="Table4">
				        <tr>
					        <td>
						        <table class="tableBorder" cellSpacing="0" cellPadding="0" width="95%" align="center" border="0"
							        id="Table5">
							        <tr>
								        <td align="right" width="150">扩展属性名称：
								        </td>
								        <td>
									        <asp:textbox id="txtFieldName" Width="150px" Runat="server"></asp:textbox>
								        </td>
							        </tr>
							        
							        <tr>
					                    <td align="right" width="150">所属类别：
					                    </td>
					                    <td valign="top" width="150">
					                        <asp:DropDownList id="ddlCategories" runat="server"></asp:DropDownList>
					                    </td>
					                </tr>
					                
							       
							        <tr>
							            <td align="right">设置用户是否可选：</td>
							            <td><asp:CheckBox id="chkChoice" runat="server" Text="是" onclick="choice(this);"></asp:CheckBox></td>
							        </tr>
							        <tr>
							            <td align="right">是否选用图片标识：</td>
							            <td><asp:CheckBox id="chkIsUseImg" runat="server" Text="是" onclick="choice(this);"></asp:CheckBox></td>
							        </tr>
							        <tr>
								        <td align="right" width="150">扩展属性预设值：
								        </td>
                                        <td>
                                            <span id='FieldValues'>
                                                <asp:TextBox ID="txtFieldValues" Width="300px" runat="server" TextMode="MultiLine" Height="50px"></asp:TextBox><br />
                                                <font face="宋体">
                                                        *预设值之间用英文状态下的“,”隔开，如：诺基亚,西门子,索尼爱立信<br />
                                                        *在填写扩展属性预设值时请不要使用“^”,“|”等特殊字符
                                                </font>
                                            </span>
                                            <p id="FileCollection">
                                                <span>预设值：</span>
                                                <span>
                                                    <input name='txtFieldValue' type='text' style='width:50px;' />
                                                </span>
                                                <span style='width:20px;'></span>
                                                <span >图片：</span>
                                                <span>
                                                    <input type='file' name='File' style='width:150px;' runat='server' />
                                                </span>
                                            </p>
                                        </td>
							        </tr>
							        <tr>
								        <td width="100"></td>
								        <td>
								            <input type='button' id="btnAddFile" onclick='addFileControl()' value='增加预设值' style='display:none' />
                                            <asp:DataGrid ID="dlAlreadyImgs" runat="server" Width="35%" DataKeyField="FieldValues" AutoGenerateColumns="False" HeaderStyle-CssClass="summary-title">
                                                <Columns>
                                                    <asp:TemplateColumn HeaderText="预设值" ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center">
                                                        <ItemTemplate >
                                                            <%# DataBinder.Eval(Container.DataItem, "FieldValues")%>
                                                        </ItemTemplate>
                                                    </asp:TemplateColumn>
                                                    <asp:TemplateColumn HeaderText="图片">
                                                        <ItemTemplate>
                                                            <a href='../upload/productFiled/<%# DataBinder.Eval(Container.DataItem, "FieldImgs") %>'
                                                                target="_blank">
                                                                <%# DataBinder.Eval(Container.DataItem, "FieldImgs")%>
                                                            </a>
                                                        </ItemTemplate>
                                                    </asp:TemplateColumn>
                                                    <asp:ButtonColumn ButtonType="LinkButton" HeaderText="删除" Text="删除" CommandName="Delete">
                                                    </asp:ButtonColumn>
                                                </Columns>
                                            </asp:DataGrid>
                                        </td>
							        </tr>
							         <tr>
								        <td align="right"><FONT face="宋体">高级搜索：</FONT></td>
								        <td>								    
									        <asp:CheckBox id="cbAddToAdvSearch" runat="server" Text="加入高级搜索"></asp:CheckBox>
									        <span id="AdvSearch" style="display: none">
										        <asp:RadioButton id="rbNotMultiple" runat="server" Text="单选" GroupName="MultiType" Checked="True"></asp:RadioButton>
										        <asp:RadioButton id="rbIsMultiple" runat="server" Text="多选" GroupName="MultiType"></asp:RadioButton>
									        </span><script language="javascript">advsearch();</script>									
								        </td>
							        </tr>
							        <script type="text/javascript">
                                        if(document.getElementById("chkIsUseImg").checked)
                                        {
                                            document.getElementById("FieldValues").style.display = "none";
                                            document.getElementById("FileCollection").style.display = "";
                                            document.getElementById("btnAddFile").style.display = "";
                                            if(document.getElementById("dlAlreadyImgs")){
												document.getElementById("dlAlreadyImgs").style.display = "";
											}
                                        }
                                        else
                                        {
                                            document.getElementById("FieldValues").style.display = "";
                                            document.getElementById("FileCollection").style.display = "none";
                                            document.getElementById("btnAddFile").style.display = "none";
                                            if(document.getElementById("dlAlreadyImgs")){
												document.getElementById("dlAlreadyImgs").style.display = "none";
											}
                                        }
                                    </script>
							        <tr>
								        <td><br /><br /></td>
								        <td><asp:button id="btnSubmit" runat="server" Text="提交"></asp:button><FONT face="宋体">&nbsp;</FONT>
									        <asp:button id="btnCancel" runat="server" Text="取消"></asp:button></td>
							        </tr>
						        </table>
					        </td>
				        </tr>
			        </table>
		        </div>
	        </div>
			<%}%>
		</form>
		</div>
		</div>
		</div>
	</body>
</HTML>
