Commit 0b3af05c authored by sgadve's avatar sgadve

For the Employee overtime and cancel logic

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@215488 ce508802-f39f-4f6c-b175-0d175dae99d5
parent c47e963c
This diff is collapsed.
package ibase.webitm.ejb.adm.adv;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import ibase.utility.BaseLogger;
import ibase.utility.E12GenericUtility;
import ibase.webitm.ejb.ActionHandlerEJB;
import ibase.webitm.ejb.ITMDBAccessEJB;
import ibase.webitm.utility.ITMException;
public class EmpOvertimeCancel extends ActionHandlerEJB
{
ITMDBAccessEJB itmdbAccessEJB = new ITMDBAccessEJB();
E12GenericUtility genericUtility = new E12GenericUtility();
public String cancel(String tranId ,String xtraParams , String forcedFlag)
{
System.out.println("Inside the cancel logic"+tranId);
Connection conn = null;
String errCode = "";
try
{
conn = getConnection();
errCode = gbf_post_logic(tranId, tranId, xtraParams,conn);
}
catch (Exception e)
{
e.printStackTrace();
}
finally
{
try
{
if(conn != null)
{
conn.close();
conn = null;
}
}
catch(Exception e)
{
BaseLogger.log("0", null, "", "Exception"+e);
}
}
return errCode;
}
public String gbf_post_logic(String as_tranid_fr, String as_tranid_to, String as_extra_arg,Connection con) throws ITMException,RemoteException
{
String ls_errcode = "" , ls_tranid = "",userId = "";
userId = genericUtility.getValueFromXTRA_PARAMS(as_extra_arg, "loginCode");
try
{
if(as_tranid_fr.equalsIgnoreCase(as_tranid_to))
{
ls_tranid = as_tranid_fr;
ls_errcode = gbf_cancel_overtime(ls_tranid , 2, as_extra_arg, con) ;
}
if(ls_errcode.trim().length() > 0)
{
return ls_errcode;
}
else
{
ls_errcode = "VTMCAN";
return ls_errcode;
}
}
catch (Exception e)
{
BaseLogger.log("0",null,"","EmpOvertimeCancel.gbf_post_logic()"+e);
}
ls_errcode = itmdbAccessEJB.getErrorString("", "VTMCAN", userId, "", con);
return ls_errcode;
}
public String gbf_cancel_overtime(String as_tranid, int ai_commit,String xtraParams,Connection con)throws ITMException,RemoteException
{
String ls_tran_id,ls_status="",ls_errcode = "",sql="",userId="";
PreparedStatement pStmt = null;
ResultSet rs = null;
userId = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginCode");
try
{
try
{
sql ="select status from empotime where tran_id = ?";
pStmt = con.prepareStatement(sql);
pStmt.setString(1, as_tranid);
rs = pStmt.executeQuery();
while(rs.next())
{
ls_status = rs.getString("status");
}
System.out.println("ls_status"+ls_status);
}
catch(Exception e)
{
return ls_errcode;
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pStmt != null)
{
pStmt.close();
pStmt = null;
}
if("A".equalsIgnoreCase(ls_status))
{
ls_errcode ="VTMCONF1";
}
else if("X".equalsIgnoreCase(ls_status))
{
ls_errcode = "VTOTCANC02";
}
else if("P".equalsIgnoreCase(ls_status))
{
ls_errcode = "VTMPROC";
}
else if("A".equalsIgnoreCase(ls_status))
{
ls_errcode = "VTAPPR05";
}
if(ls_errcode != null && ls_errcode.trim().length() > 0)
{
ls_errcode = itmdbAccessEJB.getErrorString("",ls_errcode, userId, "", con);
}
else
{
if("A".equalsIgnoreCase(ls_status))
{
try
{
sql ="update empotime set status= ? where tran_id= ?";
pStmt = con.prepareStatement(sql);
pStmt.setString(1, "X");
pStmt.setString(2, as_tranid);
int i = pStmt.executeUpdate();
if(i > 0)
{
con.commit();
}
else
{
con.rollback();
}
if(pStmt != null)
{
pStmt.close();
pStmt = null;
}
}
catch(Exception e)
{
ls_errcode = itmdbAccessEJB.getErrorString("", "DS000", userId, "", con);
return ls_errcode;
}
}
else if("".equalsIgnoreCase(ls_status))
{
try
{
sql ="update empotime set status= ? where tran_id= ?";
pStmt = con.prepareStatement(sql);
pStmt.setString(1, "X");
pStmt.setString(2, as_tranid);
int i = pStmt.executeUpdate();
if(i > 0)
{
con.commit();
}
else
{
con.rollback();
}
if(pStmt != null)
{
pStmt.close();
pStmt = null;
}
}
catch(Exception e)
{
ls_errcode = itmdbAccessEJB.getErrorString("", "DS000", userId, "", con);
return ls_errcode;
}
}
else
{
try
{
sql ="update empotime set status= ? where tran_id= ?";
pStmt = con.prepareStatement(sql);
pStmt.setString(1, "X");
pStmt.setString(2, as_tranid);
int i = pStmt.executeUpdate();
if(i > 0)
{
con.commit();
}
else
{
con.rollback();
}
if(pStmt != null)
{
pStmt.close();
pStmt = null;
}
}
catch(Exception e)
{
ls_errcode = itmdbAccessEJB.getErrorString("", "DS000", userId, "", con);
return ls_errcode;
}
}
if(ls_errcode != null && ls_errcode.trim().length() > 0)
{
if(ai_commit == 2)
{
// rollback is what
}
}
else
{
if(ai_commit == 2)
{
// commit is what
}
}
}
}
catch(Exception e)
{
BaseLogger.log("0",null,"","EmpOvertimeCancel.gbf_cancel_overtime()"+e);
}
System.out.println("########ls_errcode1"+ls_errcode);
return ls_errcode;
}
}
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