apzl_leasing/WebContent/AppConfig/Document/UpdateAttachmentUpload.jsp
2018-06-03 22:26:41 +08:00

57 lines
2.3 KiB
Plaintext

<%@page import="java.net.URLDecoder"%>
<%@page import="com.amarsoft.are.jbo.impl.BizObjectTableMapper"%>
<%@page import="com.amarsoft.awe.util.DBKeyHelp"%>
<%@page import="com.amarsoft.awe.common.attachment.*"%>
<%@ page contentType="text/html; charset=GBK"%>
<%@ include file="/IncludeBegin.jsp"%><%
AmarsoftUpload myAmarsoftUpload = new AmarsoftUpload();
myAmarsoftUpload.initialize(pageContext);
myAmarsoftUpload.upload();
String sDocNo = (String)myAmarsoftUpload.getRequest().getParameter("DocNo"); //文档编号
String sAttachmentNo = (String)myAmarsoftUpload.getRequest().getParameter("AttachmentNo"); //文档编号
List<BizObject> list = JBOFactory.createBizObjectQuery("jbo.sys.DOC_ATTACHMENT",
"select * from O where DOCNO=:DOCNO and ATTACHMENTNO=:ATTACHMENTNO ")
.setParameter("DOCNO", sDocNo).setParameter("ATTACHMENTNO", sAttachmentNo).getResultList(false);
BizObject attchment=list.get(0);
BizObjectManager bm = JBOFactory.getBizObjectManager("jbo.sys.DOC_ATTACHMENT");
String trueTable = ((BizObjectTableMapper)bm).getTable(); //取得真实的表名
//定义数据库操作变量
SqlObject so = null;
String sNewSql = "";
String sFileSaveMode = CurConfig.getConfigure("FileSaveMode");
String sFileSavePath = CurConfig.getConfigure("FileSavePath");
String sFileNameType = CurConfig.getConfigure("FileNameType");
if (!myAmarsoftUpload.getFiles().getFile(0).isMissing()){
try {
if(sFileSaveMode.equals("Disk")){ //存放文件服务器中
String sFilePath=sFileSavePath+attchment.getAttribute("fullpath").getString();
System.out.println(sFilePath);
myAmarsoftUpload.getFiles().getFile(0).saveAs(sFilePath);
}
if(sFileSaveMode.equals("Table")){ //存放数据表中
myAmarsoftUpload.getFiles().getFile(0).fileToField(Sqlca,"update "+trueTable+" set DocContent=? where DocNo='"+sDocNo+"' and AttachmentNo='"+sAttachmentNo+"'");
}
myAmarsoftUpload = null;
}catch(Exception e){
myAmarsoftUpload = null;
%>
<script type="text/javascript">
alert(getMessageText('AWEW1010'));//上传文件失败!
parent.AsDialog.ClosePage();
</script>
<%
}
}
%>
<script type="text/javascript">
alert(getMessageText('AWEW1013'));//上传文件成功!
// parent.AsDialog.ClosePage();
parent.reloadAttachment();
</script>
<%@ include file="/IncludeEnd.jsp"%>