/** * 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); } } }