public void populateResultSet(MVCMgr mvcMgr, ResultSet rs) throws Exception { if (rs != null) { if (mvcMgr.getFoundMode().equals(Constant.FIND_VENDOR)) { while (rs.next()) { PoVendor vendor = new PoVendor(); vendor.setVendorId(Decoder.convertGetString(rs.getString(26))); vendor.setVendorCode(Decoder.convertGetString(rs.getString(1))); vendor.setVendorName(Decoder.convertGetString(rs.getString(2))); vendor.setAddress(Decoder.convertGetString(rs.getString(3))); vendor.setPresident(Decoder.convertGetString(rs.getString(4))); vendor.setWebsite(Decoder.convertGetString(rs.getString(5))); vendor.setCreditLine(Decoder.convertGetString(rs.getString(14))); vendor.setTurnover(Decoder.convertGetString(rs.getString(15))); vendor.setEmployeeNum(Decoder.convertGetString(rs.getString(16))); vendor.setEstablishedYear(Decoder.convertGetString(rs.getString(17))); vendor.setMajorMarket(Decoder.convertGetString(rs.getString(18))); vendor.setImportPercentage(Decoder.convertGetString(rs.getString(19))); vendor.setExportPercentage(Decoder.convertGetString(rs.getString(20))); vendor.setGroupCompany(Decoder.convertGetString(rs.getString(21))); vendor.setTotalCapacity(Decoder.convertGetString(rs.getString(22))); vendor.setConclusion(Decoder.convertGetString(rs.getString(23))); vendor.setPaymentTerm( (PaymentTerm) Utility.getObject( ((PoMgr) mvcMgr).getPurchaseOrderMeta().getPaymentTermList(), Decoder.convertGetString(rs.getString(27)))); vendor.setVat( (VAT) Utility.getObject( ((PoMgr) mvcMgr).getPurchaseOrderMeta().getVatList(), Decoder.convertGetString(rs.getString(28)))); vendor.setPoType( (SelectionOption) Utility.getObject( ((PoMgr) mvcMgr).getPurchaseOrderMeta().getPoTypeList(), Decoder.convertGetString(rs.getString(29)))); vendor.setDeliveryTerm( (DeliveryTerm) Utility.getObject( ((PoMgr) mvcMgr).getPurchaseOrderMeta().getDeliveryTermList(), rs.getString(30))); vendor.setMajorSupplier(rs.getString(31) != null && rs.getString(31).equals("Y")); this.getFindList().add(vendor); } } else if (mvcMgr.getFoundMode().equals(Constant.FIND_CONTACT)) { while (rs.next()) { PoVendorContact contact = new PoVendorContact(); contact.setContactId(Decoder.convertGetString(rs.getString(1))); contact.setContactCode(Decoder.convertGetString(rs.getString(2))); contact.setContactPersonName(Decoder.convertGetString(rs.getString(3))); contact.setMobile(Decoder.convertGetString(rs.getString(4))); contact.setEmail(Decoder.convertGetString(rs.getString(5))); contact.setFactoryCode(Decoder.convertGetString(rs.getString(7))); contact.setAddress(Decoder.convertGetString(rs.getString(8))); contact.setMobile(Decoder.convertGetString(rs.getString(9))); contact.setFax(Decoder.convertGetString(rs.getString(10))); contact.setPoType( (SelectionOption) Utility.getObject( ((PoMgr) mvcMgr).getPurchaseOrderMeta().getPoTypeList(), Decoder.convertGetString(rs.getString(11)))); this.getFindList().add(contact); } } else if (mvcMgr.getFoundMode().equals(Constant.FIND_PO_PART)) { while (rs.next()) { PoPurchaseRequestDetail purchaseRequestDetail = new PoPurchaseRequestDetail(); purchaseRequestDetail.setPrDetailId(rs.getString(1)); purchaseRequestDetail.setPrId(Decoder.convertGetString(rs.getString(2))); purchaseRequestDetail.setPrNo(Decoder.convertGetString(rs.getString(2))); purchaseRequestDetail.setRequestQty(Decoder.convertGetString(rs.getString(3))); purchaseRequestDetail.setRequestDate(Decoder.convertGetString(rs.getString(4))); purchaseRequestDetail.setRemark(Decoder.convertGetString(rs.getString(5))); purchaseRequestDetail.setCreatedBy(Decoder.convertGetString(rs.getString(18))); purchaseRequestDetail.setPartTypeCode(Decoder.convertGetString(rs.getString(19))); purchaseRequestDetail.setVpnCode(Decoder.convertGetString(rs.getString(20))); purchaseRequestDetail.setVpnName(Decoder.convertGetString(rs.getString(21))); Quote quote = new Quote(); quote.setQuoteUnitPrice(Decoder.convertGetString(rs.getString(16))); Currency currency = new Currency(); currency.setAttributeId(Decoder.convertGetString(rs.getString(17))); currency.setAttributeCode(Decoder.convertGetString(rs.getString(17))); currency.setAttributeName(Decoder.convertGetString(rs.getString(17))); quote.setCurrency(currency); purchaseRequestDetail.setQuote(quote); PoPart part = new PoPart(Decoder.convertGetString(rs.getString(12))); part.setPnId(Decoder.convertGetString(rs.getString(7))); part.setPnCode(Decoder.convertGetString(rs.getString(8))); part.setPnName(Decoder.convertGetString(rs.getString(9))); part.setPartFullName(Decoder.convertGetString(rs.getString(10))); part.setPrimaryUnitOfMeasure( new UOM( Decoder.convertGetString(rs.getString(13)), Decoder.convertGetString(rs.getString(14)), Decoder.convertGetString(rs.getString(15)))); PartType partType = new PartType(); partType.setAttributeId(Decoder.convertGetString(rs.getString(19))); partType.setAttributeCode(Decoder.convertGetString(rs.getString(22))); partType.setAttributeName(Decoder.convertGetString(rs.getString(23))); part.setPartType(partType); purchaseRequestDetail.setPart(part); this.getFindList().add(purchaseRequestDetail); } } else if (mvcMgr.getFoundMode().equals(Constant.FIND_PART) || mvcMgr.getFoundMode().equals(Constant.FIND_FOC_PART)) { while (rs.next()) { PoPart part = new PoPart(Decoder.convertGetString(rs.getString(7))); part.setPnId(Decoder.convertGetString(rs.getString(1))); part.setPnCode(Decoder.convertGetString(rs.getString(2))); part.setPartName(Decoder.convertGetString(rs.getString(3))); part.setPartFullName(Decoder.convertGetString(rs.getString(4))); part.setCompleteName(Decoder.convertGetString(rs.getString(5))); part.setPnDescription(Decoder.convertGetString(rs.getString(6))); part.setStdPurchaseUnitPrice(Decoder.convertGetString(rs.getString(8))); part.setPurchaseLeadTime(Decoder.convertGetString(rs.getString(9))); UOM uom = new UOM(); uom.setAttributeId(Decoder.convertGetString(rs.getString(10))); uom.setAttributeCode(Decoder.convertGetString(rs.getString(11))); uom.setAttributeName(Decoder.convertGetString(rs.getString(12))); part.setPrimaryUnitOfMeasure(uom); PartType partType = new PartType(); partType.setAttributeId(Decoder.convertGetString(rs.getString(13))); partType.setAttributeCode(Decoder.convertGetString(rs.getString(14))); partType.setAttributeName(Decoder.convertGetString(rs.getString(15))); part.setPartType(partType); part.getLocation().setAttributeId(Decoder.convertGetString(rs.getString(16))); part.setVpnCode(Decoder.convertGetString(rs.getString(17))); part.setVpnName(Decoder.convertGetString(rs.getString(18))); this.getFindList().add(part); } } else if (mvcMgr.getFoundMode().equals(Constant.FIND_PO) || mvcMgr.getFoundMode().equals(Constant.FIND_PO_COPY)) { while (rs.next()) { PurchaseOrder purchaseOrder = new PurchaseOrder(); PoVendorContact contact = new PoVendorContact(); PoVendor vendor = new PoVendor(); purchaseOrder.setPoNo(Decoder.convertGetString(rs.getString(1))); vendor.setVendorId(Decoder.convertGetString(rs.getString(2))); contact.setContactId(Decoder.convertGetString(rs.getString(3))); purchaseOrder.setBillToSelfSite( (SelfSite) Utility.getObject( ((PoMgr) mvcMgr).getPurchaseOrderMeta().getSelfSiteList(), rs.getString(4))); purchaseOrder.setShipToSelfSite( (SelfSite) Utility.getObject( ((PoMgr) mvcMgr).getPurchaseOrderMeta().getSelfSiteList(), rs.getString(5))); purchaseOrder.setCurrency( (Currency) Utility.getObject( ((PoMgr) mvcMgr).getPurchaseOrderMeta().getCurrencyList(), rs.getString(6))); purchaseOrder.setPoTotalAmount(rs.getString(8)); purchaseOrder.setDeliveryTerm( (DeliveryTerm) Utility.getObject( ((PoMgr) mvcMgr).getPurchaseOrderMeta().getDeliveryTermList(), rs.getString(9))); purchaseOrder.setDeliveryDate(Decoder.convertGetString(rs.getString(10))); purchaseOrder.setRemark(Decoder.convertGetString(rs.getString(11))); purchaseOrder.setShippingMark(Decoder.convertGetString(rs.getString(12))); purchaseOrder.setPoStatus( (PoStatus) Utility.getObject( ((PoMgr) mvcMgr).getPurchaseOrderMeta().getPoStatusList(), rs.getString(13))); purchaseOrder.setCreationDate(Decoder.convertGetString(rs.getString(14))); purchaseOrder.setCreatedBy(Decoder.convertGetString(rs.getString(15))); purchaseOrder.setModifiedReason(Decoder.convertGetString(rs.getString(17))); vendor.setVendorName(Decoder.convertGetString(rs.getString(19))); contact.setContactPersonName(Decoder.convertGetString(rs.getString(20))); contact.setAddress(Decoder.convertGetString(rs.getString(21))); contact.setMobile(Decoder.convertGetString(rs.getString(22))); contact.setFax(Decoder.convertGetString(rs.getString(23))); contact.setEmail(Decoder.convertGetString(rs.getString(24))); purchaseOrder.setPoType( (SelectionOption) Utility.getObject( ((PoMgr) mvcMgr).getPurchaseOrderMeta().getPoTypeList(), rs.getString(25))); purchaseOrder.setPoCategory( (PoCategory) Utility.getObject( ((PoMgr) mvcMgr).getPurchaseOrderMeta().getPoCategoryList(), rs.getString(26))); purchaseOrder.setPoRefNo(Decoder.convertGetString(rs.getString(27))); // purchaseOrder.setRevision(rs.getInt(27)); vendor.setVendorCode(rs.getString(28)); purchaseOrder.setVat( (VAT) Utility.getObject( ((PoMgr) mvcMgr).getPurchaseOrderMeta().getVatList(), rs.getString(29))); // // purchaseOrder.setIsSuspense(Decoder.convertGetString(rs.getString(30)).equals("Y") ? // true : false); purchaseOrder.setDiscountTotalPrice(Decoder.convertGetString(rs.getString(30))); purchaseOrder.setRevision(Decoder.convertGetString(rs.getString(31))); vendor.setCurrentPoContact(contact); purchaseOrder.setVendor(vendor); if (((PoMgr) mvcMgr).getEntryMode().equals(Constant.VIEW_STATUS)) { purchaseOrder.setFlag("Y"); } vendor.setMajorSupplier(rs.getString(32) != null && rs.getString(32).equals("Y")); this.getFindList().add(purchaseOrder); } } } }
public void populateFindColumnList(MVCMgr mvcMgr, Login login) { this.getFindColumnList().clear(); if (mvcMgr.getFoundMode().equals(Constant.FIND_VENDOR)) { this.getFindColumnList() .add( new FindSearch( "1", this.getLanguageTranslation("VendorCode", login, "PUR"), "PV.VENDOR_CODE")); this.getFindColumnList() .add( new FindSearch( "2", this.getLanguageTranslation("VendorName", login, "PUR"), "PV.VENDOR_NAME")); } else if (mvcMgr.getFoundMode().equals(Constant.FIND_CONTACT)) { this.getFindColumnList() .add( new FindSearch( "1", this.getLanguageTranslation("ContactCode", login, "PUR"), "PC.CONTACT_CODE")); this.getFindColumnList() .add( new FindSearch( "2", this.getLanguageTranslation("ContactName", login, "PUR"), "PC.CONTACT_PERSON_NAME")); this.getFindColumnList() .add( new FindSearch( "3", this.getLanguageTranslation("E-mail", login, "PUR"), "PC.E_MAIL")); this.getFindColumnList() .add( new FindSearch( "4", this.getLanguageTranslation("Mobile", login, "PUR"), "PC.MOBILE")); } else if (mvcMgr.getFoundMode().equals(Constant.FIND_PO_PART) || mvcMgr.getFoundMode().equals(Constant.FIND_PART) || mvcMgr.getFoundMode().equals(Constant.FIND_FOC_PART)) { this.getFindColumnList() .add( new FindSearch( "1", this.getLanguageTranslation("PartCode", login, "PUR"), "IP.PART_CODE")); this.getFindColumnList() .add( new FindSearch( "2", this.getLanguageTranslation("PartName", login, "PUR"), "IP.PART_NAME")); this.getFindColumnList() .add( new FindSearch( "3", this.getLanguageTranslation("PartFullName", login, "PUR"), "IP.PART_FULL_NAME")); this.getFindColumnList() .add( new FindSearch( "4", this.getLanguageTranslation("PartType", login, "PUR"), "IPT.PART_TYPE_NAME")); } else if (mvcMgr.getFoundMode().equals(Constant.FIND_PO) || mvcMgr.getFoundMode().equals(Constant.FIND_PO_COPY)) { this.getFindColumnList() .add( new FindSearch( "1", this.getLanguageTranslation("PONo", login, "PUR"), "PP.PO_REF_NO")); this.getFindColumnList() .add( new FindSearch( "2", this.getLanguageTranslation("VendorName", login, "PUR"), "PV.VENDOR_NAME")); this.getFindColumnList() .add( new FindSearch( "3", this.getLanguageTranslation("CreateBy", login, "PUR"), "PP.CREATED_BY")); this.getFindColumnList() .add( new FindSearch( "4", this.getLanguageTranslation("CreationDate", login, "PUR"), "TO_CHAR(PP.CREATION_DATE, 'YYYY-MM-DD')")); this.getFindColumnList() .add( new FindSearch( "5", this.getLanguageTranslation("POType", login, "PUR"), "DECODE(PP.PO_TYPE,'I','Oversea','Local')")); } }
public String populateQuerytList(MVCMgr mvcMgr, Login login) throws Exception { // System.out.println(" populateQuerytList com.laconic.pur.po.component;"); StringBuffer sqlBuffer = new StringBuffer(); if (mvcMgr.getFoundMode().equals(Constant.FIND_VENDOR)) { if (((PoMgr) mvcMgr).getEntryMode().equals(Constant.CREATE_QUICK_PO)) { sqlBuffer.append(" SELECT PV.VENDOR_CODE, PV.VENDOR_NAME, PV.BIO_ADDRESS, "); sqlBuffer.append(" PV.PRESIDENT, PV.WEB_SITE, PV.BIO_TEL1, "); sqlBuffer.append(" PV.BIO_TEL2, PV.BIO_TEL3, PV.BIO_FAX1, "); sqlBuffer.append(" PV.BIO_FAX2, PV.BIO_FAX3, PV.COUNTRY, "); sqlBuffer.append(" PV.PAYMENT_TERM, PV.CREDIT_LINE, PV.TURNOVER, "); sqlBuffer.append(" PV.NO_OF_EMPLOYEE, PV.ESTABLISHED_YEAR, PV.MAJOR_MARKET, "); sqlBuffer.append(" PV.IMPORT, PV.EXPORT, PV.OTHER_GROUP_COMPANIES, "); sqlBuffer.append(" PV.TOTAL_CAPACITY, PV.REMARK, NULL, "); sqlBuffer.append(" PV.GROUP_CODE, PV.VENDOR_ID, PV.PAYMENT_TERM_ID, "); sqlBuffer.append( " PV.TAX_ID, DECODE((SELECT VALUE FROM FM_GL_INIT_PARAMETER WHERE NAME = 'COUNTRY'),PV.COUNTRY_ID,'L','I'), "); sqlBuffer.append(" PV.DELIVERY_TERM_ID, NVL(PV.MAJOR_SUPPLIER_FLAG,'N') "); sqlBuffer.append(" FROM PUR_VENDOR PV "); sqlBuffer.append(" WHERE 1 = 1 "); sqlBuffer.append( " AND (EXISTS (SELECT 'O' FROM PUR_VENDOR_PART PVP WHERE PVP.VENDOR_ID = PV.VENDOR_ID ) "); sqlBuffer.append(" OR NVL(PV.MAJOR_SUPPLIER_FLAG,'N') = 'Y' ) "); sqlBuffer.append(" AND NVL(PV.STATUS,'E') = 'E'"); this.isRearchCondition(sqlBuffer); if (!this.isHaveOrderBy(sqlBuffer)) { sqlBuffer.append(" ORDER BY VENDOR_CODE "); } } } else if (mvcMgr.getFoundMode().equals(Constant.FIND_CONTACT)) { sqlBuffer.append(" SELECT PC.CONTACT_ID, PC.CONTACT_CODE, PC.CONTACT_PERSON_NAME, "); sqlBuffer.append(" PC.MOBILE, PC.E_MAIL, PC.TITLE, "); sqlBuffer.append(" PVF.FACTORY_CODE, PVF.F_ADDRESS, PVF.F_TEL1, "); sqlBuffer.append( " PVF.F_FAX1, DECODE((SELECT VALUE FROM FM_GL_INIT_PARAMETER WHERE NAME = 'COUNTRY'),PVF.F_COUNTRY_ID,'L','I') "); sqlBuffer.append(" FROM PUR_CONTACT PC, "); sqlBuffer.append(" PUR_VENDOR_FACTORY PVF "); sqlBuffer.append(" WHERE PC.VENDOR_ID = "); sqlBuffer.append(((PoMgr) mvcMgr).getCurrentPurchaseOrder().getVendor().getVendorId()); sqlBuffer.append(" AND PVF.FACTORY_ID = PC.FACTORY_ID "); // sqlBuffer.append(" AND PC.FLAG = 'V' "); this.isRearchCondition(sqlBuffer); if (!this.isHaveOrderBy(sqlBuffer)) { sqlBuffer.append(" ORDER BY 2 "); } } else if (mvcMgr.getFoundMode().equals(Constant.FIND_PO_PART)) { sqlBuffer.append(" SELECT NULL A, NULL B, 0 C, "); sqlBuffer.append(" NULL D, PVP.DESCRIPTION, NULL E, "); sqlBuffer.append(" IP.PART_ID, IP.PART_CODE, IP.PART_NAME, "); sqlBuffer.append(" IP.PART_FULL_NAME, IP.PART_PRODUCTION_TYPE_ID, IPT.PART_CATEGORY, "); sqlBuffer.append(" IU.UOM_ID, IU.UOM_CODE, IU.UOM_NAME, "); sqlBuffer.append(" NVL(PVP.PRICE_UNIT,0), PVP.CURRENCY, IP.CREATED_BY, "); sqlBuffer.append(" IPT.PART_TYPE_CODE, VENDOR_PART_CODE, VENDOR_PART_NAME, "); sqlBuffer.append(" IPT.PART_TYPE_ID, IPT.PART_TYPE_NAME "); sqlBuffer.append(" FROM ITEM_UOM IU, "); sqlBuffer.append(" ITEM_PART_TYPE IPT, "); sqlBuffer.append(" ITEM_PART IP, "); sqlBuffer.append(" (SELECT * FROM PUR_VENDOR_PART WHERE VENDOR_ID = "); sqlBuffer.append(((PoMgr) mvcMgr).getCurrentPurchaseOrder().getVendor().getVendorId()); sqlBuffer.append(" ) PVP "); sqlBuffer.append(" WHERE IP.ORDERABLE_FLAG = 'Y' "); sqlBuffer.append(" AND NVL(IP.TEMPLATE_ITEM_FLAG,'N') = 'N' "); if (((PoMgr) mvcMgr).getCurrentPurchaseOrder().getVendor().isMajorSupplier()) { sqlBuffer.append(" AND IP.PART_ID = PVP.PART_ID(+) "); } else { sqlBuffer.append(" AND IP.PART_ID = PVP.PART_ID "); } sqlBuffer.append(" AND IP.PART_TYPE_ID = IPT.PART_TYPE_ID(+) "); sqlBuffer.append(" AND IU.UOM_ID = IP.UOM_ID "); /* Part type code filter */ sqlBuffer.append(" AND IPT.PART_TYPE_ID = IP.PART_TYPE_ID "); if (((PoMgr) mvcMgr).getPartTypeFromString() != null && !((PoMgr) mvcMgr).getPartTypeFromString().equals("")) { sqlBuffer.append( " AND IPT.PART_TYPE_CODE >= '" + ((PoMgr) mvcMgr).getPartTypeFromString() + "' "); } if (((PoMgr) mvcMgr).getPartTypeToString() != null && !((PoMgr) mvcMgr).getPartTypeToString().equals("")) { sqlBuffer.append( " AND IPT.PART_TYPE_CODE <= '" + ((PoMgr) mvcMgr).getPartTypeToString() + "' "); } /* Part physical dimension filter */ if (((PoMgr) mvcMgr).getFromWidth() != null && ((PoMgr) mvcMgr).getFromWidth().matches("^(?=.+)(?:[1-9]\\d*|0)?(?:\\.\\d+)?$")) { sqlBuffer.append(" AND NVL(IP.UNIT_WIDTH,0) >= " + ((PoMgr) mvcMgr).getFromWidth()); } if (((PoMgr) mvcMgr).getToWidth() != null && ((PoMgr) mvcMgr).getToWidth().matches("^(?=.+)(?:[1-9]\\d*|0)?(?:\\.\\d+)?$")) { sqlBuffer.append(" AND NVL(IP.UNIT_WIDTH,0) <= " + ((PoMgr) mvcMgr).getToWidth()); } if (((PoMgr) mvcMgr).getFromLength() != null && !((PoMgr) mvcMgr).getFromLength().equals("")) { if (((PoMgr) mvcMgr).getFromLength().matches("^(?=.+)(?:[1-9]\\d*|0)?(?:\\.\\d+)?$")) { sqlBuffer.append(" AND IP.UNIT_LENGTH >= " + ((PoMgr) mvcMgr).getFromLength()); if (((PoMgr) mvcMgr).getToLength() != null && ((PoMgr) mvcMgr).getToLength().matches("^(?=.+)(?:[1-9]\\d*|0)?(?:\\.\\d+)?$")) { sqlBuffer.append(" AND IP.UNIT_LENGTH <= " + ((PoMgr) mvcMgr).getToLength()); } } else { sqlBuffer.append(" AND IP.UNIT_LENGTH IS NULL "); } } if (((PoMgr) mvcMgr).getFromThickness() != null && ((PoMgr) mvcMgr).getFromThickness().matches("^(?=.+)(?:[1-9]\\d*|0)?(?:\\.\\d+)?$")) { sqlBuffer.append(" AND NVL(IP.UNIT_HEIGHT,0) >= " + ((PoMgr) mvcMgr).getFromThickness()); } if (((PoMgr) mvcMgr).getToThickness() != null && ((PoMgr) mvcMgr).getToThickness().matches("^(?=.+)(?:[1-9]\\d*|0)?(?:\\.\\d+)?$")) { sqlBuffer.append(" AND NVL(IP.UNIT_HEIGHT,0) <= " + ((PoMgr) mvcMgr).getToThickness()); } if (ParameterUtil.isItemSeparatedByFactory) { sqlBuffer.append( " AND EXISTS (SELECT 'O' FROM ITEM_PART_FACTORY IPF WHERE IPF.PART_ID = IP.PART_ID AND IPF.FACTORY_ID = " + login.getEmployee().getFactoryId() + " ) "); } this.isRearchCondition(sqlBuffer); if (!this.isHaveOrderBy(sqlBuffer)) { sqlBuffer.append(" ORDER BY IP.PART_CODE "); } } else if (mvcMgr.getFoundMode().equals(Constant.FIND_PART) || mvcMgr.getFoundMode().equals(Constant.FIND_FOC_PART)) { sqlBuffer.append(" SELECT IP.PART_ID, IP.PART_CODE, IP.PART_NAME, "); sqlBuffer.append(" IP.PART_FULL_NAME, IP.COMPLETE_NAME, IP.PART_DESCRIPTION, "); sqlBuffer.append(" IPT.PART_CATEGORY, IP.STD_PURCHASE_UNIT_COST,IP.LEAD_TIME, "); sqlBuffer.append(" IP.UOM_ID,IU.UOM_CODE ,IU.UOM_NAME, "); sqlBuffer.append(" IP.PART_TYPE_ID, IPT.PART_TYPE_CODE,IPT.PART_TYPE_NAME, "); sqlBuffer.append(" IP.LOCATION_ID, PVP.VENDOR_PART_CODE, PVP.VENDOR_PART_NAME "); sqlBuffer.append(" FROM "); sqlBuffer.append(" ITEM_UOM IU, "); sqlBuffer.append(" ITEM_PART_TYPE IPT, "); sqlBuffer.append(" ITEM_PART IP, "); sqlBuffer.append(" (SELECT * FROM PUR_VENDOR_PART WHERE VENDOR_ID = "); sqlBuffer.append(((PoMgr) mvcMgr).getCurrentPurchaseOrder().getVendor().getVendorId()); sqlBuffer.append(" ) PVP "); sqlBuffer.append(" WHERE IP.ORDERABLE_FLAG = 'Y' "); sqlBuffer.append(" AND NVL(IP.TEMPLATE_ITEM_FLAG,'N') = 'N' "); sqlBuffer.append(" AND IPT.PART_TYPE_ID = IP.PART_TYPE_ID "); sqlBuffer.append(" AND IU.UOM_ID = IP.UOM_ID "); if (((PoMgr) mvcMgr).getCurrentPurchaseOrder().getVendor().isMajorSupplier()) sqlBuffer.append(" AND PVP.PART_ID(+) = IP.PART_ID "); else sqlBuffer.append(" AND PVP.PART_ID = IP.PART_ID "); if (ParameterUtil.isItemSeparatedByFactory) { sqlBuffer.append( " AND EXISTS (SELECT 'O' FROM ITEM_PART_FACTORY IPF WHERE IPF.PART_ID = IP.PART_ID AND IPF.FACTORY_ID = " + login.getEmployee().getFactoryId() + " ) "); } this.isRearchCondition(sqlBuffer); if (!this.isHaveOrderBy(sqlBuffer)) { sqlBuffer.append(" ORDER BY 2 "); } } else if (mvcMgr.getFoundMode().equals(Constant.FIND_PO)) { sqlBuffer.append(" SELECT DISTINCT PP.PO_ID, PV.VENDOR_ID, PP.CONTACT_ID, "); sqlBuffer.append(" PP.BILL_TO_SITE_ID, PP.SHIP_TO_SITE_ID, PP.CURRENCY_CODE, "); sqlBuffer.append(" PP.CURRENCY_RATE, PP.ITEM_TOTAL_AMOUNT, PP.DELIVERY_TERM_ID, "); sqlBuffer.append( " TO_CHAR(PP.DELIVERY_DATE,'DD-MM-YYYY') , PP.REMARK, PP.SHIPPING_MARK, "); sqlBuffer.append( " PP.STATUS, TO_CHAR(PP.CREATION_DATE, 'YYYY-MM-DD'), PP.CREATED_BY, "); sqlBuffer.append( " TO_CHAR(PP.MODIFIED_DATE, 'DD-MM-YYYY'), PP.MODIFIED_REASON, PP.MODIFIED_BY, "); sqlBuffer.append(" PV.VENDOR_NAME, PC.CONTACT_PERSON_NAME, PVF.F_ADDRESS, "); sqlBuffer.append(" PVF.F_TEL1, PVF.F_FAX1, PC.E_MAIL, "); sqlBuffer.append(" PP.PO_TYPE, PP.PART_CATEGORY , PP.PO_REF_NO, "); sqlBuffer.append(" PV.VENDOR_CODE ,PP.PO_VAT ,NVL(PP.PO_DISCOUNT,0), "); sqlBuffer.append(" NVL(PP.PO_REVISION,1) , NVL(PV.MAJOR_SUPPLIER_FLAG,'N') "); sqlBuffer.append(" FROM PUR_CONTACT PC, "); sqlBuffer.append(" PUR_VENDOR PV, "); sqlBuffer.append(" PUR_PO PP, "); sqlBuffer.append(" PUR_VENDOR_FACTORY PVF "); sqlBuffer.append(" WHERE PV.VENDOR_ID = PP.VENDOR_ID "); sqlBuffer.append(" AND PC.VENDOR_ID = PP.VENDOR_ID "); sqlBuffer.append(" AND PC.CONTACT_ID(+) = PP.CONTACT_ID "); sqlBuffer.append(" AND PVF.FACTORY_ID(+) = PC.FACTORY_ID "); if (mvcMgr.getEntryMode().equals(Constant.VIEW_STATUS)) { sqlBuffer.append(" AND PP.STATUS IN ('C','D','S','M') "); } else if (mvcMgr.getEntryMode().equals(Constant.APPROVE_QUICK_PO)) { if (login.getEmployee().getUserRightLevel() != null && !login.getEmployee().getUserRightLevel().equals("")) { sqlBuffer.append( " AND NVL(PP.PO_TOTAL_AMOUNT,0) <= (SELECT DECODE(PPAR.DISABLE_FLAG, 'N', NVL(MAX_APPROVAL_AMOUNT, 999999999), 999999999) FROM PUR_PO_APPROVAL_RIGHT PPAR, GM_CURRENCY GC WHERE PPAR.CURRENCY_ID(+) = GC.CURRENCY_ID AND GC.CURRENCY_ID = PP.CURRENCY_ID AND PPAR.USER_RIGHT_LEVEL(+) = " + login.getEmployee().getUserRightLevel() + ") "); } sqlBuffer.append(" AND PP.STATUS IN ('P','V') "); sqlBuffer.append(" AND PP.QUICK_PO_STATUS IN ('Y') "); } else if (mvcMgr.getEntryMode().equals(Constant.REVISE_QUICK_PO)) { sqlBuffer.append(" AND PP.STATUS IN ('C','R') "); sqlBuffer.append(" AND PP.QUICK_PO_STATUS IN ('Y') "); } else if (mvcMgr.getEntryMode().equals(Constant.REVISE_QUICK_PO_INFO)) { sqlBuffer.append(" AND PP.STATUS NOT IN ('D') "); sqlBuffer.append(" AND PP.QUICK_PO_STATUS IN ('Y') "); } else if (mvcMgr.getEntryMode().equals(Constant.SEND_OUT_QUICK_PO)) { sqlBuffer.append(" AND PP.STATUS IN ('A') "); sqlBuffer.append(" AND PP.QUICK_PO_STATUS IN ('Y') "); } else if (mvcMgr.getEntryMode().equals(Constant.DELETE_QUICK_PO)) { sqlBuffer.append(" AND PP.STATUS IN ('C','R') "); sqlBuffer.append(" AND PP.QUICK_PO_STATUS IN ('Y') "); } else if (mvcMgr.getEntryMode().equals(Constant.CLOSE_QUICK_PO)) { sqlBuffer.append(" AND PP.STATUS IN ('S') "); sqlBuffer.append(" AND PP.QUICK_PO_STATUS IN ('Y') "); } else if (mvcMgr.getEntryMode().equals(Constant.MODIFY_QUICK_PO)) { sqlBuffer.append(" AND PP.STATUS IN ('S') "); sqlBuffer.append(" AND PP.QUICK_PO_STATUS IN ('Y') "); } else { sqlBuffer.append(" AND PP.STATUS = 'C' "); } this.isRearchCondition(sqlBuffer); if (!this.isHaveOrderBy(sqlBuffer)) { sqlBuffer.append(" ORDER BY PO_ID DESC "); } } else if (mvcMgr.getFoundMode().equals(Constant.FIND_PO_COPY)) { sqlBuffer.append(" SELECT DISTINCT PP.PO_ID, PV.VENDOR_ID, PP.CONTACT_ID, "); sqlBuffer.append(" PP.BILL_TO_SITE_ID, PP.SHIP_TO_SITE_ID, PP.CURRENCY_CODE, "); sqlBuffer.append(" PP.CURRENCY_RATE, PP.ITEM_TOTAL_AMOUNT, PP.DELIVERY_TERM_ID, "); sqlBuffer.append( " TO_CHAR(PP.DELIVERY_DATE,'DD-MM-YYYY') , PP.REMARK, PP.SHIPPING_MARK, "); sqlBuffer.append( " PP.STATUS, TO_CHAR(PP.CREATION_DATE, 'YYYY-MM-DD'), PP.CREATED_BY, "); sqlBuffer.append( " TO_CHAR(PP.MODIFIED_DATE, 'DD-MM-YYYY'), PP.MODIFIED_REASON, PP.MODIFIED_BY, "); sqlBuffer.append(" PV.VENDOR_NAME, PC.CONTACT_PERSON_NAME, PVF.F_ADDRESS, "); sqlBuffer.append(" PVF.F_TEL1, PVF.F_FAX1, PC.E_MAIL, "); sqlBuffer.append(" PP.PO_TYPE, PP.PART_CATEGORY , PP.PO_REF_NO, "); sqlBuffer.append(" PV.VENDOR_CODE ,PP.PO_VAT ,NVL(PP.PO_DISCOUNT,0), "); sqlBuffer.append(" NVL(PP.PO_REVISION,1),NVL(PV.MAJOR_SUPPLIER_FLAG,'N') "); sqlBuffer.append(" FROM PUR_CONTACT PC, "); sqlBuffer.append(" PUR_VENDOR PV, "); sqlBuffer.append(" PUR_PO PP, "); sqlBuffer.append(" PUR_VENDOR_FACTORY PVF "); sqlBuffer.append(" WHERE PV.VENDOR_ID = PP.VENDOR_ID "); sqlBuffer.append( " AND PV.VENDOR_ID = " + ((PoMgr) mvcMgr).getCurrentPurchaseOrder().getVendor().getVendorId()); sqlBuffer.append(" AND PC.VENDOR_ID = PP.VENDOR_ID "); sqlBuffer.append(" AND PC.CONTACT_ID(+) = PP.CONTACT_ID "); sqlBuffer.append(" AND PVF.FACTORY_ID(+) = PC.FACTORY_ID "); this.isRearchCondition(sqlBuffer); if (!this.isHaveOrderBy(sqlBuffer)) { sqlBuffer.append(" ORDER BY PO_ID DESC "); } } DeBug.print(sqlBuffer.toString()); return sqlBuffer.toString(); }