EAS BOS套打设置

     /** 
     * output actionPrintPreview_actionPerformed 
     */  
    public void actionPrintPreview_actionPerformed(ActionEvent e)  
            throws Exception {  
        // super.actionPrintPreview_actionPerformed(e);  
        if (this.editData.getId() == null) {  
            SysUtil.abort();  
        }  
        ArrayList idList = new ArrayList();  
  
        if (this.editData != null) {  
            idList.add(this.editData.getId().toString());  
        }  
  
        if (idList == null || idList.size() == 0)  
            return;  
  
        // 定义ExampleProvider实例  
        BOSQueryDelegate data = new ExampleProvider(idList);  
        // 定义printer控件  
        KDNoteHelper appHlp = new KDNoteHelper();  
  
        // 指定打印模板example的相对路径、数据provider类、窗体句柄  
        // 调用打印功能  
        appHlp.printPreview("/bim/coscsc/Offer", data, SwingUtilities  
                .getWindowAncestor(this));  
  
    }  
  
    class ExampleProvider implements BOSQueryDelegate {  
  
        // 建议使用query  
        private IMetaDataPK mpk = new MetaDataPK(  
                "com.kingdee.eas.coscsc.app.OfferQuery");  
  
        private Set ids = null;  
  
        public ExampleProvider(List id) {  
            this.ids = new HashSet(id);  
        }  
  
        // 实现接口BOSQueryDelegate的execute方法  
        public IRowSet execute(BOSQueryDataSource ds) {  
            IRowSet iRowSet = null;  
            String filterId = "id";  
            String sortField = "id";  
            if(ds.getID().equalsIgnoreCase("OfferE5Query.bos-query")){  
                mpk = new MetaDataPK(  
                "com.kingdee.eas.coscsc.app.OfferE5Query");  
                filterId = "parent.id";  
                sortField = "SEQ";  
            }else if(ds.getID().equalsIgnoreCase("OfferE3Query.bos-query")){  
                mpk = new MetaDataPK(  
                "com.kingdee.eas.coscsc.app.OfferE3Query");  
                filterId = "parent.id";  
            }else if(ds.getID().equalsIgnoreCase("OfferE4Query.bos-query")){  
                mpk = new MetaDataPK(  
                "com.kingdee.eas.coscsc.app.OfferE4Query");  
                filterId = "parent.id";  
            }else if(ds.getID().equalsIgnoreCase("OfferE6Query.bos-query")){  
                mpk = new MetaDataPK(  
                "com.kingdee.eas.coscsc.app.OfferE6Query");  
                filterId = "parent.id";  
            }  
            try {  
                // 动态查询执行器  
                IQueryExecutor exec = QueryExecutorFactory  
                        .getRemoteInstance(mpk);  
  
                // 自动转换查询中的枚举字段  
                exec.option().isAutoTranslateEnum = true;  
                  
                // 构造过滤条件  
                EntityViewInfo ev = new EntityViewInfo();  
                FilterInfo filter = new FilterInfo();  
                filter.getFilterItems().add(  
                        new FilterItemInfo(filterId, ids, CompareType.INCLUDE));  
                ev.setFilter(filter);  
                  
                // 增加排序字段(可选)  
                ev.getSorter().add(new SorterItemInfo(sortField));  
  
                exec.setObjectView(ev);  
                System.out.println(exec.getSQL());  
  
                // 执行query,返回结果集  
                // 可对结果集进行数据处理在返回  
                iRowSet = exec.executeQuery();  
                return iRowSet;  
            } catch (Exception e1) {  
                ExceptionHandler.handle((CoreUI) null, e1);  
            }  
            return null;  
  
        }  
    } 

/** 
         * ÖØÔØactionPrint_actionPerformed·½·¨ 
         * @param e  componentΪthis ,idΪeditData.getString("id"),pathΪÌ×´ò¿Í»§¶Ëquery·¾¶ ex£ºxx/xxquery 
         * @throws Exception 
         */  
        public void actionPrint_actionPerformed(Component component,String id,String path) throws Exception {  
                if (id==null||"".equals(id)) {  
                        return;  
                }  
                DataProvider data = new DataProvider(id);  
                KDNoteHelper appHlp = new KDNoteHelper();  
                appHlp.print(path, data,  
                                javax.swing.SwingUtilities.getWindowAncestor(component));  
        }  
        /** 
         * ÖØÔØactionPrintPreview_actionPerformed·½·¨ 
         * @param e 
         * @throws Exception 
         */  
        public void printPreview_actionPerformed(Component component,String id,String path)  
                        throws Exception {  
                if (id==null||"".equals(id)) {  
                        return;  
                }  
                DataProvider data = new DataProvider(id);  
                KDNoteHelper appHlp = new KDNoteHelper();  
                appHlp.printPreview(path, data,  
                                javax.swing.SwingUtilities.getWindowAncestor(component));  
        }  
  
        public class DataProvider implements BOSQueryDelegate {  
  
                private String billId = null;  
  
                public DataProvider() {  
                        super();  
                }  
  
                public DataProvider(String billId) {  
                        super();  
                        this.billId = billId;  
                }  
  
                public IRowSet execute(BOSQueryDataSource ds) {  
                        IRowSet rowSet = null;  
                        try {  
                                IQueryExecutor iqec = null;  
                                FilterInfo filter = new FilterInfo();  
                                EntityViewInfo viewInfo = new EntityViewInfo();  
                                //query ·¾¶  
                                String path = "com.kingdee.eas.custom.panasonic.bc.app";  
  
                                DecimalFormat format = new DecimalFormat("#0.00");  
  
                                String str = ds.getID();  
                                //Ì×´ò¿Í»§¶ËqueryÃû³Æ  
                                if ("ExpenseAccountBillForPrintQuery.bos-query".equals(str)) {  
                                        iqec = QueryExecutorFactory.getRemoteInstance(new MetaDataPK(path,  
                                                                        "ExpenseAccountBillForPrintQuery"));  
                                        filter.getFilterItems().add(new FilterItemInfo("id", billId));  
                                        viewInfo.setFilter(filter);  
                                        iqec.setObjectView(viewInfo);  
                                        iqec.option().isAutoTranslateBoolean = true;  
                                        iqec.option().isAutoTranslateEnum = true;  
                                        rowSet = iqec.executeQuery();  
                                        String[] names = { "amount" };  
                                        updateRowSetBigDecimal(rowSet, names, format);  
  
                                } else if ("approveInfo.bos-query".equals(str)) {  
                                        IBillPrintFacade billPrintFacade = BillPrintFacadeFactory.getRemoteInstance();  
                                        rowSet = billPrintFacade.queryApproveInfo(billId);  
                                }  
                        } catch (Exception e) {  
//                              handUIException(e);  
                        }  
                        return rowSet;  
                }  
  
                void updateRowSetBigDecimal(IRowSet rowSet, String[] names,  
                                Format format) {  
                        try {  
  
                                while (rowSet.next()) {  
                                        for (int i = 0; i < names.length; i++) {  
                                                if (rowSet.getBigDecimal(names[i]) != null) {  
                                                        rowSet.updateBigDecimal(names[i], new BigDecimal(  
                                                                        format.format(rowSet  
                                                                                        .getBigDecimal(names[i]))));  
                                                }  
                                        }  
                                }  
                                rowSet.beforeFirst();  
                        } catch (SQLException e) {  
//                              handUIException(e);  
                        }  
                }  
        }  






  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值