本示例在用友NC57環境下調試通過
最近在做基于NC的二次開發,這種封閉的系統文檔很少,一個簡單的例子都不能找到幫助。
本示例的目的是為了讓后來者少走我走過的彎路
package nc.ui.ic.generaltc; import nc.ui.pub.ButtonObject; import nc.ui.pub.ClientEnvironment; import nc.ui.pub.ToftPanel; import nc.ui.pub.beans.UIPanel; import nc.ui.pub.bill.BillCardPanel; import nc.ui.pub.bill.BillEditEvent; import nc.ui.pub.bill.BillEditListener; import nc.ui.pub.bill.BillItem; import nc.ui.pub.bill.BillListPanel; import nc.ui.scm.pub.query.SCMQueryConditionDlg; import javax.swing.JComboBox; import javax.swing.JLabel; import javax.swing.JTextField; import java.awt.Dimension; /** * NC5.7單據基礎示例 * @ClassName: ClientUI * @Description: TODO * @author s * @date 2013-4-9 下午2:22:21 * BillEditListener 是按鈕監聽類 * 實現BillEditListener,需實現bodyRowChange()、afterEdit()兩個方法 */ public class ClientUI extends ToftPanel implements BillEditListener { // 單據類型 private BillCardPanel cpBill = null; // 客戶端環境變量類 private ClientEnvironment ce = getClientEnvironment(); // 按鈕查詢,增加,修改,刪除,保存,取消,打印,審核,棄審,關閉,打開. protected ButtonObject bnQuery = new ButtonObject("查詢", "查詢", 1, "查詢"); protected ButtonObject bnAdd = new ButtonObject("增加", "增加", 2, "增加"); protected ButtonObject bnModify = new ButtonObject("修改", "修改", 3, "修改"); protected ButtonObject bnDelete = new ButtonObject("刪除", "刪除", 4, "刪除"); protected ButtonObject bnSave = new ButtonObject("保存", "保存", 5, "保存"); protected ButtonObject bnCancel = new ButtonObject("取消", "取消", 6, "取消"); protected ButtonObject bnPrint = new ButtonObject("打印", "打印", 7, "打印"); protected ButtonObject bnAudit = new ButtonObject("審核", "審核", 9, "審核"); protected ButtonObject bnUnAudit = new ButtonObject("棄審", "棄審", 10, "棄審"); protected ButtonObject bnClose = new ButtonObject("關閉", "關閉", 11, "關閉"); protected ButtonObject bnOpen = new ButtonObject("打開", "打開", 12, "打開"); protected ButtonObject[] bgMain = { bnQuery, bnAdd, bnModify, bnDelete, bnSave, bnCancel, bnPrint, bnAudit, bnUnAudit, bnClose, bnOpen }; // 狀態 有下列五種狀態 private int iStatus = 0; private int INIT = 0; private int NEW = 1; private int UPDATED = 2; private int DELETED = 3; private int SAVED = 4; private nc.vo.scm.pub.session.ClientLink m_cl=null; protected UIPanel conditionpanel = null; public ClientUI() { super(); initialize(); } /** * 選中行觸發該方法 */ public void bodyRowChange(BillEditEvent arg0) { // TODO Auto-generated method stub // int isChangeRow = arg0.getRow(); } public void afterEdit(BillEditEvent arg0) { } /** * 界面初始化。 * @Title: initialize * @Description: TODO * @return void * @throws * 創建者:s * 創建日期:2013-4-10 */ private void initialize() { try { setName("TcUI"); m_cl = new nc.vo.scm.pub.session.ClientLink(ClientEnvironment.getInstance()); //INIT,NEW,UPDATED,DELETED,SAVED; iStatus = INIT; setBnStatus(iStatus); //bnOpen.setHint("測試!!?。。?); // 加載按鈕 setButtons(bgMain); add(getBillCardPanel()); // onQuery(); } catch (Exception e) { nc.vo.scm.pub.SCMEnv.out(e.getMessage()); JLabel msg = new JLabel(e.getMessage()); msg.setHorizontalAlignment(JLabel.CENTER); add(msg); } } /** * 設置單據窗體 * @Title: getBillCardPanel * @Description: TODO * @return BillCardPanel * @throws * 創建者:s * 創建日期:2013-4-10 */ private BillCardPanel getBillCardPanel() { if (cpBill == null) { try { cpBill = new BillCardPanel(); /* * 單據模板有兩種常用加載方式 * 第一種是根據“單據模板編號”來加載 * 單據模板編號是模板在標準產品庫中所保存的模板編號,在pub_billtemplet(單據模板主表)中的pk_billtemplet字段 * 可根據nodecode條件去pub_billtemplet表中查詢 * 可用語句select pk_billtemplet from pub_billtemplet where nodecode='40081001'來查詢 * nodecode是在“功能注冊”時定義的節點“功能編碼”,或稱“節點編號”,見圖1(單據類型管理) */ //cpBill.loadTemplet("0001AA1000000004OJWO"); /* * 第二種方式是使用cpBill.loadTemplet(strBillType, strBusiType, strOperator, strCorp)方法加載 * strBillType是單據模板在標準產品庫中所保存的模板類型,在pub_billtemplet(單據模板主表)中的pk_billtypecode字段 * 可根據nodecode條件去pub_billtemplet表中查詢 * 可用語句select pk_billtypecode from pub_billtemplet where nodecode='40081001'來查詢 * strBusiType是業務類型,可設為null * strOperator是操作者,使用ClientEnvironment.getUser().getPrimaryKey()取得環境用戶參數 * strCorp是公司參數,使用ClientEnvironment.getCorporation().getPk_corp()取得環境公司參數 */ cpBill.loadTemplet("40081001", null, ce.getUser().getPrimaryKey(), ce.getCorporation().getPk_corp()); //設置單據體表體菜單是否顯示 cpBill.setBodyMenuShow(false); //添加監聽 cpBill.addEditListener(this); } catch (java.lang.Throwable ivjExc) { } } return cpBill; } /** * * @Title: getConditionPanel * @Description: TODO * @return UIPanel * @throws * 創建者:s * 創建日期:2013-4-9 */ protected UIPanel getConditionPanel() { if (conditionpanel == null) { conditionpanel = new UIPanel(); conditionpanel.setName("UIPanel"); conditionpanel.setLayout(new java.awt.GridLayout(2, 6, 0, 1)); conditionpanel.setMaximumSize(new Dimension(550, 40)); conditionpanel.setPreferredSize(new Dimension(550, 40)); conditionpanel.setMinimumSize(new Dimension(550, 1)); } return conditionpanel; } @Override public String getTitle() { // TODO Auto-generated method stub return null; } @Override public void onButtonClicked(ButtonObject arg0) { // TODO Auto-generated method stub } /** * 設置按鈕狀態。 * @Title: setBnStatus * @Description: TODO * @param status * @return void * @throws * 創建者:s * 創建日期:2013-4-10 */ public void setBnStatus(int status) { //初始、刪除、保存狀態 if (status == INIT || status == DELETED || status == SAVED) { bnQuery.setEnabled(true); bnAdd.setEnabled(true); bnModify.setEnabled(true); bnSave.setEnabled(false); bnCancel.setEnabled(false); bnDelete.setEnabled(true); // bnModify.setEnabled(false); } //增加、修改狀態 else if (status == NEW || status == UPDATED) { bnQuery.setEnabled(false); bnAdd.setEnabled(false); bnSave.setEnabled(true); bnCancel.setEnabled(true); bnDelete.setEnabled(false); bnModify.setEnabled(false); } //bnPrint.setEnabled(false); updateButtons(); } }
圖1:單據類型管理界面
更多文章、技術交流、商務合作、聯系博主
微信掃碼或搜索:z360901061

微信掃一掃加我為好友
QQ號聯系: 360901061
您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。
【本文對您有幫助就好】元
