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 {
Statement stmt = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
String active=""; //added by manish mhatre on 16-dec-2019
String cctrCheck = null;
try {
......@@ -2708,8 +2708,9 @@ public class FinCommon {
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if ("Y".equalsIgnoreCase(cctrCheck.trim()) && cctrCode != null && cctrCode.trim().length() > 0) {
pstmt = null;
if ("Y".equalsIgnoreCase(cctrCheck.trim()) && cctrCode != null && cctrCode.trim().length() > 0)
{
sql = "SELECT COUNT(1) AS COUNTER FROM COSTCTR WHERE CCTR_CODE = ? ";
// stmt = con.createStatement();
// rs = stmt.executeQuery(sql);
......@@ -2723,31 +2724,36 @@ public class FinCommon {
rs = null;
pstmt.close();
pstmt = null;
if (cnt == 0) {
if (cnt == 0)
{
errCode = "VMCCTR1";
} else {
// chandni
sql = "SELECT COUNT(1) FROM ACCOUNTS_CCTR WHERE ACCT_CODE = ? AND CCTR_CODE = ? ";
// stmt = con.createStatement();
// rs = stmt.executeQuery(sql);
pstmt = con.prepareStatement(sql);
pstmt.setString(1, acctCode);
pstmt.setString(2, cctrCode);
rs = pstmt.executeQuery();
if (rs.next()) {
cnt = rs.getInt(1);
} else
{
//added by manish mhatre on 13-dec-2019
sql="SELECT ACTIVE FROM COSTCTR WHERE CCTR_CODE= ?";
pstmt=con.prepareStatement(sql);
pstmt.setString(1, cctrCode);
rs=pstmt.executeQuery();
if(rs.next())
{
active=rs.getString("ACTIVE");
}
rs.close();
rs = null;
rs=null;
pstmt.close();
pstmt = null;
if (cnt == 0) {
pstmt=null;
if("N".equalsIgnoreCase(active))
{
errCode = "VTCCTR2"; //end manish
}else
{
// 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();
// rs = stmt.executeQuery(sql);
pstmt = con.prepareStatement(sql);
pstmt.setString(1, acctCode);
pstmt.setString(2, cctrCode);
rs = pstmt.executeQuery();
if (rs.next()) {
cnt = rs.getInt(1);
......@@ -2756,15 +2762,35 @@ public class FinCommon {
rs = null;
pstmt.close();
pstmt = null;
if (cnt > 0) {
errCode = "VMCCTR2";
} else if (cnt == 0 && cctrCode != null && cctrCode.trim().length() > 0) {
errCode = "VMCCTR2";
if (cnt == 0) {
// chandni
sql = "SELECT COUNT(1) from ACCOUNTS_CCTR WHERE ACCT_CODE = ?";
// 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) {
System.out.println("SQLException :ITMDBAccessEJB :isCctrCode:" + se.getMessage() + ":");
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