[转]用友NC单据UI基本代码示例

原地址:

http://blog.csdn.net/softwave/article/details/8781220

本示例在用友NC57环境下调试通过

最近在做基于NC的二次开发,这种封闭的系统文档很少,一个简单的例子都不能找到帮助。

本示例的目的是为了让后来者少走我走过的弯路

  1. package nc.ui.ic.generaltc;  
  2.   
  3. import nc.ui.pub.ButtonObject;  
  4. import nc.ui.pub.ClientEnvironment;  
  5. import nc.ui.pub.ToftPanel;  
  6. import nc.ui.pub.beans.UIPanel;  
  7. import nc.ui.pub.bill.BillCardPanel;  
  8. import nc.ui.pub.bill.BillEditEvent;  
  9. import nc.ui.pub.bill.BillEditListener;  
  10. import nc.ui.pub.bill.BillItem;  
  11. import nc.ui.pub.bill.BillListPanel;  
  12. import nc.ui.scm.pub.query.SCMQueryConditionDlg;  
  13. import javax.swing.JComboBox;  
  14. import javax.swing.JLabel;  
  15. import javax.swing.JTextField;  
  16. import java.awt.Dimension;  
  17.   
  18. /** 
  19.  * NC5.7单据基础示例 
  20.  * @ClassName: ClientUI 
  21.  * @Description: TODO 
  22.  * @author s 
  23.  * @date 2013-4-9 下午2:22:21 
  24.  * BillEditListener  是按钮监听类 
  25.  * 实现BillEditListener,需实现bodyRowChange()、afterEdit()两个方法 
  26.  */  
  27. public class ClientUI extends ToftPanel implements BillEditListener {  
  28.   
  29.     // 单据类型  
  30.     private BillCardPanel cpBill = null;  
  31.       
  32.     // 客户端环境变量类  
  33.     private ClientEnvironment ce = getClientEnvironment();  
  34.       
  35.     // 按钮查询,增加,修改,删除,保存,取消,打印,审核,弃审,关闭,打开.  
  36.     protected ButtonObject bnQuery = new ButtonObject("查询""查询"1"查询");  
  37.     protected ButtonObject bnAdd = new ButtonObject("增加""增加"2"增加");  
  38.     protected ButtonObject bnModify = new ButtonObject("修改""修改"3"修改");  
  39.     protected ButtonObject bnDelete = new ButtonObject("删除""删除"4"删除");  
  40.     protected ButtonObject bnSave = new ButtonObject("保存""保存"5"保存");  
  41.     protected ButtonObject bnCancel = new ButtonObject("取消""取消"6"取消");  
  42.     protected ButtonObject bnPrint = new ButtonObject("打印""打印"7"打印");  
  43.     protected ButtonObject bnAudit = new ButtonObject("审核""审核"9"审核");  
  44.     protected ButtonObject bnUnAudit = new ButtonObject("弃审""弃审"10"弃审");  
  45.     protected ButtonObject bnClose = new ButtonObject("关闭""关闭"11"关闭");  
  46.     protected ButtonObject bnOpen = new ButtonObject("打开""打开"12"打开");  
  47.       
  48.     protected ButtonObject[] bgMain = { bnQuery, bnAdd, bnModify, bnDelete,  
  49.             bnSave, bnCancel, bnPrint, bnAudit, bnUnAudit, bnClose, bnOpen };  
  50.       
  51.     // 状态 有下列五种状态  
  52.     private int iStatus = 0;  
  53.     private int INIT = 0;  
  54.     private int NEW = 1;  
  55.     private int UPDATED = 2;  
  56.     private int DELETED = 3;  
  57.     private int SAVED = 4;  
  58.       
  59.     private nc.vo.scm.pub.session.ClientLink m_cl=null;  
  60.     protected UIPanel conditionpanel = null;  
  61.   
  62.     public ClientUI() {  
  63.         super();  
  64.         initialize();  
  65.     }  
  66.   
  67.     /** 
  68.      * 选中行触发该方法 
  69.      */  
  70.     public void bodyRowChange(BillEditEvent arg0) {  
  71.         // TODO Auto-generated method stub  
  72.         // int isChangeRow = arg0.getRow();  
  73.     }  
  74.   
  75.     public void afterEdit(BillEditEvent arg0) {  
  76.     }  
  77.   
  78.     /** 
  79.      * 界面初始化。 
  80.      * @Title: initialize 
  81.      * @Description: TODO 
  82.      * @return void 
  83.      * @throws 
  84.      * 创建者:s 
  85.      * 创建日期:2013-4-10 
  86.      */  
  87.     private void initialize() {  
  88.         try {  
  89.             setName("TcUI");  
  90.             m_cl = new nc.vo.scm.pub.session.ClientLink(ClientEnvironment.getInstance());  
  91.             //INIT,NEW,UPDATED,DELETED,SAVED;  
  92.             iStatus = INIT;  
  93.             setBnStatus(iStatus);  
  94.             //bnOpen.setHint("测试!!!!!");  
  95.             // 加载按钮  
  96.             setButtons(bgMain);  
  97.             add(getBillCardPanel());  
  98.             // onQuery();  
  99.         } catch (Exception e) {  
  100.              nc.vo.scm.pub.SCMEnv.out(e.getMessage());  
  101.              JLabel msg = new JLabel(e.getMessage());  
  102.              msg.setHorizontalAlignment(JLabel.CENTER);  
  103.              add(msg);  
  104.         }  
  105.     }  
  106.   
  107.     /** 
  108.      * 设置单据窗体 
  109.      * @Title: getBillCardPanel 
  110.      * @Description: TODO 
  111.      * @return BillCardPanel 
  112.      * @throws 
  113.      * 创建者:s 
  114.      * 创建日期:2013-4-10 
  115.      */  
  116.     private BillCardPanel getBillCardPanel() {  
  117.         if (cpBill == null) {  
  118.             try {  
  119.                 cpBill = new BillCardPanel();  
  120.                 /* 
  121.                  * 单据模板有两种常用加载方式 
  122.                  * 第一种是根据“单据模板编号”来加载 
  123.                  * 单据模板编号是模板在标准产品库中所保存的模板编号,在pub_billtemplet(单据模板主表)中的pk_billtemplet字段 
  124.                  * 可根据nodecode条件去pub_billtemplet表中查询 
  125.                  * 可用语句select pk_billtemplet from pub_billtemplet where nodecode='40081001'来查询 
  126.                  * nodecode是在“功能注册”时定义的节点“功能编码”,或称“节点编号”,见图1(单据类型管理) 
  127.                  */  
  128.                 //cpBill.loadTemplet("0001AA1000000004OJWO");  
  129.                 /* 
  130.                  * 第二种方式是使用cpBill.loadTemplet(strBillType, strBusiType, strOperator, strCorp)方法加载 
  131.                  * strBillType是单据模板在标准产品库中所保存的模板类型,在pub_billtemplet(单据模板主表)中的pk_billtypecode字段 
  132.                  * 可根据nodecode条件去pub_billtemplet表中查询 
  133.                  * 可用语句select pk_billtypecode from pub_billtemplet where nodecode='40081001'来查询 
  134.                  * strBusiType是业务类型,可设为null 
  135.                  * strOperator是操作者,使用ClientEnvironment.getUser().getPrimaryKey()取得环境用户参数 
  136.                  * strCorp是公司参数,使用ClientEnvironment.getCorporation().getPk_corp()取得环境公司参数 
  137.                  */  
  138.                 cpBill.loadTemplet("40081001"null, ce.getUser().getPrimaryKey(), ce.getCorporation().getPk_corp());  
  139.                 //设置单据体表体菜单是否显示  
  140.                 cpBill.setBodyMenuShow(false);  
  141.                 //添加监听  
  142.                 cpBill.addEditListener(this);  
  143.   
  144.             } catch (java.lang.Throwable ivjExc) {  
  145.             }  
  146.         }  
  147.         return cpBill;  
  148.     }  
  149.     /** 
  150.      *  
  151.      * @Title: getConditionPanel 
  152.      * @Description: TODO 
  153.      * @return UIPanel 
  154.      * @throws 
  155.      * 创建者:s 
  156.      * 创建日期:2013-4-9 
  157.      */  
  158.     protected UIPanel getConditionPanel() {  
  159.         if (conditionpanel == null) {  
  160.             conditionpanel = new UIPanel();  
  161.             conditionpanel.setName("UIPanel");  
  162.             conditionpanel.setLayout(new java.awt.GridLayout(2601));  
  163.             conditionpanel.setMaximumSize(new Dimension(55040));  
  164.             conditionpanel.setPreferredSize(new Dimension(55040));  
  165.             conditionpanel.setMinimumSize(new Dimension(5501));  
  166.         }  
  167.         return conditionpanel;  
  168.     }  
  169.       
  170.     @Override  
  171.     public String getTitle() {  
  172.         // TODO Auto-generated method stub  
  173.         return null;  
  174.     }  
  175.   
  176.     @Override  
  177.     public void onButtonClicked(ButtonObject arg0) {  
  178.         // TODO Auto-generated method stub  
  179.           
  180.     }  
  181.       
  182.     /** 
  183.      * 设置按钮状态。 
  184.      * @Title: setBnStatus 
  185.      * @Description: TODO 
  186.      * @param status 
  187.      * @return void 
  188.      * @throws 
  189.      * 创建者:s 
  190.      * 创建日期:2013-4-10 
  191.      */  
  192.     public void setBnStatus(int status) {  
  193.         //初始、删除、保存状态  
  194.         if (status == INIT || status == DELETED || status == SAVED) {  
  195.             bnQuery.setEnabled(true);  
  196.             bnAdd.setEnabled(true);  
  197.             bnModify.setEnabled(true);  
  198.             bnSave.setEnabled(false);  
  199.             bnCancel.setEnabled(false);  
  200.             bnDelete.setEnabled(true);  
  201.             //  bnModify.setEnabled(false);  
  202.         }  
  203.         //增加、修改状态  
  204.         else if (status == NEW || status == UPDATED) {  
  205.             bnQuery.setEnabled(false);  
  206.             bnAdd.setEnabled(false);  
  207.             bnSave.setEnabled(true);  
  208.             bnCancel.setEnabled(true);  
  209.             bnDelete.setEnabled(false);  
  210.             bnModify.setEnabled(false);  
  211.         }  
  212.             //bnPrint.setEnabled(false);  
  213.         updateButtons();  
  214.     }  


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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值