Commit 5257d942 authored by sanashaikh's avatar sanashaikh

Sana S: Added on 26/09/2019

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@208257 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 61cea745
package ibase.webitm.ejb.adm;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import bsh.util.Util;
import ibase.utility.E12GenericUtility;
import ibase.webitm.ejb.ITMDBAccessEJB;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.utility.GenericUtility;
import ibase.webitm.utility.ITMException;
import java.util.*;
import javax.ejb.Stateless;
@Stateless
//Created By Sana S on 19/09/2019 [start]
public class PayrollRemarkIC extends ValidatorEJB implements PayrollRemarkICLocal,PayrollRemarkICRemote
{
E12GenericUtility genericUtility = new E12GenericUtility();
AdmCommon admCommon = new AdmCommon();
ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB();
public String itemChanged(String xmlString, String xmlString1,String xmlString2, String objContext, String currentColumn,String editFlag, String xtraParams) throws RemoteException,ITMException
{
System.out.println("Came Inside 1 itemChanged:::");
Document dom = null;
Document dom1 = null;
Document dom2 = null;
String errFields = null;
genericUtility = new E12GenericUtility();
try
{
System.out.println("xmlString [" + xmlString + "]");
System.out.println("xmlString1 [" + xmlString1 + "]");
System.out.println("xmlString2 [" + xmlString2 + "]");
if (xmlString != null && xmlString.trim().length() != 0)
{
dom = genericUtility.parseString(xmlString);
}
if (xmlString1 != null && xmlString1.trim().length() != 0)
{
dom1 = genericUtility.parseString(xmlString1);
}
if (xmlString2 != null && xmlString2.trim().length() != 0)
{
dom2 = genericUtility.parseString(xmlString2);
}
errFields = itemChanged(dom, dom1, dom2, objContext, currentColumn,editFlag, xtraParams);
System.out.println("errFields :" + errFields);
}
catch (Exception e)
{
System.out.println("Exception :PayrollRemarks :" + e.getMessage()+ ":");
errFields = genericUtility.createErrorString(e);
throw new ITMException(e);
}
return errFields;
}
public String itemChanged(Document dom, Document dom1, Document dom2,String objContext, String currentColumn, String editFlag,String xtraParams) throws RemoteException, ITMException
{
System.out.println("Item Changes Call..................");
Connection conn = null;
PreparedStatement pstmt=null;
ResultSet rs = null;
String sql="";
StringBuffer valueXmlString = new StringBuffer();
int currentFormNo = 0;
String FName ="", LName = "";
String empCode = "";
double workDays = 0.0,woffDays=0.0,lvesTaken=0.0,daysCnt=0.0;
String workDays1 = "",woffDays1="",lvesTaken1="";
try
{
conn = getConnection();
if(objContext != null && objContext.trim().length()>0)
{
currentFormNo = Integer.parseInt(objContext);
}
valueXmlString = new StringBuffer("<?xml version=\"1.0\"?><Root><header><editFlag>");
valueXmlString.append(editFlag).append("</editFlag></header>");
System.out.println("Form No:::"+currentFormNo);
switch (currentFormNo)
{
case 1:
{
valueXmlString.append("<Detail1>");
if ("emp_code".equalsIgnoreCase(currentColumn))
{
empCode = checkNull(genericUtility.getColumnValue("emp_code", dom));
sql = "SELECT EMP_FNAME, EMP_LNAME FROM EMPLOYEE WHERE EMP_CODE = ?";
System.out.println("Emp Name Query:::"+sql);
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, empCode);
rs = pstmt.executeQuery();
if(rs.next())
{
FName = checkNull(rs.getString(1));
LName = checkNull(rs.getString(2));
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
valueXmlString.append("<emp_lname>").append(LName).append("</emp_lname>\r\n");
valueXmlString.append("<emp_fname>").append(FName).append("</emp_fname>\r\n");
}
else if ("work_days".equalsIgnoreCase(currentColumn) && "woff_days".equalsIgnoreCase(currentColumn) && "lves_taken".equalsIgnoreCase(currentColumn) )
{
workDays1=checkNull(genericUtility.getColumnValue("work_days", dom));
workDays = Double.parseDouble(workDays1);
System.out.print("workDays:"+workDays);
woffDays1=checkNull(genericUtility.getColumnValue("woff_days", dom));
woffDays=Double.parseDouble(woffDays1);
System.out.print("woff_days:"+woffDays);
lvesTaken1=checkNull(genericUtility.getColumnValue("lves_taken", dom));
lvesTaken=Double.parseDouble(lvesTaken1);
System.out.print("lves_taken:"+lvesTaken);
daysCnt=workDays+woffDays+lvesTaken;
valueXmlString.append("<paid_days>").append(daysCnt).append("</paid_days>\r\n");
}
valueXmlString.append("</Detail1>");
break;
}
}//END OF SWITCH
valueXmlString.append("</Root>");
System.out.println("valueXmlString[sepclose]"+valueXmlString);
}//END OF TRY
catch(Exception e)
{
System.out.println("Exception ::"+e.getMessage());
e.printStackTrace();
throw new ITMException(e);
}
finally
{
try
{
if(conn != null)
{
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
conn.close();
conn = null;
}
} catch (SQLException e) {
e.printStackTrace();
throw new ITMException(e);
}
}
return valueXmlString.toString();
}
private String checkNull(String input)
{
if (input == null)
{
input = "";
} else
{
input = input.trim();
}
return input;
}
}
//Created By Sana S on 19/09/2019 [end]
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