<%@ Page Language="C#" AutoEventWireup="false" %>
<%@ Register TagPrefix="Hishop" Namespace="Hishop.Web.Controls" Assembly="Hishop.Web.Controls" %>
<%@ Register TagPrefix="Hishop" Namespace="Hishop.Web.Management" Assembly="Hishop.Web.Management" %>
<%@ Register TagPrefix="Hishop" Namespace="Hishop.Web.Validator" Assembly="Hishop.Web.Validator" %>
<%@ Register Assembly="FredCK.FCKeditorV2" Namespace="FredCK.FCKeditorV2" TagPrefix="FCKeditorV2" %>
<%@ Import Namespace="Hishop.SystemServices" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <Hishop:HeadContainer ID="HeadContainer1" runat="server" />
    <Hishop:PageTitle ID="PageTitle1" runat="server" />
    <link rel="stylesheet" href="../../utility/validate/pagevalidator.css" type="text/css" />
    <link rel="stylesheet" href="../css/Hishopv5.css" type="text/css" />
    <script type="text/javascript" src="../../utility/jquery-1.3.2.min.js"></script>
    <script type="text/javascript" src="../../utility/validate/pagevalidator.js"></script>
    
    <script type="text/javascript" src="../js/Hishopv5.js"></script>
    <script type="text/javascript" language="javascript">
        function ResetGroupBuyProducts() {
            var categoryId = $("#AddGroupBuy_dropCategories").val();
            var sku = $("#AddGroupBuy_txtSKU").val();
            var productName = $("#AddGroupBuy_txtSearchText").val();
            var postUrl = "ProductHandler.aspx?action=getGroupBuyProducts&timestamp=";
            postUrl += new Date().getTime() + "&categoryId=" + categoryId + "&sku=" + encodeURI(sku) + "&productName=" + encodeURI(productName);

            document.getElementById("AddGroupBuy_groupBuyView_dropGroupBuyProduct").options.length = 0;
            $.ajax({
                url: postUrl,
                type: 'GET', dataType: 'json', timeout: 10000,
                async: false,
                success: function(resultData) {
                    if (resultData.Status == "0") {
                    }
                    else if (resultData.Status == "OK") {
                        FillProducts(resultData.Product);
                    }
                }
            });
        }

        function FillProducts(Product) {
            var productSelector = $("#AddGroupBuy_groupBuyView_dropGroupBuyProduct");
            productSelector.append("<option selected=\"selected\" value=\"0\"><\/option>");

            $.each(Product, function(i, Product) {
            var a = Product.ProductId;
            var b = Product.ProductName;
                productSelector.append("<option value=\"" + a + "\">" + b + "<\/option>");
            });
        }

    </script>
</head>
<body>
    <form id="form1" runat="server">

        <div>
           
            <div class="PageTitleArea">
                <div class="PageTitle">
                    <asp:Literal ID="lblPageTitle" runat="server" Text="添加团购活动"></asp:Literal>
                </div>
                <div style="width: 80%;">
                    <asp:Literal ID="lblPageDesc" runat="server" Text="填写团购活动详细信息"></asp:Literal>
                </div>
            </div>
            
            <Hishop:AddGroupBuy ID="AddGroupBuy" runat="server">
            <SkinTemplate>

        <Hishop:StatusMessage id="Status" runat="server" Visible="False" />

<fieldset class="AdminSearchform">
    <legend>
        <asp:Literal ID="litSelectQuery" runat="server" Text="查找团购商品"></asp:Literal></legend>
    <table width="55%" border="0" cellspacing="0" cellpadding="0" style="margin-left: 18px">
        <tr>
            <td class="searchTableLeftTD">
                <nobr>
                    <asp:Label ID="lblSearchText" runat="server" Text="商品名称"></asp:Label>：</nobr>
            </td>
            <td class="searchTableControlTD">
                <asp:TextBox ID="txtSearchText" runat="server" Width="110" ToolTip="如果有多个关键字请用分隔号分开"></asp:TextBox></td>
             <td class="searchTableLeftTD">
                <nobr>
                    <asp:Label ID="lblCategory" runat="server" Text="商品分类"></asp:Label>：</nobr>
            </td>
            <td class="searchTableControlTD">
                <Hishop:ProductCategoriesDropDownList ID="dropCategories" runat="server" />
            </td>
            <td class="searchTableLeftTD">
                <nobr>
                    <asp:Label ID="lblSKU" runat="server" Text="货号"></asp:Label>：</nobr>
            </td>
            <td class="searchTableControlTD">
                <asp:TextBox ID="txtSKU" Width="110" runat="server"></asp:TextBox>
            </td>
             <td class="searchTableControlTD">
                <input type="button" id="btnSearch" value="查找" onclick="ResetGroupBuyProducts()"
                    class="inp_L1" /></td>
            
        </tr>
       
    </table>
</fieldset>
<Hishop:GroupBuyView ID="groupBuyView" runat="server" >
<SkinTemplate>
<table style="width: 100%" cellspacing="0" cellpadding="0" class="formTableList">
    
    <!--团购商品-->
    <tr>
        <td class="leftTD">
            <asp:Literal ID="lblProductName" runat="server" Text="团购商品"></asp:Literal></td>
        <td class="rightTD">
            <Hishop:GroupBuyProductDropDownList ID="dropGroupBuyProduct" runat="server" />
        </td>
        <td class="rightTD">
            <div id="dropGroupBuyProductTip" runat="server"></div>
            <Hishop:ValidateTarget ID="ValidateTarget5" runat="server" ContainerId="ValidatorContainer" ControlToValidate="dropGroupBuyProduct" Description="选择此次团购活动的商品，当此团购活动有会员已订购时，商品不能再进行编辑" Nullable="false" FocusMessage="选择此次团购活动的商品，当此团购活动有会员已订购时，商品不能再进行编辑">
                       <Validators>
                           <Hishop:DropDownListClientValidator ErrorMessage="请选择此次团购活动的商品" />
                       </Validators>
            </Hishop:ValidateTarget>
        </td>
    </tr>
   
    <!--结束日期-->
    <tr id="tblrStock" runat="server">
        <td class="leftTD">
            <asp:Literal ID="Literal2" runat="server" Text="结束日期"></asp:Literal></td>
        <td class="rightTD">
           <Hishop:WebCalendar ID="calendarEnd" runat="server" CalendarType="EndDate"/>&nbsp;&nbsp;<asp:DropDownList ID="dropHour" runat="server" />点</td>
        <td class="rightTD">
            <div class="msgNormal">
                <asp:Literal ID="Literal1" runat="server" Text="当达到结束日期时，活动会自动变为结束未处理状态。" />
            </div>
        </td>
    </tr>
     <!--违约金-->
    <tr>
        <td class="leftTD">
            <asp:Literal ID="lblNeedPrice" runat="server" Text="违约金"></asp:Literal></td>
        <td class="rightTD">
            <asp:TextBox ID="txtNeedPrice" runat="server"></asp:TextBox>
        </td>
        <td class="rightTD">
            <div id="txtNeedPriceTip" runat="server">
            </div>
            <Hishop:ValidateTarget ID="ValidateTargetNeedPrice" runat="server" ContainerId="ValidatorContainer"
                ControlToValidate="txtNeedPrice" Nullable="true" Description="设置此次团购活动的违约金">
                <Validators>
                    <Hishop:InputMoneyClientValidator ErrorMessage="此次团购活动的违约金" />
                    <Hishop:NumberRangeClientValidator ErrorMessage="超出系统允许的金额范围"  MinValue="0" MaxValue="9999999" />
                </Validators>
            </Hishop:ValidateTarget>
        </td>
    </tr>
    
     <!--限购总数量-->
    <tr>
        <td class="leftTD">
            <asp:Literal ID="Literal5" runat="server" Text="限购总数量"></asp:Literal></td>
        <td class="rightTD">
            <asp:TextBox ID="txtMaxCount" runat="server" Width="80px" MaxLength="100"></asp:TextBox></td>
        <td class="rightTD">
            <div id="txtMaxCountTip" runat="server">
            </div>
            <Hishop:ValidateTarget ID="ValidateTargetStock" runat="server" ControlToValidate="txtMaxCount"
                Nullable="false" ContainerId="ValidatorContainer" Description="此次活动可购买的商品总数量,订购达到此上限时，活动会自动变为结束未处理状态。">
                <Validators>
                    <Hishop:InputNumberClientValidator ErrorMessage="此次活动可购买的商品总数量" />
                </Validators>
            </Hishop:ValidateTarget>
        </td>
    </tr>
    
      <!--团购满足数量-->
    <tr>
        <td class="leftTD">
            <asp:Literal ID="Literal6" runat="server" Text="团购满足数量"></asp:Literal></td>
        <td class="rightTD">
            <asp:TextBox ID="txtCount" runat="server" Width="80px" MaxLength="100"></asp:TextBox></td>
        <td class="rightTD">
            <div id="txtCountTip" runat="server">
            </div>
            <Hishop:ValidateTarget ID="ValidateTarget6" runat="server" ControlToValidate="txtCount"
                Nullable="false" ContainerId="ValidatorContainer" Description="满足此次活动的最低商品订购数量。">
                <Validators>
                    <Hishop:InputNumberClientValidator ErrorMessage="此次活动的最低商品订购数量。" />
                </Validators>
            </Hishop:ValidateTarget>
        </td>
    </tr>
    
    <!--团购价格-->
    <tr>
        <td class="leftTD">
            <asp:Literal ID="Literal7" runat="server" Text="团购价格"></asp:Literal></td>
        <td class="rightTD">
            <label>
                <asp:TextBox ID="txtPrice" runat="server"></asp:TextBox>
            </label>
        </td>
        <td class="rightTD">
            <div id="txtPriceTip" runat="server">
            </div>
            <Hishop:ValidateTarget ID="ValidateTarget7" runat="server" ContainerId="ValidatorContainer"
                ControlToValidate="txtPrice" Nullable="false" Description="达到团购满足数量后享受的团购价格.">
                <Validators>
                    <Hishop:InputMoneyClientValidator ErrorMessage="达到团购满足数量后享受的团购价格" />
                    <Hishop:NumberRangeClientValidator ErrorMessage="超出系统允许的金额范围"  MinValue="0" MaxValue="9999999" />
                </Validators>
            </Hishop:ValidateTarget>
        </td>
    </tr>
    <tr>
        <td class="leftTD">
            <asp:Literal ID="lblConten" runat="server" Text="活动说明"></asp:Literal></td>
        <td class="rightTD">
            <asp:TextBox ID="txtContent" runat="server" TextMode="MultiLine" Width="250px" Height="70px"></asp:TextBox>
        </td>
        <td class="rightTD">
         <div id="txtContentTip" runat="server">
            </div>
            <Hishop:ValidateTarget ID="ValidateTarget4" runat="server" ControlToValidate="txtContent" Nullable="true"
                ContainerId="ValidatorContainer" Description="此次活动的说明">
                <Validators>
                    <Hishop:InputStringClientValidator ErrorMessage="超出允许填入的数量"
                         UpperBound="1000" />
                </Validators>
            </Hishop:ValidateTarget>
           
        </td>
    </tr>  



 
</SkinTemplate>
</Hishop:GroupBuyView>
<table style="width: 100%" cellspacing="0" cellpadding="0" class="formTableList">
    <tr>
        <td class="bottonLeftTD">
            &nbsp;</td>
        <td class="rightTD">
            <table>
                <tr>
                    <td valign="top">
                        <asp:Button ID="btnAddGroupBuy" runat="server" Text="添加"
                             OnClientClick="return PageIsValid();"
                            CssClass="inp_L1" /></td>
                            <td valign="top">
                       
                    <td>
                        <div class="return_inp">
                            <a href='<%= Globals.GetSiteUrls().UrlData.FormatUrl("admin_ReturnGroupBuys")%>'>
                                <asp:Literal ID="lblReturn" runat="server" Text="返回"></asp:Literal></a>
                        </div>
                    </td>
                </tr>
            </table>
        </td>
        <td class="rightTD">
            &nbsp;</td>
    </tr>
</table>

            </SkinTemplate>
            </Hishop:AddGroupBuy>
            
        </div>
        <br />
        <div class="botCopyInfo">
            <hr style="width:500px;" />
            <Hishop:SiteCopyright ID="SiteCopyright1" runat="server" />
        </div>
        <br />
        <Hishop:ValidatorContainer runat="server" ID="ValidatorContainer" />
    </form>
</body>
</html>