public boolean isValidParty(PartyLovVO partyLovVO) throws Exception { boolean validParty = false; Connection connection = null; StringBuilder finalQry = new StringBuilder(); PreparedStatement pstmt = null; ResultSet rs = null; QueryFields fields = null; String whereCond = ""; try { fields = new QueryFields(); fields.put("BP.DCS_STATUS", "1"); fields.put("PR.DCS_CODE", partyLovVO.getPartyRole()); fields.put("BP.DCS_CODE", partyLovVO.getPartyId()); if (!StringUtility.isNullEmpty(partyLovVO.getRelatedParty())) { fields.put("BP.DCS_CODE", partyLovVO.getRelatedParty()); fields.put("PR.DCS_CODE", partyLovVO.getRelationShipType()); } whereCond = " AND " + QueryBuilderUtil.buildWhereCond(fields); finalQry.append(PartyLovQueries.validatePartyIdQry).append(whereCond); connection = getConnection(); pstmt = connection.prepareStatement(finalQry.toString()); rs = pstmt.executeQuery(); if (rs.next()) { if (rs.getInt(1) > 0) { validParty = true; } else { validParty = false; } } } finally { ConnectionUtil.closeConnection(connection, pstmt, rs); } return validParty; }
public String isValidNickName(PartyLovVO partyLovVO) { Statement st = null; Connection connection = null; ResultSet rs = null; String ret = "Invalid"; String partyRole = partyLovVO.getPartyRole(); String visiblePartyId = partyLovVO.getPartyNickName(); String hiddenPartyId = partyLovVO.getPartyId(); try { boolean partyMatch = visiblePartyId.equalsIgnoreCase(getNickNameInNickNameMode(hiddenPartyId)); if (!partyMatch) { hiddenPartyId = ""; partyLovVO.setPartyId(""); } if (!isValidParty(partyLovVO) || StringUtility.isNullEmpty(hiddenPartyId)) { boolean temp = false; if (!StringUtility.isNullEmpty(hiddenPartyId) && partyMatch) { temp = isValidParty(partyLovVO); if (!temp && ("*PU_LOCN".equals(partyRole) || "*DEL_LOCN".equals(partyRole))) { if ("*PU_LOCN".equals(partyRole)) { partyLovVO.setPartyRole("*SHIPPER"); } else { partyLovVO.setPartyRole("*CONSIGNEE"); } temp = isValidParty(partyLovVO); } } if (!temp) { connection = getConnection(); st = connection.createStatement( ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); rs = st.executeQuery( "SELECT DCS_CODE FROM ET_BUSINESS_PARTY WHERE DCS_NICK_NAME='" + visiblePartyId + "' AND DCS_PARTY_TYPE LIKE '%" + partyRole + "%'"); int count = 0; if (rs.next()) { rs.last(); count = rs.getRow(); rs.beforeFirst(); } if (count == 0) { ret = "InValidNickName"; } else if (count == 1) { if (rs.first()) { partyLovVO.setPartyId(rs.getString("DCS_CODE")); temp = isValidParty(partyLovVO); if (!temp && ("*PU_LOCN".equals(partyRole) || "*DEL_LOCN".equals(partyRole))) { if ("*PU_LOCN".equals(partyRole)) { partyLovVO.setPartyRole("*SHIPPER"); } else { partyLovVO.setPartyRole("*CONSIGNEE"); } temp = isValidParty(partyLovVO); } if (temp) { ret = partyLovVO.getPartyId(); } } else { } } else { ret = "Duplicate"; } } else { ret = hiddenPartyId; } } else { ret = hiddenPartyId; } } catch (Exception e) { e.printStackTrace(); } finally { ConnectionUtil.closeConnection(connection, st, rs); } return ret; }
public String loadConsigneeOnBlurAjaxData( PartyLovVO lovAttributes, ESupplyGlobalParameters loginBean, String xmlString) throws Exception { StringBuilder finalQry = new StringBuilder(); PreparedStatement pstmt = null; ResultSet rs = null; String invoiceBranch = null; Connection connection = null; String whereCond = ""; String invoiceDept = null; String collectParty = null; String stParty = null; String collectCon = null; String stCon = null; String collectType = null; String onBlurSeq = null; String[] onBlurSeqAry = null; try { QueryFields fields = new QueryFields(); finalQry.append(PartyLovQueries.loadConsigneeOnBlurAjaxQry); fields.put("BP.DCS_STATUS", "1"); fields.put("PR.DCS_CODE", lovAttributes.getPartyRole()); fields.put("BP.DCS_CODE", lovAttributes.getPartyId()); whereCond = " AND " + QueryBuilderUtil.buildWhereCond(fields); finalQry.append(whereCond); connection = getConnection(); pstmt = connection.prepareStatement(finalQry.toString()); rs = pstmt.executeQuery(); if (rs.next()) { onBlurSeq = lovAttributes.getOnBlurSeq(); invoiceBranch = StringUtility.noNull(rs.getString("INVOICE_BRANCH")); invoiceDept = StringUtility.noNull(rs.getString("INVOICE_DEPT")); collectParty = StringUtility.noNull(rs.getString("COLLECT_PARTY")); stParty = StringUtility.noNull(rs.getString("ST_PARTY")); collectCon = StringUtility.noNull(rs.getString("COLLECT_CON")); stCon = StringUtility.noNull(rs.getString("ST_CON")); if (!StringUtility.isNullEmpty(onBlurSeq)) { onBlurSeqAry = onBlurSeq.split(","); } if (onBlurSeqAry != null && onBlurSeqAry.length > 0) { for (String onBlurFinalSeq : onBlurSeqAry) { if ("1".equals(onBlurFinalSeq) || "0".equals(onBlurFinalSeq)) { xmlString += "<invoicebranch>" + invoiceBranch + "</invoicebranch>"; xmlString += "<invoicedept>" + invoiceDept + "</invoicedept>"; } if ("2".equals(onBlurFinalSeq) || "0".equals(onBlurFinalSeq)) { if (!"0".equals(collectCon) && !"1".equals(collectCon)) { collectType = "1".equals(stCon) ? "Export" : ("2".equals(stCon) ? "Import" : "Both"); } else if (collectParty != "0" && "1" != collectParty) { collectType = "1".equals(stParty) ? "Export" : ("2".equals(stParty) ? "Import" : "Both"); } xmlString += "<collectshipment>" + collectType + "</collectshipment>"; } } } } } finally { ConnectionUtil.closeConnection(connection, pstmt, rs); } return xmlString; }
public String loadCustomerOnBlurAjaxData( PartyLovVO lovAttributes, ESupplyGlobalParameters loginBean, String xmlString) throws Exception { StringBuilder finalQry = new StringBuilder(); PreparedStatement pstmt = null; ResultSet rs = null; String invoiceBranch = null; String partyId = ""; Connection connection = null; String whereCond = ""; String invoiceDept = null; String tradeTerms = "NoTradeTerm"; boolean ro = false; String creditLimit = null; String collectParty = null; String stParty = null; String collectCon = null; String stCon = null; String csr = null; String salesPersonId = null; String salesPersonIdNickName = null; String collectType = null; String onBlurSeq = null; String[] onBlurSeqAry = null; try { QueryFields fields = new QueryFields(); finalQry.append(PartyLovQueries.loadCustomerOnBlurAjaxQry); fields.put("BP.DCS_STATUS", "1"); fields.put("PR.DCS_CODE", lovAttributes.getPartyRole()); fields.put("BP.DCS_CODE", lovAttributes.getPartyId()); whereCond = " AND " + QueryBuilderUtil.buildWhereCond(fields); finalQry.append(whereCond); connection = getConnection(); pstmt = connection.prepareStatement(finalQry.toString()); rs = pstmt.executeQuery(); if (rs.next()) { onBlurSeq = lovAttributes.getOnBlurSeq(); partyId = StringUtility.noNull(rs.getString("DCS_CODE")); invoiceBranch = StringUtility.noNull(rs.getString("INVOICE_BRANCH")); invoiceDept = StringUtility.noNull(rs.getString("INVOICE_DEPT")); tradeTerms = StringUtility.noNull(rs.getString("TRADE_TERMS")); creditLimit = StringUtility.noNull(rs.getString("CREDIT_LIMIT")); collectParty = StringUtility.noNull(rs.getString("COLLECT_PARTY")); stParty = StringUtility.noNull(rs.getString("ST_PARTY")); collectCon = StringUtility.noNull(rs.getString("COLLECT_CON")); stCon = StringUtility.noNull(rs.getString("ST_CON")); csr = StringUtility.noNull(rs.getString("CSR")); salesPersonId = StringUtility.noNull(rs.getString("SALESPERSONID")); salesPersonIdNickName = StringUtility.noNull(rs.getString("SALESPERSONIDNICKNAME")); if (!StringUtility.isNullEmpty(onBlurSeq)) { onBlurSeqAry = onBlurSeq.split(","); } if (onBlurSeqAry != null && onBlurSeqAry.length > 0) { for (String onBlurFinalSeq : onBlurSeqAry) { if ("1".equals(onBlurFinalSeq) || "0".equals(onBlurFinalSeq)) { xmlString += "<invoicebranch>" + invoiceBranch + "</invoicebranch>"; xmlString += "<invoicedept>" + invoiceDept + "</invoicedept>"; } if ("2".equals(onBlurFinalSeq) || "0".equals(onBlurFinalSeq)) { ro = StringUtility.noNull(rs.getString("RO")).equals("1") ? true : false; xmlString += "<tradeterm>" + tradeTerms + "</tradeterm>"; xmlString += "<ro>" + ro + "</ro>"; } if ("3".equals(onBlurFinalSeq) || "0".equals(onBlurFinalSeq)) { if (!"0".equals(collectCon) && !"1".equals(collectCon)) { collectType = "1".equals(stCon) ? "Export" : ("2".equals(stCon) ? "Import" : "Both"); } else if (collectParty != "0" && "1" != collectParty) { collectType = "1".equals(stParty) ? "Export" : ("2".equals(stParty) ? "Import" : "Both"); } xmlString += "<collectshipment>" + collectType + "</collectshipment>"; } if ("4".equals(onBlurFinalSeq) || "0".equals(onBlurFinalSeq)) { xmlString += "<creditlimit>" + creditLimit + "</creditlimit>"; } if ("5".equals(onBlurFinalSeq) || "0".equals(onBlurFinalSeq)) { String[] csrTeam = csr.split(","); String csrXmlString = ""; if (!StringUtility.isNullEmpty(csrTeam)) { if ("csrAETeam".equals(lovAttributes.getCsrType()) && csrTeam.length > 0) { csrXmlString = csrTeam[0]; } else if ("csrAITeam".equals(lovAttributes.getCsrType()) && csrTeam.length > 1) { csrXmlString = csrTeam[1]; } else if ("csrOETeam".equals(lovAttributes.getCsrType()) && csrTeam.length > 2) { csrXmlString = csrTeam[2]; } else if ("csrOITeam".equals(lovAttributes.getCsrType()) && csrTeam.length > 3) { csrXmlString = csrTeam[3]; } else { if (csrTeam.length > 4) { csrXmlString = csrTeam[4]; } } } xmlString += "<csr>" + csrXmlString + "</csr>"; } if ("6".equals(onBlurFinalSeq) || "0".equals(onBlurFinalSeq)) { String[] salesPerson = getDefaultSalespersonForCustomer(partyId, loginBean.getTerminalId()); salesPersonId = !StringUtility.isNullEmpty(salesPerson) ? salesPerson[0] : ""; salesPersonIdNickName = !StringUtility.isNullEmpty(salesPerson) ? salesPerson[1] : ""; xmlString += "<salespersonid>" + salesPersonId + "</salespersonid>"; xmlString += "<salespersonidnickname>" + salesPersonIdNickName + "</salespersonidnickname>"; } } } } } finally { ConnectionUtil.closeConnection(connection, pstmt, rs); } return xmlString; }