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

📄 addattachdo.asp

📁 功能齐全的oa系统
💻 ASP
字号:
<!--#include virtual="include/DataEnvi.asp"-->
<!--#include virtual="include/function.asp"-->

<%
	Dim RootPath
	Dim BasePath
	Dim KeyPath
	Dim FileFold
	Dim ObjFS
	Dim IDs
	Dim ObjCrm,StrSqlCrm
	

	Dim StrFileName,Source
	Dim ObjDB,ObjRS,StrSQL
	
	Set conn=Server.CreateObject("ADODB.Connection")
	OpenDBCrm( conn )
	
	Set ObjFS = Server.CreateObject("Scripting.FileSystemObject")
	Set ObjUpload = Server.CreateObject("LyfUpload.UploadFile")

	RootPath = "Files"
	BasePath	 =	ObjUpload.Request("BasePath")
	IDs = ObjUpload.Request("IDs")
	If BasePath = "" Then BasePath = "Default"

	FileFold= Server.MapPath(RootPath&"/"&BasePath)
	If	Not ObjFS.FolderExists(FileFold) Then
		ObjFS.CreateFolder(FileFold)
	End If

	Randomize
	KeyPath	=	Year(Date()) & Month(Date()) & Day(Date())
	KeyPath	=	KeyPath & Hour(Time()) & Minute(Time()) & Second(Time())
	KeyPath	=	KeyPath & (20000-Cint(10000*Rnd))


	FileFold = Server.MapPath(RootPath&"/"&BasePath&"/"&KeyPath)
	If	Not ObjFS.FolderExists(FileFold) Then
		ObjFS.CreateFolder(FileFold)
	End If

	StrFileName = ObjUpload.SaveFile("source",FileFold,true) '保存文件到服务器
	IntFileSize = ObjUpload.FileSize
	


	If StrFileName = "" Then
		StrErr = "文件上传失败!"
	ElseIf StrFileName = "0"  Then
		StrErr = "文件尺寸过大!"
	End if

	If StrErr <> "" Then
		ObjFS.DeleteFolder(FileFold)	
		Response.Write StrErr & "<input type=button value='返回' onclick='window.close()'>"
		Response.End 
	End If

	Set ObjDB = Server.CreateObject("Adodb.Connection")
	OpenDB ObjDB
	StrSQL = "Insert Into t_OA_Attach (FileName,FileSize,BasePath,KeyPath,AccountID) Values ('" & StrFileName & "','" & IntFileSize & "','" & BasePath & "','" & KeyPath & "','" & Session("AccountID") & "')"
	ObjDB.Execute StrSQL
    '-------------------------------------------------------------------------------
	'在操作完OA中的t_OA_Attach表中的记录后马上修改Kingcrm库中t_crm_Bargain表中相应的记录
	if (Session("t_crm_Bargain_id")<>"") Then
		StrSqlCrm= "Select * From t_crm_Bargain Where ID= "&Cint(Session("t_crm_Bargain_id"))
		Set ObjCrm=Server.CreateObject("Adodb.RecordSet")
		ObjCrm.Open StrSqlCrm,conn,1,3
		ObjCrm("Attachs")=ObjCrm("Attachs")&","&KeyPath
		ObjCrm.Update
		ObjCrm.Close
		Set ObjCrm=Nothing
		conn.Close
		Set conn=Nothing
	End if
	'--------------------------------------------------------------------------------

	StrSQL = "Select Top 1 ID From t_OA_Attach Order By ID Desc"
	Set ObjRS = ObjDB.Execute(StrSQL)
	IntID = ObjRS("ID")
	If IDs="" Then
		IDs = KeyPath
	Else
		IDs = IDs & "," & KeyPath
	End If
	Response.Redirect "AddNew.asp?IDs=" & IDs & "&BasePath=" & BasePath
%>

⌨️ 快捷键说明

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