/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

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