Commit 295a3f52 authored by agaikwad's avatar agaikwad

Request_id-F14CSUN001


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@98671 ce508802-f39f-4f6c-b175-0d175dae99d5
parent a7c50a3b
This source diff could not be displayed because it is too large. You can view the blob instead.
package ibase.webitm.ejb.fin;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.utility.GenericUtility;
import ibase.webitm.utility.ITMException;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import javax.ejb.Stateless;
import org.w3c.dom.Document;
import org.w3c.dom.NodeList;
@Stateless
public class AssetSalesPostSave extends ValidatorEJB implements AssetSalesPostSaveLocal,AssetSalesPostSaveRemote
{
public String postSave()throws RemoteException,ITMException
{
return "";
}
public String postSave(String domString, String tranId,String editFlag, String xtraParams, Connection conn ) throws RemoteException,ITMException
{
NodeList detail2List = null;
String errString = "";
Document dom = null;
PreparedStatement pstmt = null,pstmt1 = null;
ResultSet rs = null;
String sql = "";
System.out.println(" Tran id = "+tranId);
double taxAmt=0d,salesamt=0d,exrecoamt=0d;
double amount = 0d,Hdramount= 0d,Detamount = 0d;
int lineNo=0;
GenericUtility genericUtility = null;
try
{
genericUtility = GenericUtility.getInstance();
dom = genericUtility.parseString(domString);
detail2List = dom.getElementsByTagName("Detail2");
tranId = genericUtility.getColumnValueFromNode("tran_id", dom.getElementsByTagName("Detail1").item(0));
System.out.println("@@@@@ postSave called :["+tranId+"]");
System.out.println("@@@@@@@@ detail2List [[[[[[[["+detail2List.getLength()+"]]]]]]]]]]]]]");
pstmt=conn.prepareStatement("select sum(tax_amt),sum(sale_amt),sum(excreco_amt) from asset_sales_det where tran_id = ?");
pstmt.setString(1, tranId);
rs=pstmt.executeQuery();
while(rs.next())
{
taxAmt = rs.getDouble(1);
salesamt = rs.getDouble(2);
exrecoamt = rs.getDouble(3);
}
if(rs !=null)
rs.close();
rs = null;
if(pstmt !=null)
pstmt.close();
pstmt = null;
sql = "update asset_sales_hdr set tax_amt = ?,sale_amt = ?, excreco_amt = ? where tran_id = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setDouble(1, taxAmt);
pstmt.setDouble(2, salesamt);
pstmt.setDouble(3, exrecoamt);
pstmt.setString(4, tranId);
int updCisshdr=pstmt.executeUpdate();
conn.commit();
//pstmt.close();
//pstmt=null;
System.out.println(" updated record in header :: "+updCisshdr);
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
if (rs != null)
{
rs.close();
rs = null;
}
pstmt=conn.prepareStatement("select sum(tax_amt),sum(amount) from asset_sales_det where tran_id = ?");
pstmt.setString(1, tranId);
rs=pstmt.executeQuery();
while(rs.next())
{
taxAmt = rs.getDouble(1);
amount = rs.getDouble(2);
}
Hdramount = taxAmt + amount;
if(rs !=null)
rs.close();
rs = null;
if(pstmt !=null)
pstmt.close();
pstmt = null;
sql = "update asset_sales_hdr set total_amt = ? where tran_id = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setDouble(1, Hdramount);
pstmt.setString(2, tranId);
int updCisshdr1 =pstmt.executeUpdate();
conn.commit();
//pstmt.close();
//pstmt=null;
System.out.println(" updated record in header :: "+updCisshdr1);
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
if (rs != null)
{
rs.close();
rs = null;
}
pstmt=conn.prepareStatement("select tax_amt,amount , line_no from asset_sales_det where tran_id = ?");
pstmt.setString(1, tranId);
rs=pstmt.executeQuery();
while(rs.next())
{
taxAmt = rs.getDouble(1);
amount = rs.getDouble(2);
lineNo = rs.getInt(3);
System.out.println("Tax Amount is"+taxAmt);
System.out.println("Amount is"+taxAmt);
System.out.println("Line No is"+taxAmt);
Detamount = taxAmt + amount;
System.out.println("totamtdet>>>>>>>>>>>>>>>>> [" +Detamount +"]" );
sql = "update asset_sales_det set tot_amt = ? where tran_id = ? and line_no = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setDouble(1, Detamount);
pstmt.setString(2, tranId);
pstmt.setInt(3,lineNo);
int updCisshdr2 =pstmt.executeUpdate();
System.out.println(" updated record in Detail :: "+updCisshdr2);
}
}
catch(Exception e)
{
System.out.println("Exception.. "+e.getMessage());
e.printStackTrace();
errString=e.getMessage();
throw new ITMException(e);
}
finally
{
try
{
if( errString != null && errString.trim().length() > 0 )
{
conn.rollback();
System.out.println("Transaction rollback... ");
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(pstmt1 != null)
{
pstmt1.close();
pstmt1 = null;
}
if(rs != null)
{
rs.close();
rs = null;
}
}
catch(Exception e)
{
e.printStackTrace();
throw new ITMException(e);
}
}
return errString;
}
}
package ibase.webitm.ejb.fin;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.utility.ITMException;
import java.rmi.RemoteException;
import java.sql.Connection;
import javax.ejb.Local;
@Local
public interface AssetSalesPostSaveLocal
{
public String postSave(String xmlString,String tranid,String editFlag,String xtraParams,Connection conn) throws RemoteException,ITMException;
}
\ No newline at end of file
package ibase.webitm.ejb.fin;
import java.rmi.RemoteException;
import java.sql.Connection;
import javax.ejb.Remote;
import ibase.webitm.ejb.ValidatorRemote;
import ibase.webitm.utility.ITMException;
@Remote
public interface AssetSalesPostSaveRemote extends ValidatorRemote
{
public String postSave(String xmlString,String tranId,String editflag,String xtraParams,Connection conn) throws RemoteException,ITMException;
}
\ No newline at end of file
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