⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 savetodb.asp

📁 物业管理和办公自动化系统
💻 ASP
字号:
<%
'************************************************************************************************
' 文件名: savetodb.asp
' Copyright(c) 2001-2002 上海阿尔卡特网络支援系统有限公司

'  创建人 : 周秋舫
'  日 期 : 2002-08-15
' 修改历史 :蔡晓燕
'   2002年11月19日 ****** 修改内容:**************************************************
' 功能描述 : 新增维保计划,将维保计划信息添加到数据库,包括附件也上载到数据库
'  版 本 :
'************************************************************************************************
option explicit
Response.CacheControl = "no-cache"
Response.AddHeader "Pragma", "no-cache"
Response.Expires = -1
%>

<!-- #include file="../include/common.inc" -->
<!-- #include file="../include/file.inc" -->
<!-- #include file="../include/upload.inc"--> 

<% 
call CheckSecurity()
if hasright(ID_EQUIPMENT) < RIGHT_WRITE  then
	Response.Write _
			"<script language=""javascript"">" & vbLF & _
			"		alert(""对不起,您没有添加系统维保计划的权限(您的角色没有设备更新的权限)!"");" & vbLF & _
			"</script>" & vbLF
	Response.end
end if

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 iPeriod			: iPeriod = UploadRequest.Item("period").Item("Value")
dim dNexttime		: dNexttime = UploadRequest.Item("nexttime").Item("Value")
dim sContent		: sContent = UploadRequest.Item("content").Item("Value")
dim iPlanhours		: iPlanhours = UploadRequest.Item("planhours").Item("Value")
dim iLimitdays		: iLimitdays = UploadRequest.Item("limitdays").Item("Value")
dim iDepartment		: iDepartment = UploadRequest.Item("department").Item("Value")
dim iRemind			: iRemind = UploadRequest.Item("remind").Item("Value")
dim sRemark			: sRemark = UploadRequest.Item("remark").Item("Value")
dim iEquiSysId		: iEquiSysId = UploadRequest.Item("id").Item("Value")
dim iObjecttype		: iObjecttype = UploadRequest.Item("objecttype").Item("Value")

'' ******************************************************************************************************
'' 维保计划附件信息
'' -----------------------------------------------------------------------------------------------------------------------------------------------
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_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 objRst, iPlanId
dim conn
set conn = DBConnection
set objRst = server.createobject("adodb.recordset")

'' 维保计划信息提交到数据库
objrst.Open "t_maintain", conn, adOpenKeyset, adLockOptimistic, 2
objrst.addnew
objrst.fields("period") = iPeriod							'' 公文类型
objrst.fields("nexttime") = dNexttime							'' 公文类型
objrst.fields("content") = sContent							'' 公文主题
objrst.fields("plan_hours") = iPlanhours					'' 公文字号
objrst.fields("limit_days") = iLimitdays				'' 紧急程度
objrst.fields("remindmethod") = iRemind			'' 秘密程度
objrst.fields("department") = iDepartment						'' 关键字
objrst.fields("remark") = sRemark		'' 抄报人员
objrst.fields("equi_sys_id") = iEquiSysId			'' 抄送人员
objrst.fields("object_type") = iObjecttype							'' 公文印发单位
objrst.update 

'' 获取刚刚提交的维保计划的标识
'iDocSerial = objrst.fields("doc_id")	'' 用这个方法为什么取不到呢?
objrst.close
dim sSQL
sSQL = "select plan_id from t_maintain where equi_sys_id = " & ToSQL(iEquiSysId,"Number") & " and object_type = " & ToSQL(iObjecttype,"Number")
'response.write sSQL
'response.end
iPlanId = conn.Execute(sSQL).fields(0).value


'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'' 上传维保计划附件
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
objrst.Open "t_maintain_attachment", conn, 1, 3, 2

'' 维保附件一
if attach_1_flag = true then
	objrst.addnew
	objrst.fields("plan_id") = iPlanId
	objrst.fields("attach_name") = attach_1_filename
'有两种方法获取content的内容,
'一种是分段获取,好处是:当系统内存有限时,可以确保上传成功;缺点是:代码较复杂,速度较慢。
'代码如下:
'	Const conChunkSize = 102400
'	dim lngOffset, varChunk
'	lngOffset = 0
'	do while lngOffset < attach_1_filesize
'	     varChunk = LeftB(RightB(attach_1_content, attach_1_filesize - lngOffset),conChunkSize)
'		 objrst.fields("content").AppendChunk varChunk
'		 lngOffset = lngOffset + conChunkSize
'	loop
'另一种是一次获取,好处是:速度较第一种快,代码简单;缺点是:有时候上传大文件会失败。
'代码如下:
	objrst.fields("content").appendchunk attach_1_content
	objrst.fields("content_type") = attach_1_contenttype
	objrst.fields("file_type") = attach_1_ext
	objrst.fields("file_size") = attach_1_filesize
	objrst.update
end if

'' 维保附件二
if attach_2_flag = true then
	objrst.addnew
	objrst.fields("plan_id") = iPlanId
	objrst.fields("attach_name") = attach_2_filename
	objrst.fields("content").appendchunk attach_2_content
	objrst.fields("content_type") = attach_2_contenttype
	objrst.fields("file_type") = attach_2_ext
	objrst.fields("file_size") = attach_2_filesize
	objrst.update
end if

'' 维保附件三
if attach_3_flag = true then
	objrst.addnew
	objrst.fields("plan_id") = iPlanId
	objrst.fields("attach_name") = attach_3_filename
	objrst.fields("content").appendchunk attach_3_content
	objrst.fields("content_type") = attach_3_contenttype
	objrst.fields("file_type") = attach_3_ext
	objrst.fields("file_size") = attach_3_filesize
	objrst.update
end if


objrst.close
set objrst=nothing
Disconnect(conn)
response.redirect "updatesysplan.asp?objecttype="&iObjectType&"&id="&iEquiSysId
'' ******************************************************************************************************
%> 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -