标题:这个ProductSave.asp吧,怎么不能用呢?
只看楼主
z76635452
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2009-10-9
结帖率:0
已结贴  问题点数:20 回复次数:1 
这个ProductSave.asp吧,怎么不能用呢?
<%@language=vbscript codepage=936 %>
<!--#include file="conn.asp"-->
<!--#include file="admin.asp"-->
<!--#include file="../inc/Const.asp" -->
<!--#include file="../Inc/Config.asp"-->
<!--#include file="Inc/Function.asp"-->
<%
dim rs,sql,ErrMsg,FoundErr
dim ID,Product_Id,BigClassName,SmallClassName,Title,Content,UpdateTime,Hits
dim IncludePic,DefaultPicUrl,UploadFiles,Elite,Passed,arrUploadFiles
dim ObjInstalled
ObjInstalled=IsObjInstalled("Scripting.FileSystemObject")
FoundErr=false
ID=Trim(Request.Form("ID"))
Product_Id=trim(request.form("Product_Id"))
ClassID=trim(request.form("ClassID"))
Title=trim(request.form("Title"))
Spec=trim(request.form("Spec"))
Unit=trim(request.form("Unit"))
Memo=trim(request.form("Memo"))
Content=trim(request.form("Content"))
UpdateTime=trim(request.form("UpdateTime"))
IncludePic=trim(request.form("IncludePic"))
DefaultPicUrl=trim(request.form("DefaultPicUrl"))
UploadFiles=trim(request.form("UploadFiles"))
Passed=trim(request.form("Passed"))
Elite=trim(request.form("Elite"))
FirstPage=trim(request.form("FirstPage"))
Newproduct=trim(request.form("Newproduct"))
Hits=trim(request.form("Hits"))


  if ClassID="" then
        founderr=true
        errmsg=errmsg & "<br><li>未指定产品所属栏目或者指定的栏目有下属子栏目</li>"
    else
        ClassID=CLng(ClassID)
        if ClassID<=0 then
            FoundErr=True
            ErrMsg=ErrMsg & "<br><li>指定了非法的栏目(外部栏目或不存在的栏目)</li>"
        else
            set tClass=conn.execute("select ClassName,Depth,ParentPath,Child,LinkUrl,ParentID From 0791idc_ProductClass where ClassID=" & ClassID)
            if tClass.bof and tClass.eof then
                FoundErr=True
                ErrMsg=ErrMsg & "<br><li>找不到指定的栏目</li>"
            else
                ClassName=tClass(0)
                Depth=tClass(1)
                ParentPath=tClass(2)
                Child=tClass(3)
                if Child>0 then
                    FoundErr=True
                    ErrMsg=ErrMsg & "<br><li>指定的栏目有下属子栏目</li>"
                end if
                if tClass(4)<>"" then
                    FoundErr=True
                    ErrMsg=ErrMsg & "<br><li>不能指定外部栏目</li>"
                end if               
             end if
        end if
   end if

if Title="" then
    founderr=true
    errmsg="<li>产品标题不能为空</li>"
end if
if Spec="" then
    Spec=null
end if
if Unit="" then
    Unit=null
end if
if Memo="" then
    Memo=null
end if

if Content="" then
    founderr=true
    errmsg=errmsg+"<li>产品说明不能为空</li>"
end if

if founderr=false then        
    if UpdateTime<>"" and IsDate(UpdateTime)=true then
        UpdateTime=CDate(UpdateTime)
    else
        UpdateTime=now()
    end if
    if Hits<>"" then
        Hits=CLng(Hits)
    else
        Hits=0
    end if
    set rs=server.createobject("adodb.recordset")
    if request("action")="add" then
        sql="select * from 0791idc_Product where (ID is null)"
        rs.open sql,conn,1,3
        rs.addnew
        call SaveData()        
        rs.update
        ID=rs("ID")
        rs.close
        set rs=nothing
        
        
        End If
        
    elseif request("action")="Modify" then
          if ID<>"" then
            sql="select * from 0791idc_Product where id=" & ID
            rs.open sql,conn,1,3
            if not (rs.bof and rs.eof) then
                call SaveData()
                rs.update
                rs.close
                set rs=nothing
               
                End If
             else
                founderr=true
                errmsg=errmsg+"<li>找不到此产品,可能已经被删除。</li>"
                call WriteErrMsg()
            end if
        else
            founderr=true
            errmsg=errmsg+"<li>不能确定产品ID的值</li>"
            call WriteErrMsg()
        end if
    else
        founderr=true
        errmsg=errmsg+"<li>没有选定参数</li>"
        call WriteErrMsg()
    end if

    call CloseConn()
%>
<!-- #include file="Inc/Head.asp" -->
<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td width="862" align="center" valign="top"> <br> <br> <b> </b><br> <br> <br>
      <table class="border" align=center width="70%" border="0" cellpadding="0" cellspacing="2" bordercolor="#999999">
        <tr align=center bgcolor="#A4B6D7">
          <td  height="25" colspan="2" class="title"><b>
            <%if request("action")="add" then%>
            添加
            <%else%>
            修改
            <%end if%>
            产品成功</b></td>
        </tr>
        <tr>
          <td width="24%" height="22" bgcolor="#C0C0C0" class="tdbg"> <p align="right">产品序号:</p></td>
          <td width="76%" bgcolor="#E3E3E3" class="tdbg"><%=ID%></td>
        </tr>
        <tr>
          <td height="22" bgcolor="#C0C0C0" class="tdbg"><div align="right">产品编号:</div></td>
          <td bgcolor="#E3E3E3" class="tdbg"><%=Product_Id%></td>
        </tr>
        <tr>
          <td height="22" bgcolor="#C0C0C0" class="tdbg"><div align="right">产品名称:</div></td>
          <td bgcolor="#E3E3E3" class="tdbg"><%=Title%></td>
        </tr>
        <tr>
          <td height="22" bgcolor="#C0C0C0" class="tdbg"><div align="right">规格:</div></td>
          <td bgcolor="#E3E3E3" class="tdbg"><%=Spec%></td>
        </tr>
        <tr>
          <td height="22" bgcolor="#C0C0C0" class="tdbg"><div align="right">单位:</div></td>
          <td bgcolor="#E3E3E3" class="tdbg"><%=Unit%></td>
        </tr>
        <tr>
          <td height="22" bgcolor="#C0C0C0" class="tdbg"><div align="right">备注:</div></td>
          <td bgcolor="#E3E3E3" class="tdbg"><%=Memo%></td>
        </tr>
        <tr>
          <td height="22" bgcolor="#C0C0C0" class="tdbg"><div align="right">所属类别:</div></td>
          <td bgcolor="#E3E3E3" class="tdbg"> <%response.write ClassName %> </td>
        </tr>
        <tr>
          <td height="22" colspan="2" bgcolor="#E3E3E3" class="tdbg"> <p align="center">
              【<a href="ProductModify.asp?ID=<%=ID%>">修改产品</a>】&nbsp;【<a href="ProductAdd.asp">继续添加产品</a>】&nbsp;【<a href="ProductManage.asp">产品管理</a>】&nbsp;【<a href="../ProductShow.asp?ID=<%=ID%>" target="_blank">预览产品内容</a>】</p></td>
        </tr>
      </table></td>
  </tr>
</table>
<!-- #include file="Inc/Foot.asp" -->
<%
else
    WriteErrMsg
end if

sub SaveData()
    rs("Product_Id")=Product_Id
    rs("Title")=Title
    rs("ClassID")=ClassID   
    rs("Spec")=Spec
    rs("Unit")=Unit
    rs("Memo")=Memo
    rs("Content")=Content
    rs("Hits")=Hits
    if IncludePic="yes" then
        rs("IncludePic")=True
    else
        rs("IncludePic")=False
    end if
    if Passed="yes" then
        rs("Passed")=True
    else
        if EnableArticleCheck="No" then
            rs("Passed")=True
        else
            rs("Passed")=False
        end if
    end if
    if Elite="yes" then
        rs("Elite")=True
    else
        rs("Elite")=False
    end if
    if Newproduct="yes" then
        rs("Newproduct")=True
    else
        rs("Newproduct")=False
    end if   
    if FirstPage="yes" then
        rs("FirstPage")=True
    else
        rs("FirstPage")=False
    end if
    rs("UpdateTime")=UpdateTime

    '***************************************
    '删除无用的上传文件
    if ObjInstalled=True and UploadFiles<>"" then
        dim fso,strRubbishFile
        Set fso = Server.CreateObject("Scripting.FileSystemObject")
        if instr(UploadFiles,"|")>1 then
            dim arrUploadFiles,intTemp
            arrUploadFiles=split(UploadFiles,"|")
            UploadFiles=""
            for intTemp=0 to ubound(arrUploadFiles)
                if instr(Content,arrUploadFiles(intTemp))<=0 and arrUploadFiles(intTemp)<>DefaultPicUrl then
                    strRubbishFile=server.MapPath("../" & arrUploadFiles(intTemp))
                    if fso.FileExists(strRubbishFile) then
                        fso.DeleteFile(strRubbishFile)
                        response.write "<br><li>" & arrUploadFiles(intTemp) & "在产品说明中没有用到,也没有被设为首页图片,所以已经被删除!</li>"
                    end if
                else
                    if intTemp=0 then
                        UploadFiles=arrUploadFiles(intTemp)
                    else
                        UploadFiles=UploadFiles & "|" & arrUploadFiles(intTemp)
                    end if
                end if
            next
        else
            if instr(Content,UploadFiles)<=0 and UploadFiles<>DefaultPicUrl then
                strRubbishFile=server.MapPath("../" & UploadFiles)
                if fso.FileExists(strRubbishFile) then
                    fso.DeleteFile(strRubbishFile)
                    response.write "<br><li>" & UploadFiles & "在产品说明中没有用到,也没有被设为首页图片,所以已经被删除!</li>"
                end if
                UploadFiles=""
            end if
        end if
        set fso=nothing
    end If
    '结束
    '***************************************
    if DefaultPicUrl="" then
       rs("DefaultPicUrl")="Img/nopic.gif"
    else   
       rs("DefaultPicUrl")=DefaultPicUrl
    end if   
    rs("UploadFiles")=UploadFiles   
end sub   
%>
搜索更多相关主题的帖子: asp ProductSave 
2009-10-09 11:18
chenguoxing517
Rank: 7Rank: 7Rank: 7
来 自:广东广州
等 级:黑侠
威 望:1
帖 子:154
专家分:619
注 册:2009-9-28
得分:20 
出现什么错误?
2009-10-13 16:16



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-287941-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.310896 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved