Commit 3ecac402 authored by arawankar's avatar arawankar

UPDATE cancellation component of payrvouch and emp_det_chg

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@184629 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 974dc58a
package ibase.webitm.ejb.adm.adv;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import javax.ejb.Stateless;
import javax.naming.InitialContext;
import ibase.system.config.AppConnectParm;
import ibase.utility.E12GenericUtility;
import ibase.webitm.ejb.ActionHandlerEJB;
import ibase.webitm.ejb.ITMDBAccessLocal;
import ibase.webitm.utility.ITMException;
@Stateless
public class EmpDetChgCanc extends ActionHandlerEJB implements EmpDetChgCancLocal,EmpDetChgCancRemote
{
public String confirm(String tranId, String xtraParams, String forcedFlag) throws RemoteException,ITMException
{
System.out.println("==========Inside Confirm Method[EmpDetChgCanc]================");
System.out.println("Parameter--tranId--["+tranId+"]--xtraParams--["+xtraParams+"]--forcedFlag--["+forcedFlag+"]");
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet resultSet = null;
String sql = "";
String confirmed = "";
String status = "";
String retString = "";
int updCount = 0;
AppConnectParm appConnect = null;
InitialContext initialCtx = null;
ITMDBAccessLocal itmDBAccess = null;
E12GenericUtility genericUtility = null;
String loginCode = "";
try
{
conn = getConnection();
appConnect = new AppConnectParm();
initialCtx = new InitialContext(appConnect.getProperty());
itmDBAccess = (ITMDBAccessLocal)initialCtx.lookup("ibase/ITMDBAccessEJB/local");
genericUtility = new E12GenericUtility();
loginCode = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginCode");
System.out.println("loinCode---["+loginCode+"]");
//Check whether the transaction is confirmed or not
sql = "select confirmed ,status from employee_det_change where tran_id = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId);
resultSet = pstmt.executeQuery();
if(resultSet.next())
{
confirmed = resultSet.getString("confirmed");
status = resultSet.getString("status");
}
System.out.println("Transaction Confirmed--["+tranId+"]["+confirmed+"]["+status+"]");
if(resultSet != null)
{
resultSet.close();
resultSet = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if("X".equalsIgnoreCase(status))
{
retString = itmDBAccess.getErrorString( "", "VTCAN" , loginCode);
return retString;
}
//If transaction in confirmed then unable to cancel the transaction else update the status as "X" in employee_det_change table.
if("Y".equalsIgnoreCase(confirmed))
{
retString = itmDBAccess.getErrorString( "", "VTCANC8" , loginCode);
return retString;
}
else if("N".equalsIgnoreCase(confirmed) || confirmed == null)
{
sql = "";
sql = "update employee_det_change set status = 'X' where tran_id = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId);
updCount = pstmt.executeUpdate();
System.out.println("["+updCount+"]of records updated agains tran_id ["+tranId+"]");
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
else
{
retString = itmDBAccess.getErrorString( "", "VTCANC2" , loginCode);
return retString;
}
if(retString == null || retString.trim().length() == 0)
{
conn.commit();
System.out.println("Connection commit................");
retString = itmDBAccess.getErrorString( "", "VTCANC1" , loginCode);
}
}
catch(Exception e)
{
//Modified by Ahmed on 26-APR-2018 to rollback transaction if exception occurs[start]
try
{
if (conn!=null)
{
conn.rollback();
}
}
catch(Exception ex)
{
ex.printStackTrace();
}
e.printStackTrace();
//Modified by Ahmed on 26-APR-2018 to rollback transaction if exception occurs[end]
System.out.println("Exception from [EmpDetChgCanc][confirm]["+e.getMessage()+"]");
}
finally
{
try
{
if(resultSet != null)
{
resultSet.close();
resultSet = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
//Modified by Ahmed on 26-APR-2018 to close connection[start]
if (conn!=null)
{
conn.close();
conn = null;
}
//Modified by Ahmed on 26-APR-2018 to close connection[end]
}
catch(Exception e)
{
System.out.println("Exception in connection closing [EmpDetChgCanc][confirm]["+e.getMessage()+"]");
e.printStackTrace();//Modified by Ahmed on 26-APR-2018 to print stack trace if exception occurs
}
}
System.out.println("retString from EmpDetChgCanc---------["+retString+"]");
return retString;
}
}
package ibase.webitm.ejb.adm.adv;
import java.rmi.RemoteException;
import javax.ejb.Local;
import ibase.webitm.ejb.ActionHandlerLocal;
import ibase.webitm.utility.ITMException;
@Local
public interface EmpDetChgCancLocal extends ActionHandlerLocal
{
public String confirm(String tranId, String xtraParams, String forcedFlag) throws RemoteException,ITMException;
}
package ibase.webitm.ejb.adm.adv;
import java.rmi.RemoteException;
import javax.ejb.Remote;
import ibase.webitm.ejb.ActionHandlerRemote;
import ibase.webitm.utility.ITMException;
@Remote
public interface EmpDetChgCancRemote extends ActionHandlerRemote
{
public String confirm(String tranId, String xtraParams, String forcedFlag) throws RemoteException,ITMException;
}
package ibase.webitm.ejb.adm.adv;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import javax.ejb.Stateless;
import javax.naming.InitialContext;
import ibase.system.config.AppConnectParm;
import ibase.utility.E12GenericUtility;
import ibase.webitm.ejb.ActionHandlerEJB;
import ibase.webitm.ejb.ITMDBAccessLocal;
import ibase.webitm.utility.ITMException;
@Stateless
public class PayrVouchCanc extends ActionHandlerEJB implements PayrVouchCancRemote,PayrVouchCancLocal
{
public String confirm(String tranId, String xtraParams, String forcedFlag) throws RemoteException,ITMException
{
System.out.println("==========Inside Confirm Method[PayrVouchCanc]================");
System.out.println("Parameter--tranId--["+tranId+"]--xtraParams--["+xtraParams+"]--forcedFlag--["+forcedFlag+"]");
Connection conn = null;
String retString = null;
E12GenericUtility genericUtility = null;
AppConnectParm appConnect = null;
InitialContext initialCtx = null;
ITMDBAccessLocal itmDBAccess = null;
String loginCode = "";
try
{
conn = getConnection();
genericUtility = new E12GenericUtility();
appConnect = new AppConnectParm();
initialCtx = new InitialContext(appConnect.getProperty());
itmDBAccess = (ITMDBAccessLocal)initialCtx.lookup("ibase/ITMDBAccessEJB/local");
loginCode = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginCode");
System.out.println("loinCode---["+loginCode+"]");
retString = confirm(tranId, xtraParams, forcedFlag, conn);
System.out.println("retString---["+retString+"]");
if(retString == null || retString.trim().length() == 0)
{
conn.commit();
System.out.println("Connection commit................");
retString = itmDBAccess.getErrorString( "", "VTCANC1" , loginCode);
}
else
{
System.out.println("Connection rollback................");
conn.rollback();
}
}
catch( Exception e)
{
//Modified by Ahmed on 26-APR-2018 to rollback transaction if exception occurs[start]
try
{
if (conn!=null)
{
conn.rollback();
}
}
catch(Exception ex)
{
ex.printStackTrace();
}
e.printStackTrace();
//Modified by Ahmed on 26-APR-2018 to rollback transaction if exception occurs[end]
System.out.println("Exception from [PayrVouchCanc][confirm]["+e.getMessage()+"]");
}
//Modified by Ahmed on 26-APR-2018 to close connection[start]
finally
{
try
{
if (conn!=null)
{
conn.close();
conn = null;
}
}
catch(Exception e)
{
System.out.println("Exception in connection closing [PayrVouchCanc][confirm]["+e.getMessage()+"]");
e.printStackTrace();
}
}
//Modified by Ahmed on 26-APR-2018 to close connection[end]
return forcedFlag;
}
public String confirm(String tranId, String xtraParams, String forcedFlag, Connection conn) throws RemoteException,ITMException
{
PreparedStatement pstmt = null;
ResultSet resultSet = null;
String sql = "";
String confirmed = "";
String loginCode = "";
String retString = "";
int updCount = 0;
String status = "";
E12GenericUtility genericUtility = null;
AppConnectParm appConnect = null;
InitialContext initialCtx = null;
ITMDBAccessLocal itmDBAccess = null;
try
{
genericUtility = new E12GenericUtility();
appConnect = new AppConnectParm();
initialCtx = new InitialContext(appConnect.getProperty());
itmDBAccess = (ITMDBAccessLocal)initialCtx.lookup("ibase/ITMDBAccessEJB/local");
loginCode = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginCode");
System.out.println("loinCode---["+loginCode+"]");
//Check whether the transaction is confirmed or not
sql = "select confirmed ,status from payr_voucher where tran_id = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId);
resultSet = pstmt.executeQuery();
if(resultSet.next())
{
confirmed = resultSet.getString("confirmed");
status = resultSet.getString("status");
}
System.out.println("Transaction Confirmed--["+tranId+"]["+confirmed+"]["+status+"]");
if(resultSet != null)
{
resultSet.close();
resultSet = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if("X".equalsIgnoreCase(status))
{
retString = itmDBAccess.getErrorString( "", "VTCAN" , loginCode);
return retString;
}
if("Y".equalsIgnoreCase(confirmed))
{
retString = itmDBAccess.getErrorString( "", "VTCANC8" , loginCode);
return retString;
}
else if("N".equalsIgnoreCase(confirmed) || confirmed == null)
{
sql = "";
sql = "delete from payr_vouchadv where tran_id = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId);
updCount = pstmt.executeUpdate();
System.out.println("["+updCount+"]Rows deleted in payr_vouchadv");
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
sql = "";
sql = "delete from payr_vouchdet where tran_id = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId);
updCount = pstmt.executeUpdate();
System.out.println("["+updCount+"]Rows deleted in payr_vouchdet");
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
sql = "";
sql = "update payr_voucher set status = 'X' where tran_id = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId);
updCount = pstmt.executeUpdate();
System.out.println("["+updCount+"]Rows Update in payr_vouchdet");
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
else
{
retString = itmDBAccess.getErrorString( "", "VTCANC2" , loginCode);
return retString;
}
}
catch( Exception e )
{
System.out.println("Exception from [PayrVouchCanc][confirm]["+e.getMessage()+"]");
e.printStackTrace();//Modified by Ahmed on 26-APR-2018 to print stack trace if exception occurs
}
finally
{
try
{
if(resultSet != null)
{
resultSet.close();
resultSet = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
catch( Exception e )
{
System.out.println("Exception in connection closing [PayrVouchCanc][confirm]["+e.getMessage()+"]");
e.printStackTrace();//Modified by Ahmed on 26-APR-2018 to print stack trace if exception occurs
}
}
return retString;
}
}
package ibase.webitm.ejb.adm.adv;
import java.rmi.RemoteException;
import java.sql.Connection;
import javax.ejb.Local;
import ibase.webitm.ejb.ActionHandlerLocal;
import ibase.webitm.utility.ITMException;
@Local
public interface PayrVouchCancLocal extends ActionHandlerLocal
{
public String confirm(String tranId, String xtraParams, String forcedFlag) throws RemoteException,ITMException;
public String confirm(String tranId, String xtraParams, String forcedFlag, Connection conn) throws RemoteException,ITMException;
}
package ibase.webitm.ejb.adm.adv;
import java.rmi.RemoteException;
import java.sql.Connection;
import javax.ejb.Remote;
import ibase.webitm.ejb.ActionHandlerRemote;
import ibase.webitm.utility.ITMException;
@Remote
public interface PayrVouchCancRemote extends ActionHandlerRemote
{
public String confirm(String tranId, String xtraParams, String forcedFlag) throws RemoteException,ITMException;
public String confirm(String tranId, String xtraParams, String forcedFlag, Connection conn) throws RemoteException,ITMException;
}
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