/webccr/src/com/emis/caesar/senao/event/button/TBtnIMEIReturn.java
https://bitbucket.org/sanliou/synccr · Java · 134 lines · 96 code · 14 blank · 24 comment · 22 complexity · 85b7a6335b86e544f9de639bc68d996d MD5 · raw file
- package com.emis.caesar.senao.event.button;
- import com.emis.caesar.senao.data.TEntryEdits;
- import com.emis.caesar.senao.event.TFocusSaleItemEventContext;
- import com.emis.caesar.senao.unit.TCcrConst;
- import com.emis.caesar.senao.unit.sale.TExItem;
- import com.emis.caesar.senao.util.CcrUtil;
- import com.emis.caesarui.webccr.webccr;
- import com.vaadin.ui.UI;
- import java.util.ArrayList;
- import java.util.HashMap;
- /**
- * IMEI銷退重銷記註
- *
- */
- public class TBtnIMEIReturn extends TFocusSaleItemEventContext {
- TEntryEdits FoEntryEdits = null;
- private TExItem oExItem_ = null;
- private String sIMEI = "";
- public TBtnIMEIReturn() {
- super();
- }
- public boolean runEventMethod(String sMethod_) {
- if (sMethod_.equals("returnOK")) {
- return returnOK();
- } else if (sMethod_.equals("returnCancel")) {
- return returnCancel();
- } else {
- return super.runEventMethod(sMethod_);
- }
- }
- protected boolean returnOK() {
- // ((webccr) UI.getCurrent()).getlog().info(webccr.class, "---原銷售交易OK---");
- CcrUtil.setMessage("---原銷售交易OK---");
- oExItem_.setIMEIreturn(true); // 設定為銷退重銷
- if (FoEntryEdits != null) {
- if (FoEntryEdits.getEdit(0) != null) {
- oExItem_.setSL_KEY_O(FoEntryEdits.getEdit(0).getText()); // SL_KEY
- }
- if (FoEntryEdits.getEdit(1) != null) {
- oExItem_.setSL_DATE_O(FoEntryEdits.getEdit(1).getText());// SL_DATE
- }
- }
- // ((webccr) UI.getCurrent()).getlog().info(webccr.class, "SL_KEY_O = " + oExItem_.getSL_KEY_O());
- // ((webccr) UI.getCurrent()).getlog().info(webccr.class, "SL_DATE_O = " + oExItem_.getSL_DATE_O());
- CcrUtil.setMessage("SL_KEY_O = " + oExItem_.getSL_KEY_O());
- CcrUtil.setMessage("SL_DATE_O = " + oExItem_.getSL_DATE_O());
- return execute();
- }
- protected boolean returnCancel() {
- // 隱藏錯誤訊息
- FsErrMsg = TCcrConst.MSG_HIDE;
- return eventOver(false);
- }
- // 檢核條件
- protected boolean verifyPrecondition(){
- // 取得游標選取的交易項
- if (isItemExisted()) {
- // 商品是否刪除
- if (!FoFocusItem.isCancel()) {
- if (!FoFocusItem.getFoExItemPool().isEmpty()) {
- if (FoFocusItem.getQty() == 1) {
- oExItem_ = FoFocusItem.getFoExItemPool().get(0);
- // if (!oExItem_.isIMEIreturn()) {
- sIMEI = oExItem_.getNo();
- return entryData();
- // } else {
- // FsErrMsg = "此IMEI已銷退";
- // return eventOver(false);
- // }
- } else {
- FsErrMsg = "僅處理數量為1的商品";
- return eventOver(false);
- }
- } else {
- FsErrMsg = "無IMEI資料,不可銷退重銷";
- return eventOver(false);
- }
- } else {
- FsErrMsg = "商品已刪除";
- return eventOver(false);
- }
- } else {
- return eventOver(false);
- }
- }
- // 輸入資料
- protected boolean entryData() {
- // 查詢資料
- // ((webccr) UI.getCurrent()).getlog().info(webccr.class, "IMEI:" + sIMEI);
- CcrUtil.setMessage("IMEI:" + sIMEI);
- // 補上當前商品編號查詢
- String sP_NO = FoFocusItem.getProduct().getFLDxP_NO();
- if (sP_NO.length() >= 8) {
- sP_NO = sP_NO.substring(0, 8);
- }
- ArrayList<HashMap> listReturn = FoCcr.getDbData.getReturnList(TCcrConst.BTN_IMEI_RETURN,
- sIMEI, sP_NO);
- if (!listReturn.isEmpty()) {
- // 彈出銷退視窗
- FoEntryEdits = new TEntryEdits("");
- FoCcr.UInotify.swReturn(FoEntryEdits, this, listReturn, "returnOK", "returnCancel");
- return handover();
- } else {
- // ((webccr) UI.getCurrent()).getlog().info(webccr.class, "---查無銷退資料---");
- FsErrMsg = "查無銷退資料!";
- return eventOver(false);
- }
- }
- // 執行事件主流程
- protected boolean execute(){
- StringBuffer bufMsg = new StringBuffer();
- bufMsg.append("銷退/重銷申請,已選擇:\n");
- bufMsg.append("交易序號:「" + oExItem_.getSL_KEY_O() + "」\n");
- bufMsg.append("銷售日期:「" + oExItem_.getSL_DATE_O() + "」\n");
- // ((webccr) UI.getCurrent()).getlog().info(webccr.class, "顯示訊息:\n" + bufMsg.toString());
- CcrUtil.setMessage("顯示訊息:\n" + bufMsg.toString());
- FoCcr.UInotify.swMessage(bufMsg.toString());
- return finalProcedure();
- }
- }