<%@ Page language="c#" Codebehind="Coupon.aspx.cs" AutoEventWireup="false" Inherits="XpShop.WebUI.Admin.Coupon" %>
<!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>Coupon</title>
		<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
		<meta name="CODE_LANGUAGE" Content="C#">
		<meta name="vs_defaultClientScript" content="JavaScript">
		<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
		<script language="javascript" src="../inc/calendar.js"></script>
	</HEAD>
	<body MS_POSITIONING="GridLayout">
	    <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" ){%>优惠券添加<%}%>
		</div>
		<div class="sub_container_content">
		<form id="Form1" method="post" runat="server">
		    <div class="frame">
		        <div class="frame_title"><asp:Label id="lblAction" runat="server"></asp:Label></div>
		        <div class="frame_content">
		            <% if(this.Request.QueryString["Action"] == "Manage"){%>
		            <table class="tableBorder" cellSpacing="0" cellPadding="0" width="98%" align="center" border="0">
			            <tr>
				            <td align="right">关键字：</td>
				            <td><asp:dropdownlist id="ddlKeyType" Runat="server">
								            <asp:ListItem Selected="True" Value="Account">优惠券内码</asp:ListItem>
								            <asp:ListItem Value="MemberName">换礼会员帐户</asp:ListItem></asp:dropdownlist>
							            <asp:TextBox id="txtkey" runat="server"></asp:TextBox>
							            <asp:Button ID="btnSerach" Runat="server" Text="查询"></asp:Button></td>
			            </tr>
		            </table>
		            <table class="tableBorder" cellSpacing="0" cellPadding="0" width="98%" align="center" border="0">
			            <tr>
				            <td height="23" class="forumRowHighlight">
					            <asp:datagrid id="dgCoupon" runat="server" AllowPaging="True" PageSize="10" PagerStyle-Mode="NumericPages"
						            AutoGenerateColumns="False" DataKeyField="CouponID" Width="100%" HorizontalAlign="Center"
						            HeaderStyle-CssClass="summary-title">
						            <HeaderStyle Font-Bold="True"></HeaderStyle>
						            <Columns>
							            <asp:TemplateColumn HeaderText="礼券编号">
								            <HeaderStyle HorizontalAlign="Left"></HeaderStyle>
								            <ItemStyle HorizontalAlign="Left"></ItemStyle>
								            <ItemTemplate>
									            <%# DataBinder.Eval(Container.DataItem, "CouponID") %>
								            </ItemTemplate>
							            </asp:TemplateColumn>
							            <asp:TemplateColumn HeaderText="礼券名称">
								            <HeaderStyle HorizontalAlign="Left"></HeaderStyle>
								            <ItemStyle HorizontalAlign="Left"></ItemStyle>
								            <ItemTemplate>
									            <%# DataBinder.Eval(Container.DataItem, "Name") %>
								            </ItemTemplate>
							            </asp:TemplateColumn>
							            <asp:TemplateColumn HeaderText="礼券类型">
								            <HeaderStyle HorizontalAlign="Left"></HeaderStyle>
								            <ItemStyle HorizontalAlign="Left"></ItemStyle>
								            <ItemTemplate>
									            <%# DataBinder.Eval(Container.DataItem, "Type").ToString() == "1" ? "折扣礼券" : "代金礼券" %>
								            </ItemTemplate>
							            </asp:TemplateColumn>
							            <asp:TemplateColumn HeaderText="礼券内码">
								            <HeaderStyle HorizontalAlign="Left"></HeaderStyle>
								            <ItemStyle HorizontalAlign="Left"></ItemStyle>
								            <ItemTemplate>
									            <%# DataBinder.Eval(Container.DataItem, "Account") %>
								            </ItemTemplate>
							            </asp:TemplateColumn>
							            <asp:TemplateColumn HeaderText="优惠内容">
								            <HeaderStyle HorizontalAlign="Left"></HeaderStyle>
								            <ItemStyle HorizontalAlign="Left"></ItemStyle>
								            <ItemTemplate>
									            <%# DataBinder.Eval(Container.DataItem, "Price") %><%# DataBinder.Eval(Container.DataItem, "Type").ToString() == "1" ? "折" : "元"%>
								            </ItemTemplate>
							            </asp:TemplateColumn>
							            <asp:TemplateColumn HeaderText="最低消费金额">
								            <HeaderStyle HorizontalAlign="Left"></HeaderStyle>
								            <ItemStyle HorizontalAlign="Left"></ItemStyle>
								            <ItemTemplate>
									            <%# DataBinder.Eval(Container.DataItem, "LowestConsumption") %>
								            </ItemTemplate>
							            </asp:TemplateColumn>
							            <asp:TemplateColumn HeaderText="过期时间">
								            <HeaderStyle HorizontalAlign="Left"></HeaderStyle>
								            <ItemStyle HorizontalAlign="Left"></ItemStyle>
								            <ItemTemplate>
									            <%# GetExpireInfo(DataBinder.Eval(Container.DataItem, "ExpireDate").ToString()) %>
								            </ItemTemplate>
							            </asp:TemplateColumn>
							            <asp:TemplateColumn HeaderText="与会员折扣同用">
								            <HeaderStyle HorizontalAlign="Left"></HeaderStyle>
								            <ItemStyle HorizontalAlign="Left"></ItemStyle>
								            <ItemTemplate>
									            <%#DataBinder.Eval(Container.DataItem, "Memberdiscount") %>
								            </ItemTemplate>
							            </asp:TemplateColumn>
							            <asp:TemplateColumn HeaderText="兑换过期时间">
								            <HeaderStyle HorizontalAlign="Left"></HeaderStyle>
								            <ItemStyle HorizontalAlign="Left"></ItemStyle>
								            <ItemTemplate>
									            <%# DataBinder.Eval(Container.DataItem, "ExchangeExpireDate", "{0:d}")%>
								            </ItemTemplate>
							            </asp:TemplateColumn>
							            <asp:TemplateColumn HeaderText="发放方式">
								            <HeaderStyle HorizontalAlign="Left"></HeaderStyle>
								            <ItemStyle HorizontalAlign="Left"></ItemStyle>
								            <ItemTemplate>
									            <%# DataBinder.Eval(Container.DataItem, "CouponType").ToString() == "1" ? "兑换" : "派发"%>
								            </ItemTemplate>
							            </asp:TemplateColumn>
							            <asp:TemplateColumn HeaderText="发放数量">
								            <HeaderStyle HorizontalAlign="Left"></HeaderStyle>
								            <ItemStyle HorizontalAlign="Left"></ItemStyle>
								            <ItemTemplate>
									            <%# DataBinder.Eval(Container.DataItem, "CouponCount")%>
								            </ItemTemplate>
							            </asp:TemplateColumn>
                                        <asp:TemplateColumn HeaderText="已兑换">
                                            <HeaderStyle HorizontalAlign="Left" />
                                            <ItemStyle HorizontalAlign="Left" />
                                            <ItemTemplate>
                                                <%# DataBinder.Eval(Container.DataItem, "ReadyExchangeCount")%>
                                            </ItemTemplate>
                                        </asp:TemplateColumn>
							            <asp:TemplateColumn HeaderText="备注">
								            <HeaderStyle HorizontalAlign="Left"></HeaderStyle>
								            <ItemStyle HorizontalAlign="Left"></ItemStyle>
								            <ItemTemplate>
									            <%# DataBinder.Eval(Container.DataItem, "Remake")%>
								            </ItemTemplate>
							            </asp:TemplateColumn>
							            <asp:TemplateColumn HeaderText="礼券小图">
								            <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
								            <ItemStyle HorizontalAlign="Center"></ItemStyle>
								            <ItemTemplate>
									            <img src='../Upload/CouponPic/<%#DataBinder.Eval(Container.DataItem,"ThumbnailImg")%>' width="70">
								            </ItemTemplate>
							            </asp:TemplateColumn>
							            <asp:ButtonColumn Text="&lt;div id=&quot;de&quot; onclick=&quot;javascript:return confirm('Are you sure you want to delete？')&quot;&gt;Delete&lt;/div&gt;"
								            CommandName="Delete">
								            <ItemStyle HorizontalAlign="Center" Width="30px"></ItemStyle>
							            </asp:ButtonColumn>
						            </Columns>
						            <PagerStyle Mode="NumericPages"></PagerStyle>
					            </asp:datagrid>
					            <TABLE id="tablePage" cellSpacing="0" cellPadding="0" width="100%" align="center">
						            <TR>
							            <TD vAlign="middle"><asp:label id="lblPager" Runat="server"></asp:label></TD>
							            <TD vAlign="middle" align="right"><INPUT id="controlID" type="hidden" name="controlID" runat="server">
								            <asp:textbox id="txtPage" Runat="server" Width="30px" BorderColor="Black" BackColor="White" BorderWidth="1px"></asp:textbox>&nbsp;&nbsp;
								            <asp:button id="btnJump" Runat="server" Text=" Go "></asp:button></TD>
						            </TR>
					            </TABLE>
				            </td>
			            </tr>
		            </table>
		            <%}if(this.Request.QueryString["Action"] == "Add" ){%>
		            <table class="tableBorder" cellSpacing="1" cellPadding="1" width="100%" align="center" border="0">
			            <tr>
				            <td>
					            <table class="tableBorder" cellSpacing="0" cellPadding="0" width="95%" align="center" border="0">
						            <tr>
							            <td  align="right" width="120px">礼券名称：</td>
							            <td>
								            <asp:TextBox id="txtName" runat="server" Width="150px"></asp:TextBox><font color="red">*</font>打折优惠券，价格优惠券</td>
						            </tr>
            						
						            <tr>
							            <td align="right" width="120px">发放方式：
							            </td>
							            <td><asp:dropdownlist id="ddlGrantType" runat="server">
									            <asp:ListItem Value="1">兑换</asp:ListItem>
									            <asp:ListItem Value="2">派发</asp:ListItem>
							            </asp:dropdownlist></td>
						            </tr>
            						
						            <tr id="Integral">
							            <td  align="right" width="120px">兑换积分：
							            </td>
							            <td><asp:textbox id="txtIntegral" runat="server" Width="150px">0</asp:textbox></td>
						            </tr>
						            <tr id="Count">
							            <td  align="right" width="120px">发放数量：
							            </td>
							            <td><asp:textbox id="txtCount" runat="server" Width="50px"></asp:textbox><font color="red">*</font></td>
						            </tr>
						            <tr id="ExchangeExpireDate">
							            <td  align="right" width="120px">兑换过期时间：
							            </td>
                                        <td>
                                            <asp:TextBox ID="txtExchangeExpireDate" runat="server"></asp:TextBox><a onmouseover="window.status='Date Picker';return true;"
                                                onmouseout="window.status='';return true;" href="javascript:show_calendar('Form1.txtExchangeExpireDate');"
                                                border="0"><img src="../images/imgbtn_Date.jpg" align="absMiddle" border="0"></a><font color="red">*</font></td>
						            </tr>
						            <tr id="MemberNames" style="display:none;">
							            <td  align="right" width="120px">会员名称：
							            </td>
							            <td><asp:textbox id="txtMemberNames" runat="server" Width="300px"></asp:textbox><br />
							                输入会员名，多个会员请用逗号分隔
							            </td>
						            </tr>
						            <tr>
							            <td  align="right" width="120px">使用过期时间：</td>
							            <td>
								            <asp:TextBox id="txtExpireDate" runat="server"></asp:TextBox><a onmouseover="window.status='Date Picker';return true;"
                                                onmouseout="window.status='';return true;" href="javascript:show_calendar('Form1.txtExpireDate');"
                                                border="0"><img src="../images/imgbtn_Date.jpg"
                                                    align="absMiddle" border="0" /></a><font color="red">*</font></td>
						            </tr>
						            <script type="text/javascript">
							            function SetThumbnailLee()
							            {
							                if(document.Form1.ddlGrantType.value=="2")
							                {
								                document.getElementById('Integral').style.display="none";
								                document.getElementById('ExchangeExpireDate').style.display="none";
								                document.getElementById('MemberNames').style.display="";
								                document.getElementById('Count').style.display="none";
							                }
							                else
							                {
							                   document.getElementById('Integral').style.display="";
							                   document.getElementById('ExchangeExpireDate').style.display="";
							                   document.getElementById('MemberNames').style.display="none";
							                   document.getElementById('Count').style.display="";
							                }
							            }
							            function SetThumbnail()
							            {
								            if(document.Form1.rad2.checked)
								            {
									            eval("ThumbnailPic" + ".style.display=\"\";");
								            }
								            else
								            {
									            eval("ThumbnailPic" + ".style.display=\"none\";");
								            }
							            }
						            </script>
						            <tr>
							            <td align="right" width="120px">礼券内码：</td>
                                        <td>
                                            <asp:RadioButton ID="rad1" runat="server" Text="系统自动生成" GroupName="1" Checked="True">
                                            </asp:RadioButton>
                                            <asp:RadioButton ID="rad2" runat="server" Text="自行输入" GroupName="1"></asp:RadioButton><span
                                                id="ThumbnailPic" style="display: none"><asp:TextBox ID="txtAccount" runat="server"
                                                    Width="150px" onkeyup="value=value.replace(/[\W]/g,'') " onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[/w]/g,''))" /><font
                                                        color="red">*</font>字母和数字结合,共同16位</span>

                                            <script language="javascript">SetThumbnail();</script>

                                        </td>
						            </tr>
            						
						            <tr>
							            <td align="right" width="120px">礼券类型：
							            </td>
							            <td><asp:dropdownlist id="ddlCoupon" runat="server">
									            <asp:ListItem Value="1">折扣礼券</asp:ListItem>
									            <asp:ListItem Value="2">代金礼券</asp:ListItem>
							            </asp:dropdownlist></td>
						            </tr>
            						
						            <tr id="Discount" style="display:block">
							            <td  align="right" width="120px">商品折扣为：</td>
							            <td>
								            <asp:TextBox id="txtPercentPrice" runat="server"></asp:TextBox>折(请填写0~10以内的数字)<font color="red">*</font></td>
						            </tr>
						            <tr id="Money" style="display:none">
							            <td  align="right" width="120px">替代金额为：</td>
							            <td>
								            <asp:TextBox id="txtPrice" runat="server">0</asp:TextBox>元<font color="red">*</font></td>
						            </tr>
						            <tr id="Gift" style="display:none">
							            <td  align="right" width="120px">兑换礼品为：</td>
							            <td>
								            <asp:TextBox id="txtGift" runat="server"></asp:TextBox><font color="red">*</font>
								            兑换金额为：
								            <asp:TextBox id="txtMoney" runat="server">0</asp:TextBox>元<font color="red">*</font></td>
						            </tr>
            						
						            <tr>
							            <td  align="right" width="120px">最低消费金额：</td>
							            <td>
								            <asp:TextBox id="txtLowestPrice" runat="server">0</asp:TextBox>元<font color="red">*</font></td>
						            </tr>
						            <tr style="display:none">
							            <td  align="right" width="120px">使用范围：
							            </td>
							            <td>
								            <asp:DropDownList id="ddlMainCategories" runat="server">
									            <asp:ListItem Value="1">无限制</asp:ListItem>
									            <asp:ListItem Value="2">指定类别</asp:ListItem>
									            <asp:ListItem Value="3">指定品牌</asp:ListItem>
									            <asp:ListItem Value="4">指定商品</asp:ListItem>
								            </asp:DropDownList>
							            </td>
						            </tr>
						            <tr>
						            <td colspan="2">
						            <div id="Conditions" style="display:none">
							            <table class="tableBorder" cellSpacing="0" cellPadding="0" width="95%" align="left" border="0">
								            <tr>
									            <td  align="right" width="120px">输入具体指定内容：</td>
									            <td>
										            <asp:TextBox id="txtContent" runat="server"></asp:TextBox><font color="red">*</font></td>
								            </tr>
							            </table>
						            </div>
						            </td>
						            </tr>
            						
						            <tr>
							            <td align="right" width="120">备注：</td>
							            <td>
								            <asp:TextBox id="txtRemake" runat="server" TextMode="MultiLine"></asp:TextBox></td>
						            </tr>
						            <tr>
							            <td  align="right" width="120px">礼券小图：
							            </td>
							            <td><INPUT id="File1" type="file" name="file2" runat="server"></td>
						            </tr>
						            <tr>
							            <td  align="right" width="120px">礼券大图：
							            </td>
							            <td><INPUT id="File2" type="file" name="file2" runat="server"></td>
						            </tr>
						            <tr>
							            <td  align="right" width="120px">与会员折扣优惠同用：
							            </td>
							            <td>
								            <asp:CheckBox id="CheckBox1" runat="server"></asp:CheckBox></td>
						            </tr>
						            <tr>
							            <td colspan="2" align="center"><asp:Button ID="btnSave" Runat="server" Text="保存"></asp:Button></td>
						            </tr>
					            </table>
					            <script language="javascript">
						            function SetThumbnailC()
						            {
							            if(document.Form1.ddlCoupon.value=="1")
							            {
								            document.getElementById('Discount').style.display="";
								            document.getElementById('Money').style.display="none";
								            document.getElementById('Gift').style.display="none";
							            }
							            if(document.Form1.ddlCoupon.value=="2")
							            {
								            document.getElementById('Money').style.display="";
								            document.getElementById('Discount').style.display="none";
								            document.getElementById('Gift').style.display="none";
							            }
							            if(document.Form1.ddlCoupon.value=="3")
							            {
								            document.getElementById('Gift').style.display="";
								            document.getElementById('Money').style.display="none";
								            document.getElementById('Discount').style.display="none";
							            }
						            }
						            SetThumbnailC();
						            </script>
					            <script language="javascript">
					            function SetThumbnailM()
					            {
						            if(document.Form1.ddlMainCategories.value!="1")
						            {
							            document.getElementById('Conditions').style.display="";
						            }
						            else
						            {
							            document.getElementById('Conditions').style.display="none";
            							
						            }
					            }
					            SetThumbnailM();
					            </script>
				            </td>
			            </tr>
		            </table>
		            <%}%>
		        </div>
	        </div>
		</form>
		</div>
		</div>
		</div>
	</body>
</HTML>