<%@ Page language="c#" Codebehind="ProductCustomField.aspx.cs" AutoEventWireup="false" Inherits="wqeshop.Admin.ProductCustomField" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
	<HEAD>
		<title>ProductCustomField</title>
		<LINK href="inc/style.css" type="text/css" rel="stylesheet"></LINK>
		<script language="javascript">
			function selectType()
			{
				if(document.Form1.ddlTypes.value == "1")
				{
					eval("type1" + ".style.display=\"\";");
					eval("type2" + ".style.display=\"none\";");
				}
				else
				{
					eval("type1" + ".style.display=\"none\";");
					eval("type2" + ".style.display=\"\";");
				}
			}
			function newCustomField()
			{
				if(document.Form1.ddlCustomFieldNames.value == "0")
				{
					eval("newFieldName" + ".style.display=\"\";");
				}
				else
				{
					eval("newFieldName" + ".style.display=\"none\";");
				}
			}
			
			function finish()
			{
				window.close();
				opener.focus();
			}
		</script>
	</HEAD>
	<body>
		<form id="Form1" method="post" runat="server">
			<table class="tableBorder" cellSpacing="0" cellPadding="0" width="640" align="center" border="0">
				<tr>
					<th class="tableHeaderText" align="left" height="25">
						&nbsp;&nbsp; 扩展项管理</th>
					<th class="tableHeaderText" align="right">
						<a href="http://www.wangqi.com" target="_blank"><img src="Images/admin_help.gif" border="0" alt="帮助"></a>&nbsp;
					</th>
				<tr>
				</tr>
			</table>
			<table class="tableBorder" cellSpacing="1" cellPadding="1" width="640" align="center" border="0">
				<tr>
					<td class="forumRowHighlight"><asp:datagrid id="dgCustomField" runat="server" Width="100%" HeaderStyle-CssClass="summary-title"
							HorizontalAlign="Left" DataKeyField="ProductCustomFieldID" AutoGenerateColumns="False" PagerStyle-Mode="NumericPages"
							AllowPaging="False">
							<Columns>
								<asp:TemplateColumn HeaderText="扩展属性名" HeaderStyle-Width="80px" ItemStyle-Width="80px" ItemStyle-HorizontalAlign="Left"
									ItemStyle-VerticalAlign="Top" HeaderStyle-HorizontalAlign="Left">
									<HeaderStyle></HeaderStyle>
									<ItemTemplate>
										<asp:TextBox ID="CustomField" Runat="server" Width="80px" Text='<%# DataBinder.Eval(Container.DataItem, "FieldName") %>'>
										</asp:TextBox>
									</ItemTemplate>
								</asp:TemplateColumn>
								<asp:TemplateColumn HeaderText="多选" HeaderStyle-Width="30px" ItemStyle-Width="30" ItemStyle-HorizontalAlign="Center"
									ItemStyle-VerticalAlign="Top" HeaderStyle-HorizontalAlign="Center">
									<HeaderStyle></HeaderStyle>
									<ItemTemplate>
										<asp:CheckBox ID="isMultiple" Runat="server" Checked='<%# DataBinder.Eval(Container.DataItem, "Multiple").ToString() == "1" ? true : false %>'>
										</asp:CheckBox>
									</ItemTemplate>
								</asp:TemplateColumn>
								<asp:TemplateColumn Visible="False" HeaderText="数量" HeaderStyle-Width="30px" ItemStyle-Width="30" ItemStyle-HorizontalAlign="Center"
									ItemStyle-VerticalAlign="Top" HeaderStyle-HorizontalAlign="Center">
									<HeaderStyle></HeaderStyle>
									<ItemTemplate>
										<asp:CheckBox ID="isCountable" Runat="server" Checked='<%# DataBinder.Eval(Container.DataItem, "Countable").ToString() == "1" ? true : false %>'>
										</asp:CheckBox>
									</ItemTemplate>
								</asp:TemplateColumn>
								<asp:TemplateColumn HeaderText="属性值" ItemStyle-HorizontalAlign="Left" HeaderStyle-HorizontalAlign="Left"
									ItemStyle-VerticalAlign="Top">
									<HeaderStyle></HeaderStyle>
									<ItemTemplate>
										<table width="100%" cellpadding="0" cellspacing="0" border="0">
											<asp:Repeater ID="rptFieldItems" Runat="server" DataSource='<%# GetFieldItems(DataBinder.Eval(Container.DataItem, "ProductCustomFieldID").ToString()) %>'>
												<ItemTemplate>
													<tr>
														<td width="20px"><%# Container.ItemIndex + 1 %>
															)</td>
														<td><%# DataBinder.Eval(Container.DataItem, "ItemName") %></td>
														<td width="100px">价格：<%# DataBinder.Eval(Container.DataItem, "Price") %></td>
														<td width="50px"><a href='Actions.aspx?Action=DeleteFieldItem&ItemID=<%# DataBinder.Eval(Container.DataItem, "CustomFieldItemID") %>&pid=<%=Request.QueryString["productid"]%>'>删除</a></td>
													</tr>
												</ItemTemplate>
											</asp:Repeater>
										</table>
									</ItemTemplate>
								</asp:TemplateColumn>
								<asp:ButtonColumn HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" HeaderText="操作"
									ItemStyle-VerticalAlign="Top" HeaderStyle-Width="30px" ItemStyle-Width="30" ButtonType="LinkButton"
									CommandName="Update" Text="修改"></asp:ButtonColumn>
								<asp:ButtonColumn HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" HeaderText="删除"
									ItemStyle-VerticalAlign="Top" 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>
			<table class="tableBorder" cellSpacing="0" cellPadding="0" width="640" align="center" border="0">
				<tr>
					<th class="tableHeaderText" align="left" height="25">
						&nbsp;&nbsp; 扩展项添加</th>
					<th class="tableHeaderText" align="right">
						<a href="http://www.wangqi.com" target="_blank"><img src="Images/admin_help.gif" border="0" alt="帮助"></a>&nbsp;
					</th>
				<tr>
				</tr>
			</table>
			<table class="tableBorder" cellSpacing="1" cellPadding="1" width="640" align="center" border="0">
				<tr>
					<td>
						<table class="tableBorder" cellSpacing="0" cellPadding="0" width="95%" align="center" border="0">
							<tr>
								<td align="right" width="150">扩展属性：
								</td>
								<td><asp:dropdownlist id="ddlCustomFieldNames" runat="server"></asp:dropdownlist><SPAN id="newFieldName" style="DISPLAY: none"><asp:textbox id="txtNewFieldName" Width="120px" Runat="server"></asp:textbox>
										<br>
										<asp:checkbox id="cbxMultiple" Runat="server" Text="多选"></asp:checkbox>
										<asp:checkbox id="cbxCountable" Runat="server" Text="允许多数量"></asp:checkbox>
									</SPAN>
									<script language="javascript">newCustomField();</script>
								</td>
							</tr>
							<tr>
								<td align="right" width="150" height="3">添加配件方式：
								</td>
								<td height="3"><asp:DropDownList ID="ddlTypes" Runat="server" AutoPostBack="True">
										<asp:ListItem Value="1">添加新配件</asp:ListItem>
										<asp:ListItem Value="2">已有库中选择配件</asp:ListItem>
									</asp:DropDownList></td>
							</tr>
							<asp:Panel ID="pnlType1" Runat="server">
								<TR>
									<TD align="right" width="150">扩展属性值：
									</TD>
									<TD>
										<asp:textbox id="txtNewFieldValue" Width="100px" Runat="server"></asp:textbox></TD>
								</TR>
								<TR>
									<TD align="right" width="150">价格：
									</TD>
									<TD>
										<asp:textbox id="txtPrice" Width="100px" Runat="server">0</asp:textbox></TD>
								</TR>
								<TR>
									<TD align="right" width="150" height="15">默认选择：
									</TD>
									<TD height="15">
										<asp:checkbox id="cbxSelected" Runat="server"></asp:checkbox>
										<asp:textbox id="txtShopProductID" Width="100px" Runat="server" Visible="False">0</asp:textbox></TD>
								</TR>
							</asp:Panel>
							<asp:Panel ID="pnlType2" Runat="server" Visible="False">
								<TR>
									<TD align="right" width="150">配件库：
									</TD>
									<TD>
										<asp:CheckBoxList id="cblItems" Runat="server" RepeatColumns="2"></asp:CheckBoxList></TD>
								</TR>
							</asp:Panel>
							<tr>
								<td></td>
								<td><asp:button id="btnSubmit" runat="server" Text="提交"></asp:button></td>
							</tr>
						</table>
					</td>
				</tr>
			</table>
			<table align="center">
				<tr>
					<td><input type="button" value="完成设置" onclick="finish();"></td>
				</tr>
			</table>
		</form>
	</body>
</HTML>
