?? 復件 update.asp
字號:
<%
'OA 表單生成器1.0
'功能:內部信箱內容提交后處理
'參數:request.form("addedit_subed")="send"#表單提交;
%>
<!--#include file="../inc/Secure.asp"-->
<!--#include file="../inc/conn.asp"-->
<!--#include file="../inc/Const.asp"-->
<%
formPath="./files/"
Set FileObj=Server.CreateObject("DBstep.FileUpLoad") '調用文件上傳組件
'response.buffer=false
'------------------------------------------------設置參數
LoginID=trim(session("LoginID")) : if LoginID="" then LoginID=0 '當前用戶ID
pid=FileObj.Request("id") '記錄ID
pmod=FileObj.Request("mod") '模式(0撰寫,1修改,2回復,3轉發)
if pmod="" then pmod=0
pmod=cint(pmod)
AccessoryID=FileObj.Request("AccessoryID")
if AccessoryID<>"" then
AccessoryID=left(AccessoryID,len(AccessoryID)-1)
end if
'response.write AccessoryID
'------------------------------------------------
if pid<>"" then
'取郵件記錄
'------------------------------------------------取記錄
'取要查看的記錄 (返回rs對象)
table="tbioamail" '表名
set rs=Server.CreateObject("ADODB.RecordSet")
sql="select * from " & table & " where ID="&pid
rs.open sql,oConn,1,1
'------------------------------------------------
'------------------------------------------------標記為已讀
if rs("read_mod")=false then
sql="update " & table & " set read_mod=1 where ID="&pid
oConn.Execute sql
end if
'------------------------------------------------
Select Case pmod
Case 1 '修改
show_nbsjr=rs("nbsjr")'收件人
show_subject=Server.HTMLEncode(rs("subject"))'主題
show_body=Server.HTMLEncode(rs("body"))'內容
Case 2 '回復
show_nbsjr=rs("fjr")
show_subject="Re:"&Server.HTMLEncode(rs("subject"))
show_body=""
Case 3 '轉發
show_nbsjr=""
show_subject="Fw:"&Server.HTMLEncode(rs("subject"))
show_body=vbcrlf&vbcrlf&vbcrlf&vbcrlf&"= = = = = = 下面是轉發郵件 = = = = = = ="&vbcrlf&Server.HTMLEncode(rs("body"))&vbcrlf&"= = = = = = = = = = = = = = = = = = = ="
Case Else
show_nbsjr=""
show_subject=""
show_body=""
End Select
end if
'------------------------------------------------編輯記錄
table="tbioamail" '表名
if FileObj.Request("addedit_subed")="send" then
'發送表單提交后
'接受錄入參數
input_nbsjr=FileObj.Request("input_nbsjr")'內部收件人
input_subject=FileObj.Request("input_subject")'主題
input_body=FileObj.Request("input_body")'內容
input_backup_mod=FileObj.Request("input_backup_mod")'是否保存到寄件夾
if input_backup_mod="" then input_backup_mod=0
input_revert_mod=FileObj.Request("input_revert_mod")'對方讀到信時給我回應
'保存到寄件夾
if input_backup_mod=1 then
'添加時使用的字段
field1=array("userid","fjr","nbsjr","subject","body","folder","revert_mod")
value1=array(LoginID,LoginID,input_nbsjr,input_subject,input_body,"寄件夾",input_revert_mod)
for i=0 to ubound(field1)
value1(i)=replace(value1(i),"'","''")
next
sql = "INSERT INTO " & table & " (" & Join(field1, ",") & ") VALUES ('" & Join(value1, "','") & "')"
oConn.Execute sql
sql = "SELECT @@IDENTITY AS 'Identity'"
set rs=Server.CreateObject("ADODB.RecordSet")
rs.open sql,oconn,1,3
parentID=rs(0)
rs.close
set rs=nothing
for i=1 to cint(FileObj.Request("upcount"))
if FileObj.FileSize("file"&i)>0 then '判斷是否有附件上傳
formPath="./files/"
Set fso = CreateObject("Scripting.FileSystemObject")
if fso.folderexists(server.mappath(formPath&Parentid))=Flase then '判斷目錄是否存在
Fso.Createfolder(server.mappath(formPath&Parentid))
end if
FileObj.FilePath=Server.MapPath(formPath&Parentid&"/")
filename=FileObj.FileName("file"&i) '取得文件上傳文件名
filesavename=DateToStr(now())&i&FileObj.ExtName("file"&i) '文件保存名
'fileStat=FileObj.SaveFile("file"&i,filesavename) '返回文件保存狀態
fileStat = SaveFile(Server.MapPath(formPath&Parentid)&"/"&filesavename,FileObj.FileBody("file"&i)) '返回文件保存狀態
sql = "INSERT INTO tbioaMail_Accessory (parentid,name,filename) VALUES ("&parentID&",'"&filename&"','"&filesavename&"')"
oConn.Execute sql
end if
next
end if
'發送郵件
ary_nbsjr=Split(input_nbsjr,",")'內部收件人列表(數組)
for j=0 to ubound(ary_nbsjr)
'添加時使用的字段
field1=array("userid","fjr","nbsjr","subject","body","folder","revert_mod")
value1=array(trim(ary_nbsjr(j)),LoginID,input_nbsjr,input_subject,input_body,"收件夾",input_revert_mod)
for i=0 to ubound(field1)
value1(i)=replace(value1(i),"'","''")
next
sql = "INSERT INTO " & table & " (" & Join(field1, ",") & ") VALUES ('" & Join(value1, "','") & "')"
oConn.Execute sql
'OA精靈提醒
body="新郵件通知:"&vbcrlf&vbcrlf
body=body&"發件人:"&getusername(LoginID)&vbcrlf
body=body&"發件時間:"&now()&vbcrlf
body=body&"郵件主題:"&input_subject&vbcrlf
'Call AgentSysMsg(trim(ary_nbsjr(j)),body)'OA精靈提醒
sql = "SELECT max(id) from tbioaMail"
set rs=Server.CreateObject("ADODB.RecordSet")
rs.open sql,oconn,1,3
parentID=rs(0)
rs.close
set rs=nothing
for i=1 to cint(FileObj.Request("upcount"))
if FileObj.FileSize("file"&i)>0 then '判斷是否有附件上傳
Set fso = CreateObject("Scripting.FileSystemObject")
if fso.folderexists(server.mappath(formPath&Parentid))=Flase then '判斷目錄是否存在
Fso.Createfolder(server.mappath(formPath&Parentid))
end if
Set fso=nothing
FileObj.FilePath=Server.MapPath(formPath&Parentid&"/")
filename=FileObj.FileName("file"&i) '取得文件上傳文件名
filesavename=DateToStr(now())&i&FileObj.ExtName("file"&i) '文件保存名
'fileStat=FileObj.SaveFile("file"&i,filesavename) '返回文件保存狀態
fileStat = SaveFile(Server.MapPath(formPath&Parentid)&"/"&filesavename,FileObj.FileBody("file"&i)) '返回文件保存狀態
sql = "INSERT INTO tbioaMail_Accessory (parentid,name,filename) VALUES ("&parentID&",'"&filename&"','"&filesavename&"')"
oConn.Execute sql
end if
next
next
'刪除草稿
if pmod=1 then
if AccessoryID<>"" then
Set fso = CreateObject("Scripting.FileSystemObject")
if fso.folderexists(server.mappath(formPath&Parentid))=Flase then '判斷目錄是否存在
Fso.Createfolder(server.mappath(formPath&Parentid))
end if
sql = "SELECT * from tbioaMail_Accessory WHERE id in (" & AccessoryID & ")"
set rs=Server.CreateObject("ADODB.RecordSet")
' response.write sql
rs.open sql,oconn,1,3
do while not rs.eof
set fs = fso.GetFile(server.mappath(formPath&rs("parentID")&"/"&rs("FileName")))
' response.write server.mappath(formPath&Pid&"/"&rs("FileName"))
fs.move (server.mappath(formPath&Parentid&"/"&rs("FileName")))
' response.write server.mappath(formPath&Parentid&"/"&rs("FileName"))
sql="UPDATE tbioaMail_Accessory SET Parentid=" & Parentid & " WHERE id="&rs("id")
' response.write sql
oConn.Execute sql
rs.movenext
loop
rs.close
set fso=nothing
end if
sql = "SELECT * from " & table & " WHERE ID="&pid&" and folder='草稿夾'"
set rs=Server.CreateObject("ADODB.RecordSet")
rs.open sql,oconn,1,3
if not rs.eof then
Parentid=rs("id")
Set fso = CreateObject("Scripting.FileSystemObject")
if fso.folderexists(server.mappath(formPath&Parentid))=true then '判斷目錄是否存在
Fso.DeleteFolder(server.mappath(formPath&Parentid))
end if
set fso=nothing
end if
rs.close
set rs=nothing
oConn.Execute "DELETE FROM " & table & " WHERE ID="&pid&" and folder='草稿夾'"
end if
'發送成功提示信息
if pmod=0 then
word="<p>內部郵件已成功發送!</p><p><img border=0 src=../images/icon_show.gif align=left width=16 height=16><a href=mail_edit.asp>撰寫新郵件</a>"
else
word="<p>內部郵件已成功發送!</p><p><img border=0 src=../images/icon_show.gif align=left width=16 height=16><a href='javascript:history.go(-2)'>返回</a>"
end if
end if
if FileObj.Request("addedit_subed")="save" then
'暫存表單提交后
'接受錄入參數
input_nbsjr=FileObj.Request("input_nbsjr")'內部收件人
input_subject=FileObj.Request("input_subject")'主題
input_body=FileObj.Request("input_body")'內容
input_backup_mod=FileObj.Request("input_backup_mod")'是否保存到寄件夾
input_revert_mod=FileObj.Request("input_revert_mod")'對方讀到信時給我回應
'保存到草稿夾
'修改時使用的字段
field1=array("userid","fjr","nbsjr","subject","body","folder","revert_mod")
value1=array(LoginID,LoginID,input_nbsjr,input_subject,input_body,"草稿夾",input_revert_mod)
if pmod<>1 then
for i=0 to ubound(field1)
value1(i)=replace(value1(i),"'","''")
next
sql = "INSERT INTO " & table & " (" & Join(field1, ",") & ") VALUES ('" & Join(value1, "','") & "')"
oConn.Execute sql
sql = "SELECT @@IDENTITY AS 'Identity'"
set rs=Server.CreateObject("ADODB.RecordSet")
rs.open sql,oconn,1,3
parentID=rs(0)
rs.close
set rs=nothing
else
sql="UPDATE " & table & " SET "
for i=0 to ubound(field1)
sql = sql & field1(i) & "='" & replace(value1(i),"'","''") & "'"
if i <> ubound(field1) then sql=sql & "," else sql=sql & " where id=" & pid
next
oConn.Execute sql
parentID=Pid
end if
for i=1 to cint(FileObj.Request("upcount"))
if FileObj.FileSize("file"&i)>0 then '判斷是否有附件上傳
Set fso = CreateObject("Scripting.FileSystemObject")
if fso.folderexists(server.mappath(formPath&Parentid))=Flase then '判斷目錄是否存在
Fso.Createfolder(server.mappath(formPath&Parentid))
end if
set fso=nothing
FileObj.FilePath=Server.MapPath(formPath&Parentid&"/")
filename=FileObj.FileName("file"&i) '取得文件上傳文件名
filesavename=DateToStr(now())&i&FileObj.ExtName("file"&i) '文件保存名
'fileStat=FileObj.SaveFile("file"&i,filesavename) '返回文件保存狀態
fileStat = SaveFile(Server.MapPath(formPath&Parentid)&"/"&filesavename,FileObj.FileBody("file"&i)) '返回文件保存狀態
sql = "INSERT INTO tbioaMail_Accessory (parentid,name,filename) VALUES ("&parentID&",'"&filename&"','"&filesavename&"')"
oConn.Execute sql
end if
next
'保存成功提示信息
if pmod=1 then
response.redirect "mail_edit.asp?id="&pid&"&mod=1"
response.end
elseif pmod=0 then
word="<p>郵件已成功保存!</p><p><img border=0 src=../images/icon_show.gif align=left width=16 height=16><a href=mail_edit.asp>撰寫新郵件</a>"
else
word="<p>郵件已成功保存!</p><p><img border=0 src=../images/icon_show.gif align=left width=16 height=16><a href='javascript:history.go(-2)'>返回</a>"
end if
end if
set FileObj=nothing
'------------------------------------------------
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" href="../css/main.css" type=text/css>
<title>main</title>
</head>
<body topmargin="10" leftmargin="10">
<table border=0 cellspacing="0" cellpadding="0">
<tr>
<td><img border="0" src="../images/icon_menu.gif" align="left"> 內部信箱->編輯郵件</td>
</tr>
</table>
<hr width="100%" size=1 color="#000000">
<br>
<div align="left">
<table width="580" cellspacing="1" cellpadding="2" class="tab">
<tr>
<td width="20%" class="tdTop">
<table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td class="tdTop">
<p align="left"><img border="0" src="../images/icon_title.gif" align="left">
<%
Select Case pmod
Case 2
response.write("回復郵件")
Case 3
response.write("轉發郵件")
Case Else
response.write("寫郵件")
End Select
%>
</p>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td class="td1">
<table border="0" width="100%" cellspacing="10" cellpadding="0">
<tr>
<td width="36%">
<p align="right"><img border="0" src="../images/edit.gif" width="32" height="32">
</td>
<td width="64%"><p> </p>
<%=word%>
</td>
</tr>
<tr>
<td width="100%" colspan="2">
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td width="25%" class="tdBottom">
</td>
</tr>
</table>
</div>
</body>
</html>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -