PageRenderTime 18ms CodeModel.GetById 10ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 1ms

/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
  1package com.emis.caesar.senao.event.button;
  2
  3import com.emis.caesar.senao.data.TEntryEdits;
  4import com.emis.caesar.senao.event.TFocusSaleItemEventContext;
  5import com.emis.caesar.senao.unit.TCcrConst;
  6import com.emis.caesar.senao.unit.sale.TExItem;
  7import com.emis.caesar.senao.util.CcrUtil;
  8import com.emis.caesarui.webccr.webccr;
  9import com.vaadin.ui.UI;
 10
 11import java.util.ArrayList;
 12import java.util.HashMap;
 13
 14
 15/**
 16 * IMEI銷退重銷記註
 17 *
 18 */
 19public class TBtnIMEIReturn extends TFocusSaleItemEventContext {
 20
 21  TEntryEdits FoEntryEdits = null;
 22  private TExItem oExItem_ = null;
 23  private String sIMEI = "";
 24
 25  public TBtnIMEIReturn() {
 26    super();
 27  }
 28
 29  public boolean runEventMethod(String sMethod_) {
 30    if (sMethod_.equals("returnOK")) {
 31      return returnOK();
 32    } else if (sMethod_.equals("returnCancel")) {
 33      return returnCancel();
 34    } else {
 35      return super.runEventMethod(sMethod_);
 36    }
 37  }
 38
 39  protected boolean returnOK() {
 40//    ((webccr) UI.getCurrent()).getlog().info(webccr.class, "---原銷售交易OK---");
 41    CcrUtil.setMessage("---原銷售交易OK---");
 42    oExItem_.setIMEIreturn(true); // 設定為銷退重銷
 43    if (FoEntryEdits != null) {
 44      if (FoEntryEdits.getEdit(0) != null) {
 45        oExItem_.setSL_KEY_O(FoEntryEdits.getEdit(0).getText()); // SL_KEY
 46      }
 47      if (FoEntryEdits.getEdit(1) != null) {
 48        oExItem_.setSL_DATE_O(FoEntryEdits.getEdit(1).getText());// SL_DATE
 49      }
 50    }
 51//    ((webccr) UI.getCurrent()).getlog().info(webccr.class, "SL_KEY_O = " + oExItem_.getSL_KEY_O());
 52//    ((webccr) UI.getCurrent()).getlog().info(webccr.class, "SL_DATE_O = " + oExItem_.getSL_DATE_O());
 53    CcrUtil.setMessage("SL_KEY_O = " + oExItem_.getSL_KEY_O());
 54    CcrUtil.setMessage("SL_DATE_O = " + oExItem_.getSL_DATE_O());
 55
 56    return execute();
 57  }
 58
 59  protected boolean returnCancel() {
 60    // 隱藏錯誤訊息
 61    FsErrMsg = TCcrConst.MSG_HIDE;
 62    return eventOver(false);
 63  }
 64
 65  // 檢核條件
 66  protected boolean verifyPrecondition(){
 67    // 取得游標選取的交易項
 68    if (isItemExisted()) {
 69      // 商品是否刪除 
 70      if (!FoFocusItem.isCancel()) {
 71        if (!FoFocusItem.getFoExItemPool().isEmpty()) {
 72          if (FoFocusItem.getQty() == 1) {
 73            oExItem_ = FoFocusItem.getFoExItemPool().get(0);
 74//            if (!oExItem_.isIMEIreturn()) {
 75            sIMEI = oExItem_.getNo();
 76            return entryData();
 77//            } else {
 78//              FsErrMsg = "此IMEI已銷退";
 79//              return eventOver(false);
 80//            }
 81          } else {
 82            FsErrMsg = "僅處理數量為1的商品";
 83            return eventOver(false);
 84          }
 85        } else {
 86          FsErrMsg = "無IMEI資料,不可銷退重銷";
 87          return eventOver(false);
 88        }
 89      } else {
 90        FsErrMsg = "商品已刪除";
 91        return eventOver(false);
 92      }
 93    } else {
 94      return eventOver(false);
 95    }
 96  }
 97
 98  // 輸入資料
 99  protected boolean entryData() {
100    // 查詢資料
101//    ((webccr) UI.getCurrent()).getlog().info(webccr.class, "IMEI:" + sIMEI);
102    CcrUtil.setMessage("IMEI:" + sIMEI);
103    // 補上當前商品編號查詢
104    String sP_NO = FoFocusItem.getProduct().getFLDxP_NO();
105    if (sP_NO.length() >= 8) {
106      sP_NO = sP_NO.substring(0, 8);
107    }
108    ArrayList<HashMap> listReturn = FoCcr.getDbData.getReturnList(TCcrConst.BTN_IMEI_RETURN,
109        sIMEI, sP_NO);
110    if (!listReturn.isEmpty()) {
111      // 彈出銷退視窗
112      FoEntryEdits = new TEntryEdits("");
113      FoCcr.UInotify.swReturn(FoEntryEdits, this, listReturn, "returnOK", "returnCancel");
114      return handover();
115    } else {
116//      ((webccr) UI.getCurrent()).getlog().info(webccr.class, "---查無銷退資料---");
117      FsErrMsg = "查無銷退資料!";
118      return eventOver(false);
119    }
120  }
121
122  // 執行事件主流程
123  protected boolean execute(){
124    StringBuffer bufMsg = new StringBuffer();
125    bufMsg.append("銷退/重銷申請,已選擇:\n");
126    bufMsg.append("交易序號:「" + oExItem_.getSL_KEY_O() + "」\n");
127    bufMsg.append("銷售日期:「" + oExItem_.getSL_DATE_O() + "」\n");
128//    ((webccr) UI.getCurrent()).getlog().info(webccr.class, "顯示訊息:\n" + bufMsg.toString());
129    CcrUtil.setMessage("顯示訊息:\n" + bufMsg.toString());
130    FoCcr.UInotify.swMessage(bufMsg.toString());
131    return finalProcedure();
132  }
133
134}