BOS中控件非空 非0校验

来源:互联网 发布:运动软件哪个好 编辑:程序博客网 时间:2024/06/08 01:29
 protected void verifyInput(ActionEvent arg0) throws Exception {    super.verifyInput(arg0);    //非空校验    HashMap<String, Object> verifyNullMap=new HashMap();    verifyNullMap.put("库存组织", prmtStorageOrgUnit);    verifyNullMap.put("工程类别", prmtProjectType);    verifyNullMap.put("设计量", txtDesignQty);    verifyNullMap.put("计量类型", comboMeasureType);    String [] strTmp=verifyNullMap.keySet().toArray(new String[verifyNullMap.size()]);    for(int i=verifyNullMap.size()-1;i>=0;i--)    CanNotNull(verifyNullMap.get(strTmp[i]),strTmp[i]);    //非0校验 可为空    HashMap<String, Object> verifyZeroMap=new HashMap();    verifyZeroMap.put("设计量", txtDesignQty);    String [] strZeroTmp=verifyZeroMap.keySet().toArray(new String[verifyZeroMap.size()]);    for(int i=verifyZeroMap.size()-1;i>=0;i--)    CanNotZero(verifyZeroMap.get(strZeroTmp[i]),strZeroTmp[i]);        }    //非空校验函数    protected void CanNotNull(Object obj,String message)    {    if((obj instanceof KDBizPromptBox && ((KDBizPromptBox)obj).getValue()==null)||       (obj instanceof KDComboBox && ((KDComboBox)obj).getSelectedItem()==null )||       (obj instanceof KDFormattedTextField &&((KDFormattedTextField)obj).getValue()==null))    {    MsgBox.showInfo(message+"不能为空!");    ((JComponent)obj).requestFocus();    abort();    }    }    //非0校验函数 可为空    protected void CanNotZero(Object obj,String message)    {    if(obj instanceof KDFormattedTextField && ((KDFormattedTextField)obj).getValue()!=null &&    (((KDFormattedTextField)obj).getBigDecimalValue().compareTo(BigDecimal.ZERO)==0))    {    MsgBox.showInfo(message+"值不能为  '0' !");    ((JComponent)obj).requestFocus();    abort();    }    }


原创粉丝点击