- // 用于存放当前修改的记录的number,方便判断用户修改过number没有
- String tempNumber = "";
- public void loadFields() {
- super.loadFields();
- tempNumber = this.editData.getNumber();
- }
- // 验证
- protected void verifyInput(ActionEvent arg0) throws Exception {
- super.verifyInput(arg0);
- // 车号不能为空
- if (txtNumber.getText().trim().equalsIgnoreCase("")) {
- MsgBox.showWarning("车号不能为空!");
- txtNumber.requestFocusInWindow();
- SysUtil.abort();
- }
- if (this.oprtState.equals(OprtState.ADDNEW)) {
- IRentVehicle rentVehicle = RentVehicleFactory.getRemoteInstance();
- RentVehicleCollection rentVehiclerentVehicleCollection = rentVehicle
- .getRentVehicleCollection(" where number='"
- + txtNumber.getText().trim() + "'");
- if (rentVehicleCollection.size() > 0) {
- MsgBox.showWarning("车号已经存在,请重新输入!");
- txtNumber.requestFocusInWindow();
- SysUtil.abort();
- }
- } else if (this.oprtState.equalsIgnoreCase(OprtState.EDIT)) {
- // number有改动才需要验证
- if (!txtNumber.getText().trim().equals(tempNumber)) {
- IRentVehicle irentVehicle = RentVehicleFactory
- .getRemoteInstance();
- RentVehicleCollection rentVehicleCollection = irentVehicle
- .getRentVehicleCollection(" where number='"
- + txtNumber.getText().trim() + "'");
- if (rentVehicleCollection.size() > 0) {
- MsgBox.showWarning("车号已经存在,请重新输入!");
- txtNumber.requestFocusInWindow();
- SysUtil.abort();
- }
- }
- }
- // 类型
- if (prmtvehicleType.getValue() == null) {
- MsgBox.showWarning("类型不能为空!");
- prmtvehicleType.requestFocusInWindow();
- SysUtil.abort();
- }
- // 主驾驶姓名
- if (txtmainDriver.getText().trim().equals("")) {
- MsgBox.showWarning("主驾驶姓名不能为空!");
- txtmainDriver.requestFocusInWindow();
- SysUtil.abort();
- }
- // ×××号
- if (txtidentityNo.getText().trim().equals("")) {
- MsgBox.showWarning("×××号不能为空!");
- txtidentityNo.requestFocusInWindow();
- SysUtil.abort();
- }
- // ×××号码必须是15或者18位
- if (!txtidentityNo.getText().trim().equalsIgnoreCase("")) {
- if (txtidentityNo.getText().trim().length() != 15
- && txtidentityNo.getText().trim().length() != 18) {
- MsgBox.showWarning("×××号应该为15位或18位!");
- txtidentityNo.requestFocusInWindow();
- SysUtil.abort();
- }
- }
- // 行驶证号
- if (txttravelNo.getText().trim().equals("")) {
- MsgBox.showWarning("行驶证号不能为空!");
- txttravelNo.requestFocusInWindow();
- SysUtil.abort();
- }
- // 驾照类型
- if (prmtLicenseType.getValue() == null) {
- MsgBox.showWarning("驾照类型不能为空!");
- prmtLicenseType.requestFocusInWindow();
- SysUtil.abort();
- }
- // 出厂日期
- if (pkproduceDate.getValue() == null) {
- MsgBox.showWarning("出厂日期必须填写!");
- pkproduceDate.requestFocusInWindow();
- SysUtil.abort();
- }
- // 签发日期
- if (pkissuingDate.getValue() == null) {
- MsgBox.showWarning("签发日期必须填写!");
- pkissuingDate.requestFocusInWindow();
- SysUtil.abort();
- }
- // 到期日期
- if (pkexpireDate.getValue() == null) {
- MsgBox.showWarning("到期日期必须填写!");
- pkexpireDate.requestFocusInWindow();
- SysUtil.abort();
- }
- // 出厂日期<签发日期
- if (pkproduceDate.getValue() != null
- && pkissuingDate.getValue() != null) {
- if (((Date) pkproduceDate.getValue()).after((Date) pkissuingDate
- .getValue())) {
- MsgBox.showWarning("出厂日期不能晚于签发日期!");
- pkproduceDate.requestFocusInWindow();
- SysUtil.abort();
- }
- }
- // 签发日期<到期日期
- if (pkissuingDate.getValue() != null && pkexpireDate.getValue() != null) {
- if (((Date) pkissuingDate.getValue()).after((Date) pkexpireDate
- .getValue())) {
- MsgBox.showWarning("签发日期不能晚于到期日期!");
- pkissuingDate.requestFocusInWindow();
- SysUtil.abort();
- }
- }
- // 验证电话号码格式\d{3}-\d{8}|\d{4}-\d{7}
- if (!txttelephone.getText().trim().equals("")) {
- String telephone = txttelephone.getText().trim();
- String style = "1\\d{10}|\\d{3}-\\d{8}|\\d{4}-\\d{7}";
- Pattern ptt = Pattern.compile(style);
- Matcher mch = ptt.matcher(telephone);
- if (!mch.matches()) {
- MsgBox.showWarning("电话号码格式不对,电话必须是正确的手机号码或者是“区号-座机号”的形式!");
- txttelephone.requestFocusInWindow();
- SysUtil.abort();
- }
- }
- }