<!--#include file="../../Inc/Cls_Main.Asp"-->
<!--#include file="../inc/Cls_Admin.Asp"-->
<!--#include file="../inc/Cls_MapPath.Asp"-->
<!--#include file="../inc/Cls_InType.Asp"-->
<!--#include file="../Admin_Check.Asp"-->
<%
Dim CmsAdmin
'=============================================================================
Set CmsAdmin = New Cls_Admin
CmsAdmin.SetAdminTitle = CmsSiteName
CmsAdmin.SetBodyCssName = "mainbody"
CmsAdmin.SetAdminPath = CmsAdminMapPath
CmsAdmin.LoadHead()
'=============================================================================
Dim Action
'=============================================================================
Action = Easp.Get("action")
Select Case Action
    Case "savemain"
        Call SaveMain()
    Case Else
        Call PageLoad()
End Select
CmsAdmin.LoadFooter()
Set CmsAdmin = Nothing

Sub PageLoad()
    Dim oRs, Id, ClassId, Title, TypeId
    Dim S, T, Url, PicUrl, AdCode, W, H
    Dim StartTime, EndTime
    '=====================================================================
    Id = Easp.Get("id:n:0")
    If Id = 0 Then
        CmsAdmin.JscriptMsg "参数错误！", "back", "Error", "null"
    End If
    Set oRs = Easp.db.GR(TablePrefix & "Ad:1", " Id = "& Id &" ", "")
    If Easp.IsN(oRs) Then
        CmsAdmin.JscriptMsg "不存在的数据！", "back", "Error", "null"
    Else
        ClassId = oRs("ClassId")
        Title = oRs("Title")
        TypeId = oRs("TypeId")
        S = oRs("S")
        T = oRs("T")
        Url = oRs("Url")
        PicUrl = oRs("PicUrl")
        AdCode = oRs("AdCode") & ""
        W = oRs("W")
        H = oRs("H")
        StartTime = Easp.DateTime(oRs("StartTime"),"yyyy-mm-dd")
        EndTime = Easp.DateTime(oRs("EndTime"),"yyyy-mm-dd")
    End If
    Easp.C oRs
%>
<script src="<%=CmsAdminMapPath%>js/check/ad.check.js"></script>
<form name="myform" id="myform" method="post" action="?action=savemain">
  <input type="hidden" name="id" value="<%=Id%>" />
  <input type="hidden" name="ToUrl" value="<%=CmsFun.LoadToUrl()%>" />
  <div class="navigation"><a href="Admin.Index.Asp" class="back">广告管理</a> 插件管理 &gt; 广告管理 &gt; 编辑广告 </div>
  <div id="contentTab">
    <div class="content-tab">
      <ul class="tab_nav">
        <li><a onclick="tabs(this);" class="selected" href="javascript:void(0);">编辑广告</a></li>
      </ul>
    </div>
    <div class="tab_con" style="display: block;">
      <table class="form_table">
        <col width="200px">
          </col>
        
        <tbody>
          <tr>
            <th> 所属分类： </th>
            <td class="td2"><%=GetAdType(ClassId, "")%> <span class="Validform_checktip">*</span></td>
          </tr>
          <tr>
            <th> 广告类型： </th>
            <td class="td2"><%=GetShowAdType(TypeId, " onchange=""ShowType(this.value)""")%> <span class="Validform_checktip">*</span></td>
          </tr>
          <tr id="trd1" style="display:none;">
            <th> 广告侧边距： </th>
            <td class="td2"><input type="text" class="txtInput w50" name="S" id="S" autocomplete="off" value="<%=S%>" datatype="n3" nullmsg="广告侧边距必须填写" errormsg="不可为：0,最多3位数" />
              <span class="Validform_checktip">*</span></td>
          </tr>
          <tr id="trd2" style="display:none;">
            <th> 广告上边距： </th>
            <td class="td2"><input type="text" class="txtInput w50" name="T" id="T" autocomplete="off" value="<%=T%>" datatype="n3" nullmsg="广告上边距必须填写" errormsg="不可为：0,最多3位数" />
              <span class="Validform_checktip">*</span></td>
          </tr>
          <tr>
            <th> 广告说明： </th>
            <td class="td2"><input type="text" class="txtInput w350" name="Title" id="Title" autocomplete="off" value="<%=Title%>" datatype="*4-150" nullmsg="广告说明必须填写" errormsg="至少4个字符,最多150个字符!" />
              <span class="Validform_checktip">*</span></td>
          </tr>
          <tr id="trd3">
            <th> 链接URL： </th>
            <td class="td2"><input type="text" class="txtInput w350" name="Url" id="Url" autocomplete="off" value="<%=Url%>" datatype="*1-150" nullmsg="链接URL必须填写" errormsg="至少1个字符,最多150个字符!" />
              <span class="Validform_checktip">*</span></td>
          </tr>
          <tr id="trd4">
            <th> 图片或FLASH URL： </th>
            <td class="td2"><input type="text" class="txtInput w350 left" name="PicUrl" id="PicUrl" autocomplete="off" value="<%=PicUrl%>" datatype="*4-150" nullmsg="图片或FLASH URL必须填写" errormsg="至少4个字符,最多150个字符!" />
              <a href="javascript:;" class="files">
              <input type="file" id="FileUploadImg" name="FileUploadImg" onchange="Upload('../', 'UpFile', 13000, 1, 'PicUrl');" />
              </a> <span class="uploading">正在上传，请稍候...</span>　
              <input type="button" class="btnSearch" value="从已上传中选择" onclick="ShowWin('PicUrl', '从已上传中选择', '../Admin_File.Asp?action=sf&ChannelId=13000&ReturnId=PicUrl', SetDialog.PublicWidth, SetDialog.PublicHeight, false);" />
              <span class="Validform_checktip">*</span></td>
          </tr>
          <tr id="trd5" style="display:none;">
            <th> 广告代码： </th>
            <td class="td2"><textarea name="AdCode" id="AdCode" class="w350h150" datatype="*4-1000" errormsg="至少4个字符,最多10000个字符!"><%=AdCode%></textarea>
              <span class="Validform_checktip">支持Html</span></td>
          </tr>
          <tr id="trd6">
            <th> 尺寸宽度： </th>
            <td class="td2"><input type="text" class="txtInput w50" name="W" id="W" autocomplete="off" value="<%=W%>" datatype="n4" nullmsg="广告侧边距必须填写" errormsg="不可为：0,最多4位数" />
              <span class="Validform_checktip">*</span></td>
          </tr>
          <tr id="trd7">
            <th> 尺寸高度： </th>
            <td class="td2"><input type="text" class="txtInput w50" name="H" id="H" autocomplete="off" value="<%=H%>" datatype="n4" nullmsg="广告侧边距必须填写" errormsg="不可为：0,最多4位数" />
              <span class="Validform_checktip">*</span></td>
          </tr>
          <tr>
            <th> 投放时间： </th>
            <td class="td2"><input type="text" class="txtInput w100" name="StartTime" id="StartTime" autocomplete="off" value="<%=StartTime%>" datatype="date1" onclick="WdatePicker();" />
              <span class="Validform_checktip">*</span></td>
          </tr>
          <tr>
            <th> 结束时间： </th>
            <td class="td2"><input type="text" class="txtInput w100" name="EndTime" id="EndTime" autocomplete="off" value="<%=EndTime%>" datatype="date1" onclick="WdatePicker();" />
              <span class="Validform_checktip">*</span></td>
          </tr>
          <tr>
            <th></th>
            <td><input type="submit" class="btnSubmit" value="提交保存" />
              &nbsp;
              <input name="重置" type="reset" class="btnSubmit" value="重 置" /></td>
          </tr>
        </tbody>
      </table>
    </div>
  </div>
</form>
<script>
ShowType(<%=TypeId%>);
</script>
<%
End Sub

Sub SaveMain()
    ChkSysAdminLevel "sys_ad", "edit"
    '=====================================================================
    Dim Id, ClassId, Title, TypeId, S, T
    Dim Url, PicUrl, AdCode, W, H
    Dim StartTime, EndTime, ToUrl
    Id = Easp.Post("Id:n:0")
    ClassId = Easp.Post("ClassId:n:0")
    Title = Trim(Easp.Post("Title:s"))
    TypeId = Easp.Post("TypeId:n:0")
    S = Easp.Post("S:n:0")
    T = Easp.Post("T:n:0")
    Url = Trim(Easp.Post("Url:s"))
    PicUrl = Trim(Easp.Post("PicUrl:s"))
    AdCode = Easp.Post("AdCode:s")
    W = Easp.Post("W:n:0")
    H = Easp.Post("H:n:0")
    StartTime = Easp.Post("StartTime:d")
    EndTime = Easp.Post("EndTime:d")
    ToUrl = Trim(Easp.Post("ToUrl:s"))
    '=====================================================================
    If Id = 0 Then
        CmsAdmin.JscriptMsg "参数错误！", "back", "Error", "null"
    End If
    If ClassId = 0 Then
        CmsAdmin.JscriptMsg "所属分类必须选择！", "back", "Error", "null"
    End If
    If Easp.IsN(Title) Then
        CmsAdmin.JscriptMsg "广告位名称不能为空！", "back", "Error", "null"
    End If
    If TypeId = 0 Then
        CmsAdmin.JscriptMsg "所属类型必须选择！", "back", "Error", "null"
    End If
    If TypeId = 1 Then
        If Easp.IsN(PicUrl) Then
            CmsAdmin.JscriptMsg "链接URL必须填写！", "back", "Error", "null"
        End If
        If Easp.IsN(Url) Then
            CmsAdmin.JscriptMsg "图片或FLASH地址必须填写！", "back", "Error", "null"
        End If
    End If
    If (TypeId = 2 Or TypeId = 3) Then
        If (T = 0 Or S = 0) Then
            CmsAdmin.JscriptMsg "侧边距、上边距不能为：0！", "back", "Error", "null"
        End If
        If Easp.IsN(PicUrl) Then
            CmsAdmin.JscriptMsg "链接URL必须填写！", "back", "Error", "null"
        End If
        If Easp.IsN(Url) Then
            CmsAdmin.JscriptMsg "图片或FLASH地址必须填写！", "back", "Error", "null"
        End If
    End If
    If TypeId = 4 Then
        If Easp.IsN(AdCode) Then
            CmsAdmin.JscriptMsg "广告代码必须填写！", "back", "Error", "null"
        End If
    End If
    If TypeId <> 5 Then
        If (H = 0 Or W = 0) Then
            CmsAdmin.JscriptMsg "尺寸不能为：0！", "back", "Error", "null"
        End If
    End If
    '=====================================================================
    Dim List, ResultVal
    Easp.Use "list"
    Set List = Easp.List.New
    List("ClassId") = ClassId
    List("Title") = Title
    List("TypeId") = TypeId
    List("S") = S
    List("T") = T
    List("Url") = Url
    List("PicUrl") = PicUrl
    List("AdCode") = AdCode
    List("W") = W
    List("H") = H
    List("StartTime") = StartTime
    List("EndTime") = EndTime
    '=====================================================================
    ResultVal = Easp.db.UR(TablePrefix & "Ad", " Id = "& Id &" ", List.Hash)
    '=====================================================================
    Easp.C List
    If ResultVal <> 0 Then
        CmsAdmin.JscriptMsg "编辑广告成功！", Easp.IIf(Easp.IsN(ToUrl), "Admin.Index.Asp", ToUrl), "Success", "null"
    End If
    '=====================================================================
End Sub
%>
