NC自定义按钮、弹窗、弹窗参照输入框、BaseDao操作数据库、插件开发

NC自定义按钮

配置xml生成对应java类

<?xml version="1.0" encoding="GBK"?>
 
<!DOCTYPE beans PUBLIC ".//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
    
    
    <!--新增按钮卡片-->
    <bean class="nc.ui.pubapp.plugin.action.InsertActionInfo">
    <property name="actionContainer" ref="actionsOfCard" />
    <property name="actionType" value="notedit" />
    <property name="target" ref="browLinkActionGroup" />
    <property name="pos" value="after" />
    <property name="action" ref="WaybillInfoAction" /> 
    </bean>

   <!--新增按钮在列表显示-->
    <bean class="nc.ui.pubapp.plugin.action.InsertActionInfo">
    <!--actionContainer表示在按钮显示的位置ref对应的值需要从基本的xml找-->
    <property name="actionContainer" ref="actionsOfList" />
    <!--actionType表示编辑状态-->
    <!--状态:notedit非编辑,edit编辑-->
    <property name="actionType" value="notedit" />
     <!--新增按钮位置,在联查之后添加按钮,这个需要在基本的xml寻找-->
    <property name="target" ref="browLinkActionGroup" />
    <property name="pos" value="after" />
    <!--新增按钮的名称-->
    <property name="action" ref="WaybillInfoAction" /> 
    </bean>

    <!--自定义按钮-->
    <bean id="WaybillInfoAction" class="nc.ui.so.m4331.billui.action.WaybillInfoAction">
        <property name="model" ref="manageAppModel" />
        <property name="editor" ref="billFormEditor" />
        <property name="code" value="WaybillInfoAction" />
    </bean>
    
</beans>

xml生成对应Java类

自定义点击按钮所执行的功能

package nc.ui.so.m4331.billui.action;
import java.awt.event.ActionEvent;

import nc.vo.so.m4331.entity.DeliveryHVO;
import nc.vo.so.m4331.entity.DeliveryVO;
import nc.ui.uif2.NCAction;
import nc.ui.uif2.model.AbstractAppModel;
import nc.ui.pubapp.uif2app.view.BillForm;
import nc.vo.arap.receivable.AggReceivableBillVO;
import nc.vo.arap.receivable.ReceivableBillVO;
import  nc.ui.pubapp.uif2app.actions.RefreshSingleAction;
public class WaybillInfoAction extends NCAction{
	private BillForm editor;
	private AbstractAppModel model;
	public WaybillInfoAction(){
	//初始按钮名称和code
		super.setBtnName("运单信息");
		//传入值和xml中的code对应
		super.setCode("WaybillInfoAction");
	}
	
	public BillForm getEditor() {
		return editor;
	}

	public void setEditor(BillForm editor) {
		this.editor = editor;
	}

	public AbstractAppModel getModel() {
		return model;
	}

	public void setModel(AbstractAppModel model) {
		this.model = model;
		//自定义按钮点击条件,必须添加该代码
		model.addAppEventListener(this);
	}
	//设置按钮满足什么条件时,可以点击-返回true可以点击。
	@Override
	protected boolean isActionEnable() {
		
				
	    return true;
	}

	@Override
	public void doAction(ActionEvent paramActionEvent) throws Exception {
	//获取选中单据的vo对象,是聚合vo
		DeliveryVO deliveryVO = (DeliveryVO) getModel().getSelectedData();
		DeliveryHVO parentVO = deliveryVO.getParentVO();
		//弹窗对象,自定义弹窗
		InvoiceDialog invoiceDialog = new InvoiceDialog();
		invoiceDialog.setParentVO(parentVO);
		invoiceDialog.setEditor(editor);
		invoiceDialog.setParameters();
		invoiceDialog.showDialog();
		//刷新单据
		RefreshSingleAction refreshaction = new RefreshSingleAction();
        refreshaction.setModel(this.getModel());
        ActionEvent e1 = new ActionEvent(refreshaction, 1001, "刷新");
        refreshaction.doAction(e1);
		
		
	}

}

Client端调用接口

INewPayTotalInfo info = (INewPayTotalInfo) NCLocator.getInstance().lookup(INewPayTotalInfo.class);
info.save();

BaseDao使用方式

  1. 查询
import nc.jdbc.framework.processor.MapProcessor;
import nc.jdbc.framework.processor.MapListProcessor;
String sql="select pk_psndoc from bd_psndoc where id=''";
String querySql="select * from bd_psndoc";
//获取的查询结果为单个对象使用MapProcessor,对查询结果进行封装。
Map<String, String> bhrQuery = (Map<String, String>)baseDAO.executeQuery(sql, new MapProcessor());
//获取结果为多个对象的集合,使用MapListProcessor进行封装
List<Map<String, Object>> executeQuery = (List<Map<String, Object>>)baseDAO.executeQuery(querySql, new MapListProcessor());			
		
		

2.更新操作

String sql="update so_delivery set ctransporttypeid = '"+ctransporttypeid+"' where cdeliveryid ='"+deliverHVO.getCdeliveryid()+"'";
baseDAO.executeUpdate(sql);

Client端操作数据库

1.查询数据

//获取查询类
IUAPQueryBS iUAPQueryBS = (IUAPQueryBS)NCLocator.getInstance().lookup(IUAPQueryBS.class.getName());
//调用类的方法,传入sql语句和结果集
iUAPQueryBS.executeQuery(sql,new MapListProcessor());

2.增加、更新、删除

IVOPersistence voPer = (IVOPersistence) NCLocator.getInstance().lookup(IVOPersistence.class.getName())
//获取当前数据源
InvocationInfoProxy.getInstance().getUserDataSource();

常见数据结果集

MapProcessor 单行多列封装到Map中:HashMap处理器,返回一个HashMap, 结果集中只有一行数据,其中结果集合中每一列的列名和列值对应HashMap的一个关键字和相应的值。

MapListProcessor 多行多列封装到Map中:HashMap集合处理器,返回一个ArrayList集合,集合中的每一个元素是一个HashMap,每个HashMap对应结果集中的一行数据, 其中结果集合中每一列的列名和列值对应HashMap的一个关键字和相应的值。

BeanProcessor单行多列封装到JavaBean中:值对象处理器,返回一个JavaBean,结果集中只有一行数据,该处理器能自动把结果集中的值按列的名称映射到javaBean中,如结果集中有名称为”name”的字段,那么只要该java对象中有getName()方法就能把结果集合中”name”对应的值映射到对象中。

BeanListProcessor多行多列封装到JavaBean中:值对象集合处理器,返回一个ArrayList集合,集合中的每一个元素是一个javaBean,每个javaBean对应结果集合中一行数据。

ColumnProcessor单行单列:列值处理器,返回一个Java对象,结果集中只有一行数据,该对象对应与结果集中某一列的值,该处理器通过结果集列的序号或名称来确定列。

ColumnListProcessor多行单列:列值处理器,返回一个阿ArrayList对象,结果集中有多行数据,该对象对应与结果集中某一列的值,该处理器通过结果集列的序号或名称来确定列。

常见结果集
Java操作数据库的方式

自定义弹窗

  • 弹窗类
    import nc.ui.pub.beans.UIDialog;

  • 按钮类
    import nc.ui.pub.beans.UIButton;

  • 文本类
    import nc.ui.pub.beans.UILabel;

  • 输入框类
    import nc.ui.pub.beans.UITextField;

弹窗常用方法

弹窗总体设置

setSize(500, 200); // 设置对话框大小为500x200像素
setLocationRelativeTo(null); // 将对话框居中显示
setDefaultCloseOperation(DISPOSE_ON_CLOSE); // 设置关闭操作为释放资源
setTitle("运单信息");//设置标题
setModal(true); // 设置为模态对话框(阻塞其他窗口)
//setLayout(null); // 使用绝对布局
setLayout(new BorderLayout());//边框布局 EAST 、 SOUTH 、 WEST 、 NORTH 、 CENTER。可以被放置在这 5 个区域的任意一个中
setResizable(false);//设置是否可以改变窗口大小
setAlwaysOnTop (true);//设置是否在最前面显示

按钮设置

UIButton qdBtn = new UIButton("确定");
//qdBtn.setBounds(40, 140, 80, 30); // 设置按钮2的位置和大小,设置绝对路径
qdBtn.setBorderPainted(false);//设置按钮边框
qdBtn.setFocusPainted(false);//设置点击是否聚焦
//增加点击事件
ButtonActionListener buttonActionListener = new ButtonActionListener();
qdBtn.addActionListener(buttonActionListener);
//设置点击监听类
final class ButtonActionListener implements ActionListener{
	        public void actionPerformed(ActionEvent e){
	        	if(e.getSource()==qdBtn){
	        	}	        
}

面板设置

//流式布局从左到右布局
UIPanel panel = new UIPanel(new FlowLayout(FlowLayout.LEFT));
this.add(panel,BorderLayout.CENTER);//将面板放到弹窗的哪个位置-边框布局

文本框赋值和获取

UITextField field = new UITextField();
field.setText();//设置文本框值
field.getText();//获取文本框输入的值

使用NC中的参照,select * from bd_refinfo 改表是存放参照对应的name和参照的表等信息

UIRefPane refPane = new UIRefPane();
refPane.setRefNodeName("运输方式");//参照运输方式
refPane.setRefNodeName("日历");//NC集成的日历组件
refPane.setRefNodeName("人员");//参照人员档案
refPane.setPk_org();//设置组织的主键,不设置组织主键,不会显示人员信息
refPane.setPK();//设置回显,参照根据主键回显信息

执行一个动作前后进行操作

package nc.bs.arap.noapproval.listener;

import java.util.List;
import java.util.Map;

import org.apache.commons.lang.StringUtils;

import nc.bs.businessevent.BdUpdateEvent;
import nc.bs.businessevent.BusinessEvent;
import nc.bs.businessevent.IBusinessEvent;
import nc.bs.businessevent.IBusinessListener;
import nc.bs.dao.BaseDAO;
import nc.jdbc.framework.processor.MapListProcessor;
import nc.vo.arap.receivable.AggReceivableBillVO;
import nc.vo.arap.receivable.ReceivableBillVO;
import nc.vo.pub.AggregatedValueObject;
import nc.vo.pub.BusinessException;
import nc.vo.pub.CircularlyAccessibleValueObject;
//继承IBusinessListener 类

public class NoApproval  implements IBusinessListener {

	//执行注册的动作将会进入doAction方法中,截断操作-throw new BusinessException("已同步至百望,请找财务取消同步")或者return;
	
	@Override
	public void doAction(IBusinessEvent event) throws BusinessException {
		

		Object object = null;
		if ((event instanceof BusinessEvent)) {
			//业务动作
			BusinessEvent e = (BusinessEvent)event;
			object=e.getObject();
		}
		AggregatedValueObject[] bills = null;
		if(null != object){
			if(object.getClass().isArray()){
				bills = (AggregatedValueObject[])object;
			}else {
				bills = new AggregatedValueObject[1]; 
				bills[0] = ((AggregatedValueObject)object);
			}
		}		
			for (int i = 0; i < bills.length; i++) {
				AggregatedValueObject aggregatedValueObject = bills[0];
				ReceivableBillVO headVo = (ReceivableBillVO)aggregatedValueObject.getParentVO();
				String def30 = headVo.getDef30();
				String def14 = headVo.getDef14();
				
				if("已同步".equals(def14)||StringUtils.isNotEmpty(def30)){
					throw new BusinessException("已同步至百望,请找财务取消同步"); 

				}
//				throw new BusinessException("已同步至百望,请找财务取消同步"); 
//				else if (def14.equals("已同步")&&StringUtils.isEmpty(def30)) {
//					String sql = " update ar_recbill set def4 = '',def14 = '' where pk_recbill = '"+headVo.getPk_recbill()+"'";
					baseDAO.executeUpdate(sql);
//				}
			}
		

		
	}


}

相关参考连接

新增按钮
新增按钮和超链接
新增扩展按钮
控制按钮不可用
插件开发
自定义弹窗显示数据

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值