📄 savetodb.asp
字号:
<%
'************************************************************************************************
' 文件名: savetodb.asp
' Copyright(c) 2001-2002 上海阿尔卡特网络支援系统有限公司
' 创建人 : 周秋舫
' 日 期 : 2002-08-15
' 修改历史 :
' ****年**月**日 ****** 修改内容:**************************************************
' 功能描述 : 将公文信息更新到数据库,包括文件也上载到数据库
' 版 本 :
'************************************************************************************************
option explicit
Response.CacheControl = "no-cache"
Response.AddHeader "Pragma", "no-cache"
Response.Expires = -1
%>
<!-- #include file="../include/config.inc" -->
<!-- #include file="../include/common.inc" -->
<!-- #include file="../include/debug.inc" -->
<!-- #include file="../include/db.inc" -->
<!-- #include file="../include/date.inc" -->
<!-- #include file="../include/datahandle.inc" -->
<!-- #include file="../include/recordlist.inc" -->
<!-- #include file="../include/security.inc" -->
<!-- #include file="file.inc" -->
<!-- #include file="upload.inc"-->
<%
call CheckSecurity()
'' 获取本人的姓名
dim sUserName : sUserName = GetUserName
Response.Buffer = TRUE
Response.Clear
'' ******************************************************************************************************
'' 获取上传文件及其它各种数据
'' -----------------------------------------------------------------------------------------------------------------------------------------------
dim byteCount : byteCount = Request.TotalBytes
dim RequestBin : RequestBin = Request.BinaryRead(byteCount)
dim UploadRequest : set UploadRequest = CreateObject("Scripting.Dictionary")
BuildUploadRequest RequestBin
'' ******************************************************************************************************
'' 公文登记信息
'' ******************************************************************************************************
dim DocTypeId : DocTypeId = UploadRequest.Item("doc_type_id").Item("Value")
dim DocUrgentLevel : DocUrgentLevel = UploadRequest.Item("doc_urgent_level").Item("Value")
dim DocSecretLevel : DocSecretLevel = UploadRequest.Item("doc_secret_level").Item("Value")
dim DocNumber : DocNumber = UploadRequest.Item("doc_number").Item("Value")
dim DocKeyword : DocKeyword = UploadRequest.Item("doc_keyword").Item("Value")
dim DocReportPerson : DocReportPerson = UploadRequest.Item("doc_report_person").Item("Value")
dim DocSendPerson : DocSendPerson = UploadRequest.Item("doc_send_person").Item("Value")
dim DocSender : DocSender = UploadRequest.Item("doc_sender").Item("Value")
dim DocSentDate : DocSentDate = UploadRequest.Item("doc_sent_date").Item("Value")
'' 公文文件有关的信息
dim DocContent : DocContent = UploadRequest.Item("content").Item("Value")
dim DocContentType : DocContentType = UploadRequest.Item("content").Item("ContentType")
dim DocPathName : DocPathName = UploadRequest.Item("content").Item("FileName")
dim DocName : DocName = Right(DocPathName,Len(DocPathName)-InstrRev(DocPathName,"\"))
dim DocSize : DocSize = LenB(DocContent)
'' 文件后缀名称
dim DocExtension
if InStr(DocName, ".") = 0 then
DocExtension = ""
else
DocExtension = Right(DocName,Len(DocName)-InstrRev(DocName,"."))
end if
'' ******************************************************************************************************
'' 公文附件信息
'' -----------------------------------------------------------------------------------------------------------------------------------------------
dim attach_1_content : attach_1_content = UploadRequest.Item("attach_1").Item("Value")
dim attach_2_content : attach_2_content = UploadRequest.Item("attach_2").Item("Value")
dim attach_3_content : attach_3_content = UploadRequest.Item("attach_3").Item("Value")
dim attach_4_content : attach_4_content = UploadRequest.Item("attach_4").Item("Value")
dim attach_5_content : attach_5_content = UploadRequest.Item("attach_5").Item("Value")
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'' 公文附件一
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
dim attach_1_flag, attach_1_contenttype, attach_1_pathname, attach_1_filename, attach_1_filesize, attach_1_ext
if LenB(attach_1_content) > 0 then
: attach_1_flag = true
attach_1_contenttype = UploadRequest.Item("attach_1").Item("ContentType")
attach_1_pathname = UploadRequest.Item("attach_1").Item("FileName")
attach_1_filename = Right(attach_1_pathname,Len(attach_1_pathname)-InstrRev(attach_1_pathname,"\"))
attach_1_filesize = LenB(attach_1_content)
'' 文件后缀名称
if InStr(attach_1_filename, ".") = 0 then
attach_1_ext = ""
else
attach_1_ext = Right(attach_1_filename,Len(attach_1_filename)-InstrRev(attach_1_filename,"."))
end if
end if
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'' 公文附件二
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
dim attach_2_flag, attach_2_contenttype, attach_2_pathname, attach_2_filename, attach_2_filesize, attach_2_ext
if LenB(attach_2_content) > 0 then
attach_2_flag = true
attach_2_contenttype = UploadRequest.Item("attach_2").Item("ContentType")
attach_2_pathname = UploadRequest.Item("attach_2").Item("FileName")
attach_2_filename = Right(attach_2_pathname,Len(attach_2_pathname)-InstrRev(attach_2_pathname,"\"))
attach_2_filesize = LenB(attach_1_content)
'' 文件后缀名称
if InStr(attach_2_filename, ".") = 0 then
attach_2_ext = ""
else
attach_2_ext = Right(attach_2_filename,Len(attach_2_filename)-InstrRev(attach_2_filename,"."))
end if
end if
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'' 公文附件三
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
dim attach_3_flag, attach_3_contenttype, attach_3_pathname, attach_3_filename, attach_3_filesize, attach_3_ext
if LenB(attach_3_content) > 0 then
attach_3_flag = true
attach_3_contenttype = UploadRequest.Item("attach_3").Item("ContentType")
attach_3_pathname = UploadRequest.Item("attach_3").Item("FileName")
attach_3_filename = Right(attach_3_pathname,Len(attach_3_pathname)-InstrRev(attach_3_pathname,"\"))
attach_3_filesize = LenB(attach_1_content)
'' 文件后缀名称
if InStr(attach_3_filename, ".") = 0 then
attach_3_ext = ""
else
attach_3_ext = Right(attach_3_filename,Len(attach_3_filename)-InstrRev(attach_3_filename,"."))
end if
end if
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'' 公文附件四
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
dim attach_4_flag, attach_4_contenttype, attach_4_pathname, attach_4_filename, attach_4_filesize, attach_4_ext
if LenB(attach_4_content) > 0 then
attach_4_flag = true
attach_4_contenttype = UploadRequest.Item("attach_4").Item("ContentType")
attach_4_pathname = UploadRequest.Item("attach_4").Item("FileName")
attach_4_filename = Right(attach_4_pathname,Len(attach_4_pathname)-InstrRev(attach_4_pathname,"\"))
attach_4_filesize = LenB(attach_1_content)
'' 文件后缀名称
if InStr(attach_4_filename, ".") = 0 then
attach_4_ext = ""
else
attach_4_ext = Right(attach_4_filename,Len(attach_4_filename)-InstrRev(attach_4_filename,"."))
end if
end if
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'' 公文附件五
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
dim attach_5_flag, attach_5_contenttype, attach_5_pathname, attach_5_filename, attach_5_filesize, attach_5_ext
if LenB(attach_5_content) > 0 then
attach_5_flag = true
attach_5_contenttype = UploadRequest.Item("attach_5").Item("ContentType")
attach_5_pathname = UploadRequest.Item("attach_5").Item("FileName")
attach_5_filename = Right(attach_5_pathname,Len(attach_5_pathname)-InstrRev(attach_5_pathname,"\"))
attach_5_filesize = LenB(attach_1_content)
'' 文件后缀名称
if InStr(attach_5_filename, ".") = 0 then
attach_5_ext = ""
else
attach_5_ext = Right(attach_5_filename,Len(attach_5_filename)-InstrRev(attach_5_filename,"."))
end if
end if
'' ******************************************************************************************************
'' ******************************************************************************************************
'' 上传数据库
'' -----------------------------------------------------------------------------------------------------------------------------------------------
dim iDocSerial, oCn, cn, objRst
set oCn = New CDBConnection
oCn.Connect(dbLocal)
set cn = oCn.m_DBConn
set objRst = server.createobject("adodb.recordset")
'' 公文信息提交到数据库
objrst.Open "t_document", cn, adOpenKeyset, adLockOptimistic, 2
objrst.addnew
objrst.fields("doc_type_id") = DocTypeId '' 公文类型
objrst.fields("doc_subject") = DocName '' 公文主题
objrst.fields("doc_number") = DocNumber '' 公文字号
objrst.fields("doc_urge_level") = DocUrgentLevel '' 紧急程度
objrst.fields("doc_secret_level") = DocSecretLevel '' 秘密程度
objrst.fields("doc_keyword") = DocKeyword '' 关键字
objrst.fields("doc_report_person") = DocReportPerson '' 抄报人员
objrst.fields("doc_send_person") = DocSendPerson '' 抄送人员
objrst.fields("doc_sender") = DocSender '' 公文印发单位
objrst.fields("doc_sent_date") = DocSentDate '' 公文印发日期
objrst.fields("doc_reg_person") = sUserName '' 公文登记员
objrst.fields("doc_reg_date") = now '' 公文登记时间
objrst.fields("content").appendchunk DocContent '' 公文内容
objrst.fields("contenttype") = DocContentType '' 公文文件内容的类型
objrst.fields("filetype") = DocExtension '' 公文文件类型,即文件后缀名
objrst.fields("filesize") = DocSize '' 公文文件大小
objrst.update
'' 获取刚刚提交的公文的标识
'iDocSerial = objrst.fields("doc_id") '' 用这个方法为什么取不到呢?
objrst.close
iDocSerial = cn.Execute("select max(doc_id) from t_document where doc_reg_person = " & ToSQL(sUserName,"Text")).fields(0).value
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'' 上传公文附件
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
objrst.Open "t_doc_attachment", cn, 1, 3, 2
'' 公文附件一
if attach_1_flag = true then
objrst.addnew
objrst.fields("doc_id") = iDocSerial
objrst.fields("attach_subject") = attach_1_filename
objrst.fields("content").appendchunk attach_1_content
objrst.fields("contenttype") = attach_1_contenttype
objrst.fields("filetype") = attach_1_ext
objrst.fields("filesize") = attach_1_filesize
objrst.update
end if
'' 公文附件二
if attach_2_flag = true then
objrst.addnew
objrst.fields("doc_id") = iDocSerial
objrst.fields("attach_subject") = attach_2_filename
objrst.fields("content").appendchunk attach_2_content
objrst.fields("contenttype") = attach_2_contenttype
objrst.fields("filetype") = attach_2_ext
objrst.fields("filesize") = attach_2_filesize
objrst.update
end if
'' 公文附件三
if attach_3_flag = true then
objrst.addnew
objrst.fields("doc_id") = iDocSerial
objrst.fields("attach_subject") = attach_3_filename
objrst.fields("content").appendchunk attach_3_content
objrst.fields("contenttype") = attach_3_contenttype
objrst.fields("filetype") = attach_3_ext
objrst.fields("filesize") = attach_3_filesize
objrst.update
end if
'' 公文附件四
if attach_4_flag = true then
objrst.addnew
objrst.fields("doc_id") = iDocSerial
objrst.fields("attach_subject") = attach_4_filename
objrst.fields("content").appendchunk attach_4_content
objrst.fields("contenttype") = attach_4_contenttype
objrst.fields("filetype") = attach_4_ext
objrst.fields("filesize") = attach_4_filesize
objrst.update
end if
'' 公文附件五
if attach_5_flag = true then
objrst.addnew
objrst.fields("doc_id") = iDocSerial
objrst.fields("attach_subject") = attach_5_filename
objrst.fields("content").appendchunk attach_5_content
objrst.fields("contenttype") = attach_5_contenttype
objrst.fields("filetype") = attach_5_ext
objrst.fields("filesize") = attach_5_filesize
objrst.update
end if
objrst.close
set objrst=nothing
oCn.Disconnect()
'' 转向刚刚上传的文件,显示该文件的属性
Response.Redirect "doc_p.asp?doc_id=" & iDocSerial & "&"
'' ******************************************************************************************************
%>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -