<!--#include file="islogin.asp"-->
<!--#INCLUDE FILE="fupload.asp"-->
<%
Response.Expires =0

if Request.ServerVariables("REQUEST_METHOD") = "POST" Then
	
	if CLng(Request.ServerVariables("HTTP_Content_Length"))>10240 then
		call deal_msg("公文档案",0,"发送不成功,附件不能超过10k!")
	end if
	
	Dim Fields,doc_id,sh_id,way,doc_type,drafter,phone,department,title,filetitle,priority,secrecy,addfile_name,addfile_type,addfile_size,addfile_content,content,audit_dept,auditor	
	dim from_dept,from_comp,doc_word,doc_serial_recv,keyword_recv,postil
	dim send_type,doc_header,doc_serial_send,sendto_main,sendto_copy,keyword_send,note
	dim room_address,conferee,meet_time,meet_time_total,organizer,compere,recorder,res,collator,toman
	dim use_time,man_num,start_addr,des_addr
	dim sql,rs,page
	UploadSizeLimit=10000000
	Set Fields = GetUpload()
	dim Field
	
	For Each Field In Fields.Items
		select case Field.name
		case "page":
			page=trim(BinaryToString(Field.value))
		case "doc_id":
			doc_id=trim(BinaryToString(Field.value))
		case "sh_id":
			sh_id=trim(BinaryToString(Field.value))
		case "way":
			way=trim(BinaryToString(Field.value))
		case "doc_type":
			doc_type=trim(BinaryToString(Field.value))
		case "Drafter":
			drafter=trim(BinaryToString(Field.value))
		case "Phone":
			phone=trim(BinaryToString(Field.value))
		case "Department":
			department=trim(BinaryToString(Field.value))		
		case "Title":
			title=trim(BinaryToString(Field.value))
		case "fileTitle":
			filetitle=trim(BinaryToString(Field.value))
		case "Priority":
			priority=trim(BinaryToString(Field.value))		
		case "Secrecy":
			secrecy=trim(BinaryToString(Field.value))
			if(secrecy="") then	secrecy=0
		case "Content":
			content=trim(BinaryToString(Field.value))
		case "Audit_dept":
			audit_dept=trim(BinaryToString(Field.value))
		case "Auditor":
			auditor=trim(BinaryToString(Field.value))
		case "From_dept":
			from_dept=trim(BinaryToString(Field.value))
		case "From_comp":
			from_comp=trim(BinaryToString(Field.value))
		case "Doc_word":
			doc_word=trim(BinaryToString(Field.value))
		case "Doc_serial_send":
			doc_serial_send=trim(BinaryToString(Field.value))
		case "Doc_serial_recv":
			doc_serial_recv=trim(BinaryToString(Field.value))
		case "Keyword_recv":
			keyword_recv=trim(BinaryToString(Field.value))
		case "Keyword_send":
			keyword_send=trim(BinaryToString(Field.value))
		case "Postil":
			postil=trim(BinaryToString(Field.value))
		case "Send_type":
			send_type=trim(BinaryToString(Field.value))
		case "Doc_header":
			doc_header=trim(BinaryToString(Field.value))
		case "Sendto_main":
			sendto_main=trim(BinaryToString(Field.value))
		case "Sendto_copy":
			sendto_copy=trim(BinaryToString(Field.value))
		case "Note":
			note=trim(BinaryToString(Field.value))
		case "Room_address":
			room_address=trim(BinaryToString(Field.value))
		case "Conferee":
			conferee=trim(BinaryToString(Field.value))
		case "Meet_time":
			meet_time=trim(BinaryToString(Field.value))
		case "Meet_time_total":
			Meet_time_total=trim(BinaryToString(Field.value))
		case "Organizer":
			organizer=trim(BinaryToString(Field.value))
		case "Compere":
			compere=trim(BinaryToString(Field.value))
		case "Recorder":
			recorder=trim(BinaryToString(Field.value))
		case "Res":
			res=trim(BinaryToString(Field.value))
		case "Collator":
			collator=trim(BinaryToString(Field.value))
		case "Toman":
			toman=trim(BinaryToString(Field.value))
		case "Use_time":
			use_time=trim(BinaryToString(Field.value))
		case "Man_num":
			man_num=trim(BinaryToString(Field.value))
		case "Start_addr":
			start_addr=trim(BinaryToString(Field.value))
		case "Des_addr":
			des_addr=trim(BinaryToString(Field.value))
		case "Addfile":
			addfile_name=trim(field.FileName)
			addfile_type=trim(field.ContentType)
			addfile_size=trim(field.Length)
			addfile_content=trim(field.value)
		end select
	next
		
	'--------------------------------------
	'response.write "title=" & title & "<br>"
	'response.write "content=" & content & "<br>"
	'response.write "sendto=" & sendto & "<br>"
	'response.write "filedname=" & filename & "<br>"
	'response.write "fileContentType=" & fileContentType & "<br>"
	'----------------------------------------
	
	connect_db()
	call get_recordset(rs)
	'Response.Write "type:"&doc_type&"<br>"&doc_id
	'Response.End 
	select case doc_type
	case 1:		
		sql = "select * from tb_doc_recv where id="	&doc_id
		rs.Open sql,conn,1,2
		'rs.addnew		
		'rs("doc_type")=doc_type		
		'rs("drafter")=drafter
		rs("phone")=phone
		rs("department")=department		
		rs("title")=title		
		rs("priority")=priority		
		rs("from_dept")=from_dept				
		rs("from_comp")=from_comp				
		rs("doc_serial")="["&doc_word&"]"&doc_serial_recv		
		rs("keyword")=keyword_recv		
		rs("postil")=postil
		'Response.Write "type:"&doc_type&"<br>"&doc_id
		'Response.End 				
		rs("content")=content
		'rs("audit_dept")=audit_dept
		'rs("auditor")=auditor
		rs("secrecy")=secrecy
		if filetitle<>"" then
		rs("addfile_name")=filetitle
		end if
		if addfile_name<>"" then
			rs("addfile_name")=addfile_name
			rs("addfile_type")=addfile_type
			rs("addfile_size")=addfile_size
			rs("addfile_content").appendchunk addfile_content
		end if		
		rs.update		
		rs.close()
	case 2:
		
		sql = "select * from tb_doc_send where id="&doc_id
		conn.BeginTrans		
		rs.Open sql,conn,1,2		
		dim rec_flag,posttime,source_id
		
		doc_type=rs("doc_type")		
		drafter=rs("drafter")
		source_id=rs("source_id")
		audit_dept=rs("audit_dept")
		auditor=rs("auditor")
		posttime=rs("posttime")		
		if trim(rs("addfile_name"))<>"" and addfile_name="" and trim(source_id)=trim(doc_id) then
			addfile_name=rs("addfile_name")
			addfile_type=rs("addfile_type")
			addfile_size=rs("addfile_size")
		end if
		
		if trim(source_id)=trim(doc_id) then
			rs("doc_active")=0
			rs.update
			rs.addnew			
		end if
				
		rs("doc_type")=doc_type
		rs("drafter")=drafter
		rs("phone")=phone
		rs("department")=department
		rs("posttime")=posttime
		rs("title")=title
		rs("priority")=priority		
		rs("content")=content
		rs("audit_dept")=audit_dept
		rs("auditor")=auditor
		rs("secrecy")=secrecy
		rs("send_type")=send_type
		rs("doc_header")=doc_header
		rs("doc_serial")="["&doc_word&"]"&doc_serial_send
		rs("keyword")=keyword_send
		rs("sendto_main")=sendto_main
		rs("sendto_copy")=sendto_copy
		rs("note")=note
		rs("source_id")=source_id
		if filetitle<>"" then
		rs("addfile_name")=filetitle
		end if

		if addfile_name<>"" then
			rs("addfile_name")=addfile_name
			rs("addfile_type")=addfile_type
			rs("addfile_size")=addfile_size
		end if
		rs("doc_active")=1
		rs.update
		doc_id=rs("id")		
		rs.close
		
		sql="select * from tb_doc_audit where id="&sh_id
		rs.Open sql,conn,1,2
		rs("modify_time")=now()
		rs("modify_id")=doc_id
		rs("isedit")=1
		rs.update()
		rs.close
		conn.CommitTrans
	case 3:
		sql="insert into tb_meet_send(doc_type,drafter,phone,department,title,priority,room_address,conferee,meet_time,meet_time_total,organizer,compere,recorder,res,collator,toman,content,audit_dept,auditor) values ('"&doc_type&"','"&drafter&"','"&phone&"','"&department&"','"&title&"','"&priority&"','"&room_address&"','"&conferee&"','"&meet_time&"','"&meet_time_total&"','"&organizer&"','"&compere&"','"&recorder&"','"&res&"','"&collator&"','"&toman&"','"&content&"','"&audit_dept&"','"&auditor&"')"
		conn.Execute(sql)
	case 4:
		sql="insert into tb_car_askuse(doc_type,drafter,phone,department,title,priority,use_time,man_num,start_addr,des_addr,content,audit_dept,auditor) values ('"&doc_type&"','"&drafter&"','"&phone&"','"&department&"','"&title&"','"&priority&"','"&content&"','"&audit_dept&"','"&auditor&"')"		
		conn.Execute(sql)
	case 5,6,7,8,9,10,11,12:			
		sql="insert into tb_doc_request(doc_type,drafter,phone,department,title,priority,content,audit_dept,auditor) values ('"&doc_type&"','"&drafter&"','"&phone&"','"&department&"','"&title&"','"&priority&"','"&content&"','"&audit_dept&"','"&auditor&"')"		
		conn.Execute(sql)
	end select
		
	set rs=nothing
	close_db()
	select case way
	case 1:
		Response.Redirect "swcl_show.asp?doc_id="&doc_id&"&page="&page
	case 2:
		Response.Redirect "fwng_show.asp?doc_id="&doc_id&"&page="&page&"&sh_id="&sh_id
	end select
	
	if Err.number <> 0 then
		close_db()
		call deal_msg("公文档案",0,"数据库错误,修改不成功!")
	end if
	call deal_msg("公文档案",0,"修改成功!")
end if
%>