Commit 56329a9c authored by mmhatre's avatar mmhatre

added common validation for cctr code

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@213633 ce508802-f39f-4f6c-b175-0d175dae99d5
parent b43efd48
...@@ -2691,7 +2691,7 @@ public class FinCommon { ...@@ -2691,7 +2691,7 @@ public class FinCommon {
Statement stmt = null; Statement stmt = null;
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null; ResultSet rs = null;
String active=""; //added by manish mhatre on 16-dec-2019
String cctrCheck = null; String cctrCheck = null;
try { try {
...@@ -2708,8 +2708,9 @@ public class FinCommon { ...@@ -2708,8 +2708,9 @@ public class FinCommon {
rs.close(); rs.close();
rs = null; rs = null;
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
if ("Y".equalsIgnoreCase(cctrCheck.trim()) && cctrCode != null && cctrCode.trim().length() > 0) { if ("Y".equalsIgnoreCase(cctrCheck.trim()) && cctrCode != null && cctrCode.trim().length() > 0)
{
sql = "SELECT COUNT(1) AS COUNTER FROM COSTCTR WHERE CCTR_CODE = ? "; sql = "SELECT COUNT(1) AS COUNTER FROM COSTCTR WHERE CCTR_CODE = ? ";
// stmt = con.createStatement(); // stmt = con.createStatement();
// rs = stmt.executeQuery(sql); // rs = stmt.executeQuery(sql);
...@@ -2723,31 +2724,36 @@ public class FinCommon { ...@@ -2723,31 +2724,36 @@ public class FinCommon {
rs = null; rs = null;
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
if (cnt == 0) { if (cnt == 0)
{
errCode = "VMCCTR1"; errCode = "VMCCTR1";
} else { } else
// chandni {
sql = "SELECT COUNT(1) FROM ACCOUNTS_CCTR WHERE ACCT_CODE = ? AND CCTR_CODE = ? "; //added by manish mhatre on 13-dec-2019
// stmt = con.createStatement(); sql="SELECT ACTIVE FROM COSTCTR WHERE CCTR_CODE= ?";
// rs = stmt.executeQuery(sql); pstmt=con.prepareStatement(sql);
pstmt = con.prepareStatement(sql); pstmt.setString(1, cctrCode);
pstmt.setString(1, acctCode); rs=pstmt.executeQuery();
pstmt.setString(2, cctrCode); if(rs.next())
rs = pstmt.executeQuery(); {
if (rs.next()) { active=rs.getString("ACTIVE");
cnt = rs.getInt(1);
} }
rs.close(); rs.close();
rs = null; rs=null;
pstmt.close(); pstmt.close();
pstmt = null; pstmt=null;
if (cnt == 0) { if("N".equalsIgnoreCase(active))
{
errCode = "VTCCTR2"; //end manish
}else
{
// chandni // chandni
sql = "SELECT COUNT(1) from ACCOUNTS_CCTR WHERE ACCT_CODE = ?"; sql = "SELECT COUNT(1) FROM ACCOUNTS_CCTR WHERE ACCT_CODE = ? AND CCTR_CODE = ? ";
// stmt = con.createStatement(); // stmt = con.createStatement();
// rs = stmt.executeQuery(sql); // rs = stmt.executeQuery(sql);
pstmt = con.prepareStatement(sql); pstmt = con.prepareStatement(sql);
pstmt.setString(1, acctCode); pstmt.setString(1, acctCode);
pstmt.setString(2, cctrCode);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if (rs.next()) { if (rs.next()) {
cnt = rs.getInt(1); cnt = rs.getInt(1);
...@@ -2756,15 +2762,35 @@ public class FinCommon { ...@@ -2756,15 +2762,35 @@ public class FinCommon {
rs = null; rs = null;
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
if (cnt > 0) { if (cnt == 0) {
errCode = "VMCCTR2"; // chandni
} else if (cnt == 0 && cctrCode != null && cctrCode.trim().length() > 0) { sql = "SELECT COUNT(1) from ACCOUNTS_CCTR WHERE ACCT_CODE = ?";
errCode = "VMCCTR2"; // stmt = con.createStatement();
// rs = stmt.executeQuery(sql);
pstmt = con.prepareStatement(sql);
pstmt.setString(1, acctCode);
rs = pstmt.executeQuery();
if (rs.next()) {
cnt = rs.getInt(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if (cnt > 0) {
errCode = "VMCCTR2";
} else if (cnt == 0 && cctrCode != null && cctrCode.trim().length() > 0) {
errCode = "VMCCTR2";
}
} }
} }
} }
} }
} catch (SQLException se) { } catch (SQLException se) {
System.out.println("SQLException :ITMDBAccessEJB :isCctrCode:" + se.getMessage() + ":"); System.out.println("SQLException :ITMDBAccessEJB :isCctrCode:" + se.getMessage() + ":");
se.printStackTrace(); se.printStackTrace();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment