Commit ff0aadcf authored by awarekar's avatar awarekar

To set Net Amount (net_amt) in Header from detail.

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@195982 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 5ebce636
// Created by Amey W on 21 Jan 2019 [To set Net Amount(net_amt) in Header from detail]
package ibase.webitm.ejb.fin;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import org.w3c.dom.Document;
import ibase.utility.E12GenericUtility;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.utility.ITMException;
public class SalesBudgetCustPostSave extends ValidatorEJB
{
public String postSave()throws RemoteException,ITMException
{
return "";
}
public String postSave(String domString, String tranId,String editFlag, String xtraParams, Connection conn ) throws RemoteException,ITMException
{
System.out.println("amey x==>@@@@ postSave called domString="+domString+"tranId="+tranId+" editFlag="+editFlag+" xtraParams= "+xtraParams+" conn="+conn);
PreparedStatement pstmt = null;
PreparedStatement pstmt2 = null;
Document dom = null;
ResultSet rs =null;
boolean isError = false;
String sql = null, sql2 = null, errString="";
int cnt = 0;
double netAmt = 0, adjAmt = 0;
try
{
E12GenericUtility genericUtility = new E12GenericUtility();
dom = genericUtility.parseString(domString);
tranId = genericUtility.getColumnValue("tran_id", dom);
sql="SELECT net_amt FROM SALES_BUDGET_CUST_DET WHERE tran_id = ? " ;
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,tranId );
rs = pstmt.executeQuery();
while (rs.next())
{
netAmt = netAmt + rs.getDouble(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
sql2="UPDATE SALES_BUDGET_CUST set net_amt = ? where tran_id = ?";
System.out.println("x==> sql2 = "+sql2);
pstmt2 = conn.prepareStatement(sql2);
pstmt2.setDouble(1,netAmt);
pstmt2.setString(2,tranId );
cnt =pstmt2.executeUpdate();
if( cnt > 0)
{
System.out.println("x==> update of SALES_BUDGET_CUST success ["+cnt+"]");
}
pstmt2.close();
pstmt2 = null;
}
catch(Exception e)
{
try {
conn.rollback();
} catch (SQLException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
isError = true;
System.out.println("Exception :VoucherPostSaveEJB : :==>\n"+e.getMessage());
e.printStackTrace();
throw new ITMException(e);
}
finally
{
try
{
System.out.println("isError ["+isError+"]");
if( conn != null )
{
/*if( isError )
{
conn.rollback();
}
else
{
conn.commit();
}*/
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(pstmt2 != null)
{
pstmt2.close();
pstmt2 = null;
}
}
catch(Exception e)
{
System.out.println("Exception :VoucherPostSaveEJB : :==>\n"+e.getMessage());
try
{
System.out.println("Before rollback");
conn.rollback();
}
catch(SQLException sqle)
{
System.out.println(sqle);
}
throw new ITMException(e);
}
}
return "";
}
}
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