EAS BOS套打設定

來源:互聯網
上載者:User
/** * 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 {// 建議使用queryprivate 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);                        }                }        }

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.