1.。定义一个常用条件模板,命名为NormalPane , 继承接口INormalQuery
package nc.ui.ldzl.rent; import java.awt.Color; import javax.swing.ButtonGroup; import nc.ui.pub.beans.UIRadioButton; import nc.ui.pub.beans.UITextArea; public class NormalPanel extends nc.ui.pub.beans.UIPanel implements nc.ui.trade.query.INormalQuery{ /** * */ private static final long serialVersionUID = 1L; //常用条件 private UIRadioButton m_rdoFree = null; private UIRadioButton m_rdoSubmit = null; private UIRadioButton m_rdoCheckGoing = null; private UIRadioButton m_rdoAudited = null; private UIRadioButton m_rdoNotPass = null; private UIRadioButton m_rdoAll = null; private String tableName = null; private String m_isNormal = "Y"; //是否有“常用条件”页签 public NormalPanel(){ super(); init(); } public NormalPanel(String m_isNormal){ super(); init(); this.m_isNormal = m_isNormal; } public NormalPanel(java.awt.LayoutManager p0){ super(p0); init(); } public NormalPanel(java.awt.LayoutManager p0, boolean p1){ super(p0,p1); init(); } public NormalPanel(boolean p1){ super(p1); init(); } private void init() { this.setSize(500, 500); /*加入常用条件*/ m_rdoFree = new UIRadioButton(); m_rdoFree.setText("自由"); m_rdoFree.setBackground(this.getBackground()); m_rdoFree.setForeground(Color.black); m_rdoFree.setSize(80, m_rdoFree.getHeight()); m_rdoFree.setSelected(true); m_rdoSubmit = new UIRadioButton(); m_rdoSubmit.setText("提交"); m_rdoSubmit.setBackground(this.getBackground()); m_rdoSubmit.setForeground(Color.black); m_rdoSubmit.setSize(m_rdoFree.getSize()); m_rdoCheckGoing = new UIRadioButton(); m_rdoCheckGoing.setText("审批进行中"); m_rdoCheckGoing.setBackground(this.getBackground()); m_rdoCheckGoing.setForeground(Color.black); m_rdoCheckGoing.setSize(160, m_rdoFree.getHeight()); m_rdoAudited = new UIRadioButton(); m_rdoAudited.setText("审批通过"); m_rdoAudited.setBackground(m_rdoFree.getBackground()); m_rdoAudited.setForeground(m_rdoFree.getForeground()); m_rdoAudited.setSize(m_rdoFree.getSize()); m_rdoNotPass = new UIRadioButton(); m_rdoNotPass.setText("审批未通过"); m_rdoNotPass.setBackground(m_rdoFree.getBackground()); m_rdoNotPass.setForeground(m_rdoFree.getForeground()); m_rdoNotPass.setSize(160, m_rdoFree.getHeight()); m_rdoAll = new UIRadioButton(); m_rdoAll.setText("全部"); m_rdoAll.setBackground(m_rdoFree.getBackground()); m_rdoAll.setForeground(m_rdoFree.getForeground()); m_rdoAll.setSize(m_rdoFree.getSize()); m_rdoFree.setLocation(50, 30); m_rdoSubmit.setLocation(m_rdoFree.getX(), m_rdoFree.getY()+m_rdoFree.getHeight()+20); m_rdoCheckGoing.setLocation(m_rdoFree.getX(), m_rdoSubmit.getY()+m_rdoSubmit.getHeight()+20); m_rdoAudited.setLocation(m_rdoFree.getX(), m_rdoCheckGoing.getY()+m_rdoCheckGoing.getHeight()+20); m_rdoNotPass.setLocation(m_rdoFree.getX(), m_rdoAudited.getY()+m_rdoAudited.getHeight()+20); m_rdoAll.setLocation(m_rdoFree.getX(), m_rdoNotPass.getY()+m_rdoNotPass.getHeight()+20); ButtonGroup bg = new ButtonGroup(); bg.add(m_rdoFree); bg.add(m_rdoSubmit); bg.add(m_rdoCheckGoing); bg.add(m_rdoAudited); bg.add(m_rdoNotPass); bg.add(m_rdoAll); bg.setSelected(m_rdoFree.getModel(), true); this.setLayout(null); //将自定义控件加入到查询条件模板中 this.add(m_rdoFree); this.add(m_rdoSubmit); this.add(m_rdoCheckGoing); this.add(m_rdoAudited); this.add(m_rdoNotPass); this.add(m_rdoAll); } /* 返回对条件的校验,如果返回为空,表示校验通过,反之返回错误原因。 * (non-Javadoc) * @see nc.ui.trade.query.INormalQuery#checkCondition() */ public String checkCondition() { return null; } /* 返回常用条件的SQL语句 * (non-Javadoc) * @see nc.ui.trade.query.INormalQuery#getWhereSql() */ public String getWhereSql() { String whereSql = "1=1"; if(m_isNormal != null && m_isNormal.equals("N")){ return whereSql; } if(m_rdoFree.isSelected()){//自由 if(tableName != null && tableName.length() > 0){ whereSql = whereSql + "and isnull("+tableName+".vbillstatus,'8')='8'"; }else{ whereSql = whereSql + "and isnull(vbillstatus,'8')='8'"; } } if(m_rdoSubmit.isSelected()){//提交 if(tableName != null && tableName.length() > 0){ whereSql = whereSql + "and isnull("+tableName+".vbillstatus,'8')='3'"; }else{ whereSql = whereSql + "and isnull(vbillstatus,'8')='3'"; } } if(m_rdoCheckGoing.isSelected()){//审批进行中 if(tableName != null && tableName.length() > 0){ whereSql = whereSql + "and isnull("+tableName+".vbillstatus,'8')='2'"; }else{ whereSql = whereSql + "and isnull(vbillstatus,'8')='2'"; } } if(m_rdoAudited.isSelected()){//审批通过 if(tableName != null && tableName.length() > 0){ whereSql = whereSql + "and isnull("+tableName+".vbillstatus,'8')='1'"; }else{ whereSql = whereSql + "and isnull(vbillstatus,'8')='1'"; } } if(m_rdoNotPass.isSelected()){//审批未通过 if(tableName != null && tableName.length() > 0){ whereSql = whereSql + "and isnull("+tableName+".vbillstatus,'8')='0'"; }else{ whereSql = whereSql + "and isnull(vbillstatus,'8')='0'"; } } if(m_rdoAll.isSelected()){ return "("+whereSql+")"; } return "("+whereSql+")"; } public void setTableName(String tableName) { this.tableName = tableName; } }
2.。创建一个查询对话框RentQueryDlgSelf ,继承nc.ui.trade.query.HYQueryDLG
package nc.ui.ldzl.rent; import java.awt.Container; import nc.ui.pub.beans.UIPanel; import nc.ui.trade.query.HYQueryDLG; public class RentQueryDlgSelf extends HYQueryDLG{ public RentQueryDlgSelf(Container parent, UIPanel normalPanel, String pk_corp, String moduleCode, String operator, String busiType) { super(parent, normalPanel, pk_corp, moduleCode, operator, busiType); hideUnitButton(); } public RentQueryDlgSelf(Container parent, UIPanel normalPanel, String pk_corp, String moduleCode, String operator, String busiType,String nodeKey) { super(parent, normalPanel, pk_corp, moduleCode, operator, busiType, nodeKey); hideUnitButton(); } }
3.。在EventHander 类里写入如方法进行调用:
protected UIDialog createQueryUI() { NormalPanel normalPanel = new NormalPanel(); Container parent = this.getBillUI(); String pk_corp = this._getCorp().getPrimaryKey(); String moduleCode = this.getBillUI()._getModuleCode(); String operator = this._getOperator(); String busiType = this.getBillUI().getBusinessType(); String nodeKey = this.getBillUI().getNodeKey(); RentQueryDlgSelf DLG = new RentQueryDlgSelf(parent, normalPanel, pk_corp, moduleCode, operator, busiType, nodeKey); return DLG; }