⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 vehicleformvalidator.java

📁 oa 源码
💻 JAVA
字号:
package com.redmoon.oa.vehicle;import javax.servlet.http.*;import com.redmoon.oa.base.*;import java.util.Vector;import cn.js.fan.util.ErrMsgException;import com.redmoon.oa.flow.FormField;import java.util.Iterator;import cn.js.fan.db.Conn;import cn.js.fan.web.Global;import java.sql.ResultSet;import java.sql.PreparedStatement;import java.sql.SQLException;import org.apache.log4j.Logger;public class VehicleFormValidator implements IFormValidator {    Logger logger = Logger.getLogger(VehicleFormValidator.class.getName());    public VehicleFormValidator() {    }        public boolean validate(HttpServletRequest httpServletRequest, int flowId, Vector fields) throws ErrMsgException {                Iterator ir = fields.iterator();        FormField beginDateField = null, endDateField = null, licenseNoField = null;        int count = 0;        while (ir.hasNext()) {            FormField ff = (FormField)ir.next();            if (ff.getName().equals("beginDate")) {                beginDateField = ff;                count += 1;            }            else if (ff.getName().equals("endDate")) {                endDateField = ff;                count += 1;            }            else if (ff.getName().equals("licenseNo")) {                licenseNoField = ff;                if (licenseNoField.getValue().equals(""))                    throw new ErrMsgException("请选择车牌号码!");                count += 1;            }            else if (ff.getName().equals("result")) {                                            }            if (count>=4)                break;        }        if (count<3)            throw new ErrMsgException("缺少域信息!");        String sql = "select flowId from form_table_vehicle_apply where beginDate>=? and endDate<=? and result='是' and flowId<>? and licenseNo=?";        ResultSet rs = null;        PreparedStatement ps = null;        Conn conn = new Conn(Global.defaultDB);        try {            ps = conn.prepareStatement(sql);            ps.setString(1, beginDateField.getValue());            ps.setString(2, endDateField.getValue());            ps.setInt(3, flowId);            ps.setString(4, licenseNoField.getValue());            rs = conn.executePreQuery();            if (rs!=null && rs.next())                throw new ErrMsgException("车牌为" + licenseNoField.getValue()  + "的车已被使用!");        }        catch (SQLException e) {            logger.error("validate:" + e.getMessage());        }        finally {            if (rs!=null) {                try { rs.close(); } catch (Exception e) {}                rs = null;            }            if (ps!=null) {                try { ps.close(); } catch (Exception e) {}                ps = null;            }            if (conn!=null) {                conn.close();                conn = null;            }        }        return true;    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -