NC65 如何添加自定义的Dialog

2 篇文章 0 订阅

参考代码如下:

package nc.ui.fdgyl.ysbbmanage.ace.action;

import java.awt.Container;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.text.SimpleDateFormat;
import java.util.Date;

import nc.bs.framework.common.NCLocator;
import nc.itf.fdgyl.IFdDBService;
import nc.ui.fdgyl.billref.model.DefdoclistRefmodel;
import nc.ui.fdgyl.billref.model.DeptTreeRefmodel;
import nc.ui.org.ref.BusinessUnitDefaultRefModel;
import nc.ui.org.ref.DeptDefaultRefModel;
import nc.ui.pub.beans.MessageDialog;
import nc.ui.pub.beans.UIButton;
import nc.ui.pub.beans.UIComboBox;
import nc.ui.pub.beans.UIDialog;
import nc.ui.pub.beans.UILabel;
import nc.ui.pub.beans.UIRefPane;
import nc.ui.pub.beans.ValueChangedEvent;
import nc.ui.pub.beans.ValueChangedListener;
import nc.vo.pub.BusinessException;

public class CorpofBBDialog extends UIDialog  implements ActionListener, ValueChangedListener {
	private static final long serialVersionUID = 1L;
	public int lbl_height=25; 
	public int lbl_weight=70;
	public int txt_height=25; 
	public int txt_weight=70;	 
	public int tmpH=30; //每行间隔
	public int first_columnY=10;  //第一行位置
	public int one_lblX=10; 
    public boolean bol =false;
    private UIRefPane ref_corp;
    private UIRefPane ref_dept;
    private UIRefPane ref_report;
	private UIButton btn_ok;
	private UIButton btn_cancel;
	private UIComboBox comyear;
	private UIComboBox commonth;
	private Object objs;
	private String pk_org;
	public CorpofBBDialog(Container parent,String pk_org){
		super(parent, "报表模型导入");
		this.pk_org = pk_org;
	}
	
	public void render() {
		this.setLayout(null);
		this.setSize(300, 210);
		Toolkit kit = Toolkit.getDefaultToolkit(); 
		Dimension screenSize = kit.getScreenSize();   // 获取屏幕的尺寸
	    int screenWidth = screenSize.width/2;         // 获取屏幕的宽
	    int screenHeight = screenSize.height/2;       // 获取屏幕的高
        int height = this.getHeight();
        int width = this.getWidth();
		this.setLocation(screenWidth-width/2, screenHeight-height/2);
		init();
		show();
	}
	
	int row = 0;
	private void init(){

		
		row++;
		UILabel uilabel = new UILabel();
		uilabel.setBounds(this.one_lblX, this.first_columnY , this.lbl_weight, this.lbl_height);
		uilabel.setText("业务单元:");
		this.add(uilabel);
		
		ref_corp=new UIRefPane();
		ref_corp.setBounds(this.one_lblX+75, this.first_columnY , this.txt_weight+140, this.txt_height);
		ref_corp.setRefNodeName(nc.vo.bd.ref.RefNodeNameConst.CORP_GROUP_S);
		nc.ui.org.ref.BusinessUnitDefaultRefModel model = new BusinessUnitDefaultRefModel();
		ref_corp.setRefModel(model);
		ref_corp.setEnabled(false);
		ref_corp.addValueChangedListener(this);
		ref_corp.setPK(getPk_org());
		this.add(ref_corp);
		
		UILabel uilabelbm = new UILabel();
		uilabelbm.setBounds(this.one_lblX, this.first_columnY+ (row * this.tmpH) , this.lbl_weight, this.lbl_height);
		uilabelbm.setText("所属部门:");
		this.add(uilabelbm);
		
		ref_dept=new UIRefPane();
		ref_dept.setBounds(this.one_lblX+75, this.first_columnY+ (row * this.tmpH) , this.txt_weight+140, this.txt_height);
		nc.ui.fdgyl.billref.model.DeptTreeRefmodel modelbm = new DeptTreeRefmodel(getPk_org());
		modelbm.setNotLeafSelectedEnabled(false);
		ref_dept.setRefModel(modelbm);
		this.add(ref_dept);
		
		row++;
		UILabel uilabel1 = new UILabel();
		uilabel1.setBounds(this.one_lblX, this.first_columnY + (row * this.tmpH), this.lbl_weight, this.lbl_height);
		uilabel1.setText("报表模板:");
		this.add(uilabel1);
		
		ref_report=new UIRefPane();
		ref_report.setBounds(this.one_lblX+75, this.first_columnY + (row * this.tmpH), this.lbl_weight+140, this.lbl_height);
		nc.ui.fdgyl.billref.model.DefdoclistRefmodel model1 = new DefdoclistRefmodel(getPk_org());
		ref_report.setRefModel(model1);
		this.add(ref_report);
		
		row++;
		UILabel uilabel2 = new UILabel();
		uilabel2.setBounds(this.one_lblX, this.first_columnY + (row * this.tmpH), this.lbl_weight, this.lbl_height);
		uilabel2.setText("本次年度:");
		this.add(uilabel2);
		
		comyear =  new UIComboBox();
		comyear.setBounds(this.one_lblX+75, this.first_columnY + (row * this.tmpH), this.lbl_weight+140, this.lbl_height);
		comyear.addItem(getCurrentYear());
		this.add(comyear);
		
		row++;
		UILabel uilabel3 = new UILabel();
		uilabel3.setBounds(this.one_lblX, this.first_columnY + (row * this.tmpH), this.lbl_weight, this.lbl_height);
		uilabel3.setText("本次月份:");
		this.add(uilabel3);
		
		commonth =  new UIComboBox();
		commonth.setBounds(this.one_lblX+75, this.first_columnY + (row * this.tmpH), this.lbl_weight+140, this.lbl_height);
		for(int i = 1 ;i <= 12 ; i++)
		{
			if(i<10){
				commonth.addItem("0"+i);
			}else{
				commonth.addItem(i);
			}
		}
		this.add(commonth);
		
//		row++;
		btn_ok=new UIButton("确定");
		btn_ok.setBounds(this.one_lblX+150, first_columnY +40+ (row * this.tmpH), 60, 23);
		btn_ok.addActionListener(this);
		this.add(btn_ok);
		
		btn_cancel=new UIButton("取消");
		btn_cancel.setBounds(this.one_lblX+220, first_columnY+40 + (row * this.tmpH), 60, 23);
		btn_cancel.addActionListener(this);
		this.add(btn_cancel);
	}
	@Override
	public void actionPerformed(ActionEvent e) {
	   if(btn_ok == e.getSource())
	   {
		   if("00016T10000000002PEM".equals(ref_corp.getRefPK()))
		   {
			 if(ref_corp.getRefPK()==null||ref_corp.getRefPK().length()==0
		 	 ||ref_report.getRefPK()==null||ref_report.getRefPK().length()==0
			 ||ref_dept.getRefPK()==null||ref_dept.getRefPK().length()==0
			 ||comyear.getSelectedItem()==null
			 ||commonth.getSelectedItem()==null)
			 {
				bol= false;
				MessageDialog.showWarningDlg(this, "提示", "界面数据不能为空!");
				return;
			 }
		   }else
		   {
			  if(ref_corp.getRefPK()==null||ref_corp.getRefPK().length()==0
			  ||ref_report.getRefPK()==null||ref_report.getRefPK().length()==0
			  ||comyear.getSelectedItem()==null
			  ||commonth.getSelectedItem()==null)
			  {
				bol= false;
				MessageDialog.showWarningDlg(this, "提示", "界面数据不能为空!");
				return;
		      }
		   }
	      String pk_corp  = ref_corp.getRefPK();
	      String report   = ref_report.getRefPK();
	      String pk_dept     = ref_dept.getRefPK();
	   	  String stryear  = comyear.getSelectedItem().toString();
	      String strmonth = commonth.getSelectedItem().toString();
	      try {
			String vbillcode = this.getFdDbservice().getVbillcodeForYsBB(stryear, strmonth, report, pk_corp,pk_dept);
			if(vbillcode!=null&&vbillcode.length()>0)
			{
				MessageDialog.showWarningDlg(this, "提示", "当前年月报表数据已存在!\n预算报表单号为:"+vbillcode);
				return;
			}
		  } catch (BusinessException e1) {
			e1.printStackTrace();
		 }
	      objs= new String[]{pk_corp,report,stryear,strmonth,pk_dept};
		  bol = true ;
    	  this.dispose();//关闭窗口
       }else if(btn_cancel == e.getSource()){
    	  bol = false ;
    	  this.dispose();//关闭窗口
       }
	}
	
	public Object getObj() {
		return objs;
	}
	public void setObj(Object objs) {
		this.objs = objs;
	}
	public boolean getBol() {
		return bol;
	}
	public void setBol(boolean bol) {
		this.bol = bol;
	}
	
	public String getCurrentYear(){
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy");
        Date date = new Date();
        return sdf.format(date);
}

	@Override
	public void valueChanged(ValueChangedEvent arg0) {
		Object strnew  = arg0.getNewValue();
		Object strold  = arg0.getOldValue();
		if(strold!=null&&!strold.equals(strnew))
		{
			ref_dept.setText("");
			nc.ui.fdgyl.billref.model.DeptTreeRefmodel model = new DeptTreeRefmodel(ref_corp.getRefPK());
			model.setNotLeafSelectedEnabled(false);
			ref_dept.setRefModel(model);
		}
	}

	/**
	 * @return pk_org
	 */
	public String getPk_org() {
		return pk_org;
	}

	/**
	 * @param pk_org 要设置的 pk_org
	 */
	public void setPk_org(String pk_org) {
		this.pk_org = pk_org;
	}
	
	public IFdDBService getFdDbservice()
	{
		IFdDBService iquery = (IFdDBService) NCLocator.getInstance().lookup(
				IFdDBService.class);
		return iquery;
	}
}

 

客户端调用代码如下:

private ShowUpableBillForm editor;
public ShowUpableBillForm getEditor() {
	return editor;
}
public void setEditor(ShowUpableBillForm editor) {
	this.editor = editor;
}
String pk_org = getEditor().getBillCardPanel().getHeadItem("pk_org").getValue();
CorpofBBDialog dia = new CorpofBBDialog(getEditor(),pk_org);
dia.render();
if(!dia.getBol())//判断确定还是取消
	return;

 

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值