<!--#include file="Admin_Common.asp"-->
<%
'**************************************************************
' Software name: PowerEasy SiteWeaver
' Web: http://www.powereasy.net
' Copyright (C) 2005－2009 佛山市动易网络科技有限公司 版权所有
'**************************************************************

Const NeedCheckComeUrl = True   '是否需要检查外部访问

Const PurviewLevel = 2      '0--不检查，1--超级管理员，2--普通管理员
Const PurviewLevel_Channel = 0   '0--不检查，1--频道管理员，2--栏目总编，3--栏目管理员
Const PurviewLevel_Others = "PresentProject"   '其他权限

strFileName = "Admin_PresentProject.asp"

Response.Write "<html>" & vbCrLf
Response.Write "<head>" & vbCrLf
Response.Write "<meta http-equiv='Content-Type' content='text/html; charset=gb2312'>" & vbCrLf
Response.Write "<title>促销方案管理</title>" & vbCrLf
Response.Write "<link href='Admin_STYLE.CSS' rel='stylesheet' type='text/css'>" & vbCrLf
Response.Write "<script language = 'JavaScript'>" & vbCrLf
Response.Write "function DelPresent(){" & vbCrLf
Response.Write "  if(document.myform.PresentList.length==0) return false;" & vbCrLf
Response.Write "  var thisurl=document.myform.PresentList.value; " & vbCrLf
Response.Write "  if (thisurl=='') {alert('请先选择一个换购礼品，再点删除按钮！');return false;}" & vbCrLf
Response.Write "  document.myform.PresentList.options[document.myform.PresentList.selectedIndex]=null;" & vbCrLf
Response.Write "}" & vbCrLf
Response.Write "function CheckForm()" & vbCrLf
Response.Write "{" & vbCrLf
Response.Write "  if (document.myform.ProjectName.value==''){" & vbCrLf
Response.Write "    alert('请指定促销方案名称！');" & vbCrLf
Response.Write "    document.myform.ProjectName.focus();" & vbCrLf
Response.Write "    return false;" & vbCrLf
Response.Write "  }" & vbCrLf
Response.Write "  for(var i=0;i<document.myform.PresentList.length;i++){" & vbCrLf
Response.Write "      if (document.myform.PresentID.value=='') document.myform.PresentID.value=document.myform.PresentList.options[i].value;" & vbCrLf
Response.Write "      else document.myform.PresentID.value+=','+document.myform.PresentList.options[i].value;" & vbCrLf
Response.Write "  }" & vbCrLf
Response.Write "}" & vbCrLf
Response.Write "function AddPresent(){" & vbCrLf
Response.Write "    var arr = showModalDialog('Admin_SelectProduct.asp?ProductType=4', '', 'dialogWidth:820px; dialogHeight:600px; help: no; scroll: no; status: no');  " & vbCrLf
Response.Write "    if (arr != null&arr!=''){" & vbCrLf
Response.Write "        var ss=arr.split(',');" & vbCrLf
Response.Write "        document.myform.PresentList.options[document.myform.PresentList.length]=new Option(ss[1],ss[0]);" & vbCrLf
Response.Write "    }" & vbCrLf
Response.Write "}" & vbCrLf
Response.Write "</script>" & vbCrLf
Response.Write "</head>" & vbCrLf
Response.Write "" & vbCrLf
Response.Write "<body>" & vbCrLf
Response.Write "<table width='100%'  border='0' cellpadding='2' cellspacing='1' class='border'>" & vbCrLf
Call ShowPageTitle("促 销 方 案 管 理", 10209)
Response.Write "  <tr>" & vbCrLf
Response.Write "    <td width='70' height='30' class='tdbg'>管理导航：</td>" & vbCrLf
Response.Write "    <td class='tdbg'><a href='Admin_PresentProject.asp'>促销方案管理首页</a> | <a href='Admin_PresentProject.asp?Action=Add'>添加促销方案</a></td>" & vbCrLf
Response.Write "  </tr>" & vbCrLf
Response.Write "</table>" & vbCrLf
Select Case Action
Case "Add"
    Call Add
Case "Modify"
    Call Modify
Case "SaveAdd", "SaveModify"
    Call SaveProject
Case "Del"
    Call Del
Case Else
    Call main
End Select
If FoundErr = True Then
    Call WriteErrMsg(ErrMsg, ComeUrl)
End If
Response.Write "</body></html>"
Call CloseConn


Sub main()
    Response.Write "<br>" & vbCrLf
    Response.Write "<table width='100%'  border='0' cellpadding='2' cellspacing='1' class='border'>" & vbCrLf
    Response.Write "  <tr align='center' class='title'>" & vbCrLf
    Response.Write "    <td width='120'>方案名称</td>" & vbCrLf
    Response.Write "    <td width='150'>价格区间</td>" & vbCrLf
    Response.Write "    <td width='140'>有效期</td>" & vbCrLf
    Response.Write "    <td width='40'>有效</td>" & vbCrLf
    Response.Write "    <td>促销内容</td>" & vbCrLf
    Response.Write "    <td width='60'>操作</td>" & vbCrLf
    Response.Write "  </tr>" & vbCrLf

    Dim rsProject, sqlProject
    sqlProject = "select * from PE_PresentProject order by MinMoney desc,MaxMoney desc"
    Set rsProject = Server.CreateObject("adodb.recordset")
    rsProject.Open sqlProject, Conn, 1, 1
    If rsProject.BOF And rsProject.EOF Then
        Response.Write "<tr><td colspan='10' height='50' align='center'>没有任何方案</td></tr>"
    Else
        totalPut = rsProject.RecordCount
        If CurrentPage < 1 Then
            CurrentPage = 1
        End If
        If (CurrentPage - 1) * MaxPerPage > totalPut Then
            If (totalPut Mod MaxPerPage) = 0 Then
                CurrentPage = totalPut \ MaxPerPage
            Else
                CurrentPage = totalPut \ MaxPerPage + 1
            End If
        End If
        If CurrentPage > 1 Then
            If (CurrentPage - 1) * MaxPerPage < totalPut Then
                rsProject.Move (CurrentPage - 1) * MaxPerPage
            Else
                CurrentPage = 1
            End If
        End If

        Dim i
        i = 0
        Do While Not rsProject.EOF
            Response.Write "  <tr class='tdbg'>" & vbCrLf
            Response.Write "    <td width='120' align='center'>" & rsProject("ProjectName") & "</td>"
            Response.Write "    <td width='150' align='center'>" & FormatNumber(rsProject("MinMoney"), 2, vbTrue, vbFalse, vbTrue) & "≤金额＜" & FormatNumber(rsProject("MaxMoney"), 2, vbTrue, vbFalse, vbTrue) & "</td>"
            Response.Write "    <td width='140' align='center'>" & FormatDateTime(rsProject("BeginDate"), 2) & "至" & FormatDateTime(rsProject("EndDate"), 2) & "</td>"
            Response.Write "    <td width='40' align='center'>"
            If rsProject("BeginDate") <= Date And rsProject("EndDate") >= Date Then
                Response.Write "√"
            Else
                Response.Write "<font color='red'>×</font>"
            End If
            Response.Write "</td>"
            Response.Write "<td>"
            If FoundInArr(rsProject("PresentContent"), "1", ",") = True Then
                Response.Write " 可以以" & rsProject("Price") & "元超值换购礼品"
            End If
            If FoundInArr(rsProject("PresentContent"), "2", ",") = True Then
                Response.Write " 返还" & rsProject("Cash") & "元现金券"
            End If
            If FoundInArr(rsProject("PresentContent"), "3", ",") = True Then
                Response.Write " 得到" & rsProject("PresentExp") & "分积分"
            End If
            If FoundInArr(rsProject("PresentContent"), "4", ",") = True Then
                Response.Write " 得到" & rsProject("PresentPoint") & PointUnit & PointName
            End If

            Response.Write "</td>"
            Response.Write "    <td width='60' align='center'><a href='Admin_PresentProject.asp?Action=Modify&ProjectID=" & rsProject("ProjectID") & "'>修改</a> <a href='Admin_PresentProject.asp?Action=Del&ProjectID=" & rsProject("ProjectID") & "'>删除</a></td>"
            Response.Write "  </tr>"
            i = i + 1
            If i >= MaxPerPage Then Exit Do
            rsProject.MoveNext
        Loop
    End If
    Set rsProject = Nothing
    Response.Write "</table>" & vbCrLf
    Response.Write ShowPage(strFileName, totalPut, MaxPerPage, CurrentPage, True, True, "个方案", True)
    Response.Write "<b><br>" & vbCrLf
    Response.Write "<font color='#FF0000'>注意：</font></b><font color='#FF0000'>不同促销方案的价格区间必须不同，否则会产生冲突</font>" & vbCrLf
End Sub

Sub Add()
    Call PopCalendarInit
    Response.Write "<form name='myform' method='post' action='Admin_PresentProject.asp' onsubmit='return CheckForm()'>" & vbCrLf
    Response.Write "  <table width='100%'  border='0' cellpadding='2' cellspacing='1' class='border'>" & vbCrLf
    Response.Write "    <tr align='center'>" & vbCrLf
    Response.Write "      <td colspan='2' class='title'><b>添加促销方案</b></td>" & vbCrLf
    Response.Write "    </tr>" & vbCrLf
    Response.Write "    <tr class='tdbg'>" & vbCrLf
    Response.Write "      <td width='100' align='right'>方案名称：</td>" & vbCrLf
    Response.Write "      <td><input name='ProjectName' type='text' id='ProjectName' size='20' maxlength='20'>" & vbCrLf
    Response.Write "        <font color='#FF0000'>*</font></td>" & vbCrLf
    Response.Write "    </tr>" & vbCrLf
    Response.Write "    <tr class='tdbg'>" & vbCrLf
    Response.Write "      <td width='100' align='right'>有 效 期：</td>" & vbCrLf
    Response.Write "      <td>" & vbCrLf
    Response.Write "        <input name='BeginDate' type='text' id='BeginDate' value='" & FormatDateTime(Date, 2) & "' size='10' maxlength='10'>" & vbCrLf
    Response.Write "        <a style='cursor:hand;' onClick='PopCalendar.show(document.myform.BeginDate, ""yyyy-m-d"", null, null, null, ""11"");'><img src='Images/Calendar.gif' border='0' Style='Padding-Top:10px' align='absmiddle'></a>" & vbCrLf
    Response.Write "至" & vbCrLf
    Response.Write "        <input name='EndDate' type='text' id='EndDate' value='" & FormatDateTime(DateAdd("D", Date, 30), 2) & "' size='10' maxlength='10'>" & vbCrLf
    Response.Write "        <a style='cursor:hand;' onClick='PopCalendar.show(document.myform.EndDate, ""yyyy-m-d"", null, null, null, ""11"");'><img src='Images/Calendar.gif' border='0' Style='Padding-Top:10px' align='absmiddle'></a>" & vbCrLf
    Response.Write "      </td>" & vbCrLf
    Response.Write "    </tr>" & vbCrLf
    Response.Write "    <tr class='tdbg'>" & vbCrLf
    Response.Write "      <td width='100' align='right'>价格区间：</td>" & vbCrLf
    Response.Write "      <td><input name='MinMoney' type='text' id='MinMoney' value='100.00' size='10' maxlength='10' style='text-align:center'>" & vbCrLf
    Response.Write "        <b><font color='#FF0000'>≤</font></b> 购物总金额 <b><font color='#FF0000'>&lt;</font></b>" & vbCrLf
    Response.Write "          <input name='MaxMoney' type='text' id='MaxMoney' value='500.00' size='10' maxlength='10' style='text-align:center'>" & vbCrLf
    Response.Write "        &nbsp;&nbsp;&nbsp;&nbsp;<font color='#FF0000'>不同促销方案的价格区间必须不同，否则会产生冲突</font></td>" & vbCrLf
    Response.Write "    </tr>" & vbCrLf
    Response.Write "    <tr class='tdbg'>" & vbCrLf
    Response.Write "      <td width='100' rowspan='4' align='right'>促销内容：</td>" & vbCrLf
    Response.Write "      <td><input name='PresentContent' type='checkbox' id='PresentContent' value='1' checked>" & vbCrLf
    Response.Write "        可以" & vbCrLf
    Response.Write "          <input name='Price' type='text' id='Price' value='10' size='6' maxlength='10' style='text-align:center'>" & vbCrLf
    Response.Write "      元超值换购以下商品中任一款：<br>" & vbCrLf
    Response.Write "      <table width='100%'  border='0' cellspacing='5' cellpadding='0'>" & vbCrLf
    Response.Write "        <tr>" & vbCrLf
    Response.Write "          <td width='20'></td>" & vbCrLf
    Response.Write "          <td width='200'><select name='PresentList' size='2' multiple id='PresentList' style='height:120;width:200 '>" & vbCrLf
    Response.Write "                    </select></td>" & vbCrLf
    Response.Write "          <td><input type='button' name='Submit' value='添加商品' onClick='AddPresent()'>" & vbCrLf
    Response.Write "            <br>" & vbCrLf
    Response.Write "            <input name='PresentID' type='hidden' id='PresentID'>" & vbCrLf
    Response.Write "            <br>" & vbCrLf
    Response.Write "            <input type='button' name='Submit' value=' 删  除 ' onClick='DelPresent()'></td>" & vbCrLf
    Response.Write "        </tr>" & vbCrLf
    Response.Write "      </table></td>" & vbCrLf
    Response.Write "    </tr>" & vbCrLf
    Response.Write "    <tr>" & vbCrLf
    Response.Write "      <td class='tdbg'><input name='PresentContent' type='checkbox' id='PresentContent' value='2'>" & vbCrLf
    Response.Write "        返还" & vbCrLf
    Response.Write "        <input name='Cash' type='text' id='Cash' value='20' size='6' maxlength='10' style='text-align:center'>" & vbCrLf
    Response.Write "      元现金券</td>" & vbCrLf
    Response.Write "    </tr>" & vbCrLf
    Response.Write "    <tr>" & vbCrLf
    Response.Write "      <td class='tdbg'><input name='PresentContent' type='checkbox' id='PresentContent' value='3'>" & vbCrLf
    Response.Write "        可以得到" & vbCrLf
    Response.Write "        <input name='PresentExp' type='text' id='PresentExp' value='20' size='6' maxlength='9' style='text-align:center'>" & vbCrLf
    Response.Write "        点积分</td>" & vbCrLf
    Response.Write "    </tr>" & vbCrLf
    Response.Write "    <tr>" & vbCrLf
    Response.Write "      <td class='tdbg'><input name='PresentContent' type='checkbox' id='PresentContent' value='4'>" & vbCrLf
    Response.Write "        可以得到" & vbCrLf
    Response.Write "        <input name='PresentPoint' type='text' id='PresentPoint' value='20' size='6' maxlength='9' style='text-align:center'>" & vbCrLf
    Response.Write "        " & PointUnit & PointName & "</td>" & vbCrLf
    Response.Write "    </tr>" & vbCrLf

    Response.Write "    <tr align='center' class='tdbg'>" & vbCrLf
    Response.Write "      <td height='50' colspan='2'>        <input name='Action' type='hidden' id='Action' value='SaveAdd'>" & vbCrLf
    Response.Write "        <input type='submit' name='Submit' value='保存促销方案'></td></tr>" & vbCrLf
    Response.Write "  </table>" & vbCrLf
    Response.Write "</form>" & vbCrLf
End Sub

Sub Modify()
    Dim ProjectID, rsProject
    ProjectID = Trim(Request("ProjectID"))
    If ProjectID = "" Then
        FoundErr = True
        ErrMsg = ErrMsg & "<li>请指定促销方案ID</li>"
        Exit Sub
    Else
        ProjectID = PE_CLng(ProjectID)
    End If
    Set rsProject = Conn.Execute("select * from PE_PresentProject where ProjectID=" & ProjectID & "")
    If rsProject.BOF And rsProject.EOF Then
        FoundErr = True
        ErrMsg = ErrMsg & "<li>找不到指定的方案！</li>"
        Set rsProject = Nothing
        Exit Sub
    End If
    Call PopCalendarInit
    Response.Write "<form name='myform' method='post' action='Admin_PresentProject.asp' onsubmit='return CheckForm()'>" & vbCrLf
    Response.Write "  <table width='100%'  border='0' cellpadding='2' cellspacing='1' class='border'>" & vbCrLf
    Response.Write "    <tr align='center'>" & vbCrLf
    Response.Write "      <td colspan='2' class='title'><b>修改促销方案</b></td>" & vbCrLf
    Response.Write "    </tr>" & vbCrLf
    Response.Write "    <tr class='tdbg'>" & vbCrLf
    Response.Write "      <td width='100' align='right'>方案名称：</td>" & vbCrLf
    Response.Write "      <td><input name='ProjectName' type='text' id='ProjectName' value='" & rsProject("ProjectName") & "' size='20' maxlength='20'>" & vbCrLf
    Response.Write "        <font color='#FF0000'>*</font></td>" & vbCrLf
    Response.Write "    </tr>" & vbCrLf
    Response.Write "    <tr class='tdbg'>" & vbCrLf
    Response.Write "      <td width='100' align='right'>有 效 期：</td>" & vbCrLf
    Response.Write "      <td>" & vbCrLf
    Response.Write "        <input name='BeginDate' type='text' id='BeginDate' value='" & rsProject("BeginDate") & "' size='10' maxlength='10'>" & vbCrLf
    Response.Write "        <a style='cursor:hand;' onClick='PopCalendar.show(document.myform.BeginDate, ""yyyy-m-d"", null, null, null, ""11"");'><img src='Images/Calendar.gif' border='0' Style='Padding-Top:10px' align='absmiddle'></a>" & vbCrLf
    Response.Write "至" & vbCrLf
    Response.Write "        <input name='EndDate' type='text' id='EndDate' value='" & rsProject("EndDate") & "' size='10' maxlength='10'>" & vbCrLf
    Response.Write "        <a style='cursor:hand;' onClick='PopCalendar.show(document.myform.EndDate, ""yyyy-m-d"", null, null, null, ""11"");'><img src='Images/Calendar.gif' border='0' Style='Padding-Top:10px' align='absmiddle'></a>" & vbCrLf
    Response.Write "      </td>" & vbCrLf
    Response.Write "    </tr>" & vbCrLf
    Response.Write "    <tr class='tdbg'>" & vbCrLf
    Response.Write "      <td width='100' align='right'>价格区间：</td>" & vbCrLf
    Response.Write "      <td><input name='MinMoney' type='text' id='MinMoney' value='" & rsProject("MinMoney") & "' size='10' maxlength='10' style='text-align:center'>" & vbCrLf
    Response.Write "        <b><font color='#FF0000'>≤</font></b> 购物总金额 <b><font color='#FF0000'>&lt;</font></b>" & vbCrLf
    Response.Write "          <input name='MaxMoney' type='text' id='MaxMoney' value='" & rsProject("MaxMoney") & "' size='10' maxlength='10' style='text-align:center'>" & vbCrLf
    Response.Write "        &nbsp;&nbsp;&nbsp;&nbsp;<font color='#FF0000'>不同促销方案的价格区间必须不同，否则会产生冲突</font></td>" & vbCrLf
    Response.Write "    </tr>" & vbCrLf
    Response.Write "    <tr class='tdbg'>" & vbCrLf
    Response.Write "      <td width='100' rowspan='4' align='right'>促销内容：</td>" & vbCrLf
    Response.Write "      <td><input name='PresentContent' type='checkbox' id='PresentContent' value='1'"
    If FoundInArr(rsProject("PresentContent"), "1", ",") = True Then Response.Write " checked"
    Response.Write "> 可以 <input name='Price' type='text' id='Price' value='" & rsProject("Price") & "' size='6' maxlength='10' style='text-align:center'> 元超值换购以下商品中任一款：<br>" & vbCrLf
    Response.Write "      <table width='100%'  border='0' cellspacing='5' cellpadding='0'>" & vbCrLf
    Response.Write "        <tr>" & vbCrLf
    Response.Write "          <td width='20'></td>" & vbCrLf
    Response.Write "          <td width='200'><select name='PresentList' size='2' multiple id='PresentList' style='height:120;width:200 '>" & vbCrLf
    Response.Write "" & vbCrLf

    If FoundInArr(rsProject("PresentContent"), "1", ",") = True And rsProject("PresentID") <> "" Then
        Dim rsPresent
        Set rsPresent = Conn.Execute("select ProductID,ProductName from PE_Product where ProductID in (" & rsProject("PresentID") & ")")
        Do While Not rsPresent.EOF
            Response.Write "<option value='" & rsPresent(0) & "'>" & rsPresent(1) & "</option>"
            rsPresent.MoveNext
        Loop
        Set rsPresent = Nothing
    End If
    Response.Write "                    </select></td>" & vbCrLf
    Response.Write "          <td><input type='button' name='Submit' value='添加商品' onClick='AddPresent()'>" & vbCrLf
    Response.Write "            <br>" & vbCrLf
    Response.Write "            <input name='PresentID' type='hidden' id='PresentID'>" & vbCrLf
    Response.Write "            <br>" & vbCrLf
    Response.Write "            <input type='button' name='Submit' value=' 删  除 ' onClick='DelPresent()'></td>" & vbCrLf
    Response.Write "        </tr>" & vbCrLf
    Response.Write "      </table></td>" & vbCrLf
    Response.Write "    </tr>" & vbCrLf
    Response.Write "    <tr>" & vbCrLf
    Response.Write "      <td class='tdbg'><input name='PresentContent' type='checkbox' id='PresentContent' value='2'"
    If FoundInArr(rsProject("PresentContent"), "2", ",") = True Then Response.Write " checked"
    Response.Write "> 返还 <input name='Cash' type='text' id='Cash' value='" & rsProject("Cash") & "' size='6' maxlength='10' style='text-align:center'> 元现金券</td>" & vbCrLf
    Response.Write "    </tr>" & vbCrLf
    Response.Write "    <tr>" & vbCrLf
    Response.Write "      <td class='tdbg'><input name='PresentContent' type='checkbox' id='PresentContent' value='3'"
    If FoundInArr(rsProject("PresentContent"), "3", ",") = True Then Response.Write " checked"
    Response.Write "> 可以得到 <input name='PresentExp' type='text' id='PresentExp' value='" & rsProject("PresentExp") & "' size='6' maxlength='9' style='text-align:center'> 分积分</td>" & vbCrLf
    Response.Write "    </tr>" & vbCrLf
    
    Response.Write "    <tr>" & vbCrLf
    Response.Write "      <td class='tdbg'><input name='PresentContent' type='checkbox' id='PresentContent' value='4'"
    If FoundInArr(rsProject("PresentContent"), "4", ",") = True Then Response.Write " checked"
    Response.Write "> 返还 <input name='PresentPoint' type='text' id='PresentPoint' value='" & rsProject("PresentPoint") & "' size='6' maxlength='10' style='text-align:center'> " & PointUnit & PointName & "</td>" & vbCrLf
    Response.Write "    </tr>" & vbCrLf

    Response.Write "    <tr align='center' class='tdbg'>" & vbCrLf
    Response.Write "      <td height='50' colspan='2'><input name='ProjectID' type='hidden' id='ProjectID' value='" & ProjectID & "'>" & vbCrLf
    Response.Write "        <input name='Action' type='hidden' id='Action' value='SaveModify'>" & vbCrLf
    Response.Write "      <input type='submit' name='Submit' value='保存促销方案'></td>" & vbCrLf
    Response.Write "    </tr>" & vbCrLf
    Response.Write "  </table>" & vbCrLf
    Response.Write "</form>" & vbCrLf
    Set rsProject = Nothing
End Sub

Sub SaveProject()
    Dim ProjectID, ProjectName, BeginDate, EndDate, MinMoney, MaxMoney, PresentContent, Price, PresentID, Cash, PresentExp, PresentPoint
    Dim rsProject, sqlProject, trs
    ProjectID = Trim(Request("ProjectID"))
    ProjectName = ReplaceBadChar(Trim(Request("ProjectName")))
    BeginDate = Trim(Request("BeginDate"))
    EndDate = Trim(Request("EndDate"))
    MinMoney = Trim(Request("MinMoney"))
    MaxMoney = Trim(Request("MaxMoney"))
    PresentContent = Trim(Request("PresentContent"))
    Price = Trim(Request("Price"))
    PresentID = ReplaceBadChar(Trim(Request("PresentID")))
    Cash = Trim(Request("Cash"))
    PresentExp = Trim(Request("PresentExp"))
    PresentPoint = Trim(Request("PresentPoint"))
    If Action = "Modify" And ProjectID = "" Then
        FoundErr = True
        ErrMsg = ErrMsg & "<li>请指定方案ID</li>"
    End If
    If ProjectName = "" Then
        FoundErr = True
        ErrMsg = ErrMsg & "<li>请指定促销方案名称</li>"
    End If
    If Not IsDate(BeginDate) Then
        FoundErr = True
        ErrMsg = ErrMsg & "<li>请指定有效的开始日期</li>"
    Else
        BeginDate = CDate(BeginDate)
    End If
    If Not IsDate(EndDate) Then
        FoundErr = True
        ErrMsg = ErrMsg & "<li>请指定有效的结束日期</li>"
    Else
        EndDate = CDate(EndDate)
    End If
    If MinMoney = "" Then
        FoundErr = True
        ErrMsg = ErrMsg & "<li>请指定金额下限</li>"
    ElseIf Not IsNumeric(MinMoney) Then
        FoundErr = True
        ErrMsg = ErrMsg & "<li>请指定正确格式的金额下限</li>"
    Else
        MinMoney = CDbl(MinMoney)
    End If
    If MaxMoney = "" Then
        FoundErr = True
        ErrMsg = ErrMsg & "<li>请指定金额上限</li>"
    ElseIf Not IsNumeric(MaxMoney) Then
        FoundErr = True
        ErrMsg = ErrMsg & "<li>请指定正确格式的金额上限</li>"
    Else
        MaxMoney = CDbl(MaxMoney)
    End If
    If MinMoney >= MaxMoney Then
        FoundErr = True
        ErrMsg = ErrMsg & "<li>金额下限不能大于或等于金额上限</li>"
    End If
    If PresentContent = "" Then
        FoundErr = True
        ErrMsg = ErrMsg & "<li>请最少要选择一种促销方式</li>"
    End If
    If FoundInArr(PresentContent, "1", ",") = True Then
        If Price = "" Then
            FoundErr = True
            ErrMsg = ErrMsg & "<li>请指定换购价格</li>"
        ElseIf IsNumeric(Price) = False Then
            FoundErr = True
            ErrMsg = ErrMsg & "<li>请指定正确格式的换购价格</li>"
        Else
            Price = CDbl(Price)
        End If
        If PresentID = "" Then
            FoundErr = True
            ErrMsg = ErrMsg & "<li>请指定换购的商品</li>"
        End If
    End If
    If FoundInArr(PresentContent, "2", ",") = True Then
        If Cash = "" Then
            FoundErr = True
            ErrMsg = ErrMsg & "<li>请指定返还的现金券的金额</li>"
        End If
        If IsNumeric(Cash) = False Then
            FoundErr = True
            ErrMsg = ErrMsg & "<li>请指定正确格式的返还现金券金额</li>"
        End If
    End If
    If FoundInArr(PresentContent, "3", ",") = True Then
        If PresentExp = "" Then
            FoundErr = True
            ErrMsg = ErrMsg & "<li>请指定可以得到的积分分数</li>"
        End If
        If IsNumeric(PresentExp) = False Then
            FoundErr = True
            ErrMsg = ErrMsg & "<li>请指定正确格式积分分数</li>"
        End If
    End If

    If FoundInArr(PresentContent, "4", ",") = True Then
        If PresentPoint = "" Then
            FoundErr = True
            ErrMsg = ErrMsg & "<li>请指定可以得到的" & PointName & "数</li>"
        End If
        If IsNumeric(PresentExp) = False Then
            FoundErr = True
            ErrMsg = ErrMsg & "<li>请指定正确格式" & PointName & "</li>"
        End If
    End If
  
    If Action = "SaveAdd" Then
        sqlProject = "select top 1 * from PE_PresentProject"
    Else
        If ProjectID = "" Then
            FoundErr = True
            ErrMsg = ErrMsg & "<li>请指定ProjectID！</li>"
        Else
            ProjectID = PE_CLng(ProjectID)
        End If
        sqlProject = "select * from PE_PresentProject where ProjectID=" & ProjectID
    End If
    
    If FoundErr = True Then Exit Sub
    
    Set rsProject = Server.CreateObject("adodb.recordset")
    rsProject.Open sqlProject, Conn, 1, 3
    If Action = "SaveAdd" Then
        rsProject.AddNew
    End If
    rsProject("ProjectName") = ProjectName
    rsProject("BeginDate") = BeginDate
    rsProject("EndDate") = EndDate
    rsProject("MinMoney") = MinMoney
    rsProject("MaxMoney") = MaxMoney
    rsProject("PresentContent") = PresentContent
    rsProject("Price") = Price
    rsProject("PresentID") = PresentID
    rsProject("Cash") = Cash
    rsProject("PresentExp") = CLng(PresentExp)
    rsProject("PresentPoint") = CLng(PresentPoint)
    rsProject.Update
    rsProject.Close
    Set rsProject = Nothing
    Call CloseConn
    Response.Redirect "Admin_PresentProject.asp"
End Sub

Sub Del()
    Dim ProjectID
    ProjectID = Trim(Request("ProjectID"))
    If ProjectID = "" Then
        FoundErr = True
        ErrMsg = ErrMsg & "<li>请指定促销方案ID</li>"
        Exit Sub
    Else
        ProjectID = PE_CLng(ProjectID)
    End If
    Conn.Execute ("delete from PE_PresentProject where ProjectID=" & ProjectID & "")
    Call CloseConn
    Response.Redirect "Admin_PresentProject.asp"
End Sub
%>
