/* (non-Javadoc) * @see com.extjs.gxt.ui.client.event.Listener#handleEvent(com.extjs.gxt.ui.client.event.BaseEvent) */ public void handleEvent(BaseEvent be) { sync++; try { if (sync == 1) { Debug.printf(be.getType(), 4); if (be.getType() == Events.Select) { if (be.getSource() == printer) { Print(); } } } } finally { sync--; } }
/** TextField change event listener */ @Override public void handleEvent(BaseEvent be) { if (activateHandler) { final Field<Object> field = (Field<Object>) be.getSource(); FieldEvent fieldEvent = null; if (be instanceof FieldEvent) { fieldEvent = (FieldEvent) be; } if (be.getType() == Events.SpecialKey) { if (null != fieldEvent && fieldEvent.getKeyCode() == 8) { updatePropertyMessage(Config.valueOf(field.getName()), ConfigStatus.EDITING); } else if (null != fieldEvent && fieldEvent.getKeyCode() == 13) { saveValue(field); } } else if ((be.getType() == Events.KeyPress || be.getType() == Events.KeyDown || be.getType() == Events.KeyUp)) { if (null != fieldEvent && fieldEvent.getKeyCode() != 37 && fieldEvent.getKeyCode() != 39 && fieldEvent.getKeyCode() != 9 && fieldEvent.getKeyCode() != 16) { if (field.isDirty()) { updatePropertyMessage(Config.valueOf(field.getName()), ConfigStatus.EDITING); } } } else if (be.getType() == Events.SelectionChange || be.getType() == Events.Change) { saveValue(field); } if (null != fieldEvent && fieldEvent.isControlKey() && ((fieldEvent.getKeyCode() == 'Z') || fieldEvent.getKeyCode() == 'Y')) { saveValue(field); } } }
@Override public void handleEvent(BaseEvent be) { // TODO Auto-generated method stub if (be.getType().equals(Events.Select)) { // 会员充值 if (be.getSource().equals(addfinace)) { AddFinace_acc addfinace_acc = new AddFinace_acc(); addfinace_acc.setIsnew(0); addfinace_acc.showDialog(); } if (be.getSource().equals(d.getButtonById(Dialog.NO))) { close(); } else if (be.getSource().equals(d.getButtonById(Dialog.YES))) { passwordc_t.clearInvalid(); String passwordc = (passwordc_t.getValue() == null ? "" : passwordc_t.getValue()); String password = (password_t.getValue() == null ? "" : password_t.getValue()); if ((!passwordc.equals(password))) { passwordc_t.markInvalid("两次录入密码不一致"); MessageBox.alert("提示", "两次密码录入不一致", null); return; } if (w.isValid()) { CommandSyncContainer list = new CommandSyncContainer(); CommandSyncsql commandsql = new CommandSyncsql(); // 保存 commandsql.getV().addAll(store._trySave(0)); // 更新ccode /** 不得已才如此操作,因为ccode的ccode字段是与其他操作管理的字段,和ccodepanel里的做法一直, 默认与icode同值 */ GWT.log( "update ccode set ccode =icode where s_cardno='" + cardno_t.getValue() + "' and cname='" + cname_t.getValue() + "'", null); commandsql .getV() .add( "update ccode set ccode =icode where s_cardno='" + cardno_t.getValue() + "' and cname='" + cname_t.getValue() + "'"); list.add(commandsql); final com.base.myproject.client.tools.GreetingServiceAsync greetingService = GWT.create(com.base.myproject.client.tools.GreetingService.class); greetingService.SendCommandSync( list, new AsyncCallback<CommandSyncReturnObject>() { public void onFailure(Throwable caught) { Window.alert("网络连接不稳定,请稍后重试!"); } public void onSuccess(CommandSyncReturnObject cyro) { System.out.println("成功:" + cyro.getMessage() + cyro.isB() + cyro.getRetrunstr()); if (cyro.isB()) { Info.display("", "保存成功", ""); addfinace.setEnabled(true); // close(); } else { MessageBox.alert("错误", "保存错误!" + cyro.getMessage(), null); } } }); // store.trySave(0); d.getButtonById(Dialog.YES).setEnabled(false); } else MessageBox.alert("禁止", "请检查录入是否正确!", null); } } else if (be.getType().equals(Events.Change)) { if (be.getSource().equals(cardno_t)) { final com.base.myproject.client.tools.GreetingServiceAsync greetingService = GWT.create(com.base.myproject.client.tools.GreetingService.class); greetingService.getDataSet( "select count(*) as c from ccode where s_cardno='" + cardno_t.getValue() + "'", new AsyncCallback<DataSet>() { @Override public void onFailure(Throwable caught) {} @Override public void onSuccess(DataSet result) { if (Integer.parseInt(result.getValue(0, "c")) > 0) { Validator v = new Validator() { @Override public String validate(Field<?> field, String value) { return "已经存在相同卡号的用户"; } }; cardno_t.setValidator(v); } else { cardno_t.setValidator(null); } cardno_t.validate(); } }); } else if (be.getSource().equals(cname_t)) { final com.base.myproject.client.tools.GreetingServiceAsync greetingService = GWT.create(com.base.myproject.client.tools.GreetingService.class); greetingService.getDataSet( "select count(*) as c from ccode where cname='" + cname_t.getValue() + "'", new AsyncCallback<DataSet>() { @Override public void onFailure(Throwable caught) {} @Override public void onSuccess(DataSet result) { if (Integer.parseInt(result.getValue(0, "c")) > 0) { Validator v = new Validator() { @Override public String validate(Field<?> field, String value) { return "已经存在相同名字的用户"; } }; cname_t.setValidator(v); } else { cname_t.setValidator(null); } cname_t.validate(); } }); } // else if (name.equals("s_cardno")) { // ccode_t.setFireChangeEventOnSetValue(true); // ccode_t.setValue(icode_t.getValue()); // ccode_t.setFireChangeEventOnSetValue(false); // } } }