Commit b887c68a authored by dsawant's avatar dsawant

updated


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@96086 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 2b678edd
package ibase.webitm.ejb.dis; package ibase.webitm.ejb.dis;
import java.rmi.RemoteException; import java.rmi.RemoteException;
import ibase.webitm.utility.GenericUtility; import ibase.webitm.utility.GenericUtility;
import java.sql.DriverManager; import java.sql.DriverManager;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.Statement; import java.sql.Statement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.Connection; import java.sql.Connection;
import java.sql.SQLException; import java.sql.SQLException;
import java.sql.*; import java.sql.*;
import javax.ejb.*; import javax.ejb.*;
import ibase.webitm.ejb.*; import ibase.webitm.ejb.*;
import org.w3c.dom.*; import org.w3c.dom.*;
import ibase.webitm.utility.ITMException; import ibase.webitm.utility.ITMException;
import ibase.utility.CommonConstants; import ibase.utility.CommonConstants;
import org.w3c.dom.*; import org.w3c.dom.*;
import javax.xml.parsers.*; import javax.xml.parsers.*;
import ibase.webitm.utility.*; import ibase.webitm.utility.*;
import ibase.system.config.*; import ibase.system.config.*;
import javax.naming.InitialContext; import javax.naming.InitialContext;
import ibase.webitm.utility.ITMException; import ibase.webitm.utility.ITMException;
import ibase.webitm.utility.GenericUtility; import ibase.webitm.utility.GenericUtility;
import java.io.File; import java.io.File;
import ibase.system.config.ConnDriver; import ibase.system.config.ConnDriver;
import javax.ejb.Stateless; import javax.ejb.Stateless;
@Stateless @Stateless
public class DissIssuePosSave extends ValidatorEJB implements DissIssuePosSaveLocal,DissIssuePosSaveRemote // SessionBean public class DissIssuePosSave extends ValidatorEJB implements DissIssuePosSaveLocal,DissIssuePosSaveRemote // SessionBean
{ {
public String postSave() throws RemoteException,ITMException public String postSave() throws RemoteException,ITMException
{ {
return ""; return "";
} }
public String postSaveRec() throws RemoteException, ITMException public String postSaveRec() throws RemoteException, ITMException
{ {
return ""; return "";
} }
public String postSaveRec(String xmlString1, String domId, String objContext, String editFlag, String xtraParams, Connection conn) throws RemoteException, ITMException public String postSaveRec(String xmlString1, String domId, String objContext, String editFlag, String xtraParams, Connection conn) throws RemoteException, ITMException
{ {
return ""; return "";
} }
public String postSave(String winName,String editFlag,String tranId, String xtraParams,Connection conn) throws RemoteException,ITMException public String postSave(String winName,String editFlag,String tranId, String xtraParams,Connection conn) throws RemoteException,ITMException
{ {
String sql = "",shipmentId = ""; String sql = "",shipmentId = "";
GenericUtility genericUtility = GenericUtility.getInstance(); GenericUtility genericUtility = GenericUtility.getInstance();
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null; ResultSet rs = null;
double amount = 0,netAmount=0,discAmount=0,taxAmount=0,noArt = 0; //net_amt =amount+tax_amt-disc_amt double amount = 0,netAmount=0,discAmount=0,taxAmount=0,noArt = 0; //net_amt =amount+tax_amt-disc_amt
double grossWeight = 0 ,tareWeight = 0 , netWeight = 0; double grossWeight = 0 ,tareWeight = 0 , netWeight = 0;
try try
{ {
conn = null; conn = null;
ConnDriver connDriver = new ConnDriver(); ConnDriver connDriver = new ConnDriver();
conn = connDriver.getConnectDB("DriverITM"); conn = connDriver.getConnectDB("DriverITM");
connDriver= null; connDriver= null;
conn.setAutoCommit(false); conn.setAutoCommit(false);
sql = "update distord_issdet set " sql = "update distord_issdet set "
+" amount = quantity * rate , " +" amount = quantity * rate , "
+" disc_amt = quantity * rate * discount/100 , " +" disc_amt = quantity * rate * discount/100 , "
+ " net_amt = quantity * rate + tax_amt - (quantity * rate * discount/100 ) " + " net_amt = quantity * rate + tax_amt - (quantity * rate * discount/100 ) "
+ " where tran_id = ? "; + " where tran_id = ? ";
pstmt= conn.prepareStatement(sql); pstmt= conn.prepareStatement(sql);
//System.out.println("First sql ["+ sql + "] tranId [" + tranId + "]"); //System.out.println("First sql ["+ sql + "] tranId [" + tranId + "]");
pstmt.setString( 1, tranId ); pstmt.setString( 1, tranId );
pstmt.executeUpdate(); pstmt.executeUpdate();
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
sql = "select sum(amount), sum(net_amt),sum(disc_amt),sum(tax_amt),sum(no_art) , sum(gross_weight) ,sum (tare_weight) , sum(net_weight ) " sql = "select sum(amount), sum(net_amt),sum(disc_amt),sum(tax_amt),sum(no_art) , sum(gross_weight) ,sum (tare_weight) , sum(net_weight ) "
+ " from distord_issdet where tran_id = ? "; + " from distord_issdet where tran_id = ? ";
pstmt= conn.prepareStatement(sql); pstmt= conn.prepareStatement(sql);
//System.out.println("Second sql ["+sql + "]"); //System.out.println("Second sql ["+sql + "]");
pstmt.setString( 1, tranId ); pstmt.setString( 1, tranId );
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if (rs.next()) if (rs.next())
{ {
amount = rs.getDouble(1); amount = rs.getDouble(1);
netAmount = rs.getDouble(2); netAmount = rs.getDouble(2);
discAmount = rs.getDouble(3); discAmount = rs.getDouble(3);
taxAmount = rs.getDouble(4); taxAmount = rs.getDouble(4);
noArt = rs.getDouble(5); noArt = rs.getDouble(5);
//added by kunal on 06/AUG/13 //added by kunal on 06/AUG/13
grossWeight = rs.getDouble(6); grossWeight = rs.getDouble(6);
tareWeight = rs.getDouble(7); tareWeight = rs.getDouble(7);
netWeight = rs.getDouble(8); netWeight = rs.getDouble(8);
} }
rs.close(); rs.close();
rs = null; rs = null;
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
//added by kunal on 06/AUG/13 //added by kunal on 06/AUG/13
sql = "select shipment_id from distord_iss where tran_id = ? "; sql = "select shipment_id from distord_iss where tran_id = ? ";
pstmt= conn.prepareStatement(sql); pstmt= conn.prepareStatement(sql);
pstmt.setString( 1, tranId ); pstmt.setString( 1, tranId );
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if (rs.next()) if (rs.next())
{ {
shipmentId = rs.getString(1); shipmentId = rs.getString(1);
} }
rs.close(); rs.close();
rs = null; rs = null;
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
if(shipmentId != null && shipmentId.trim().length() > 0) if(shipmentId != null && shipmentId.trim().length() > 0)
{ {
grossWeight = 0; grossWeight = 0;
tareWeight = 0; tareWeight = 0;
netWeight = 0; netWeight = 0;
} }
sql = " update distord_iss set " sql = " update distord_iss set "
+ " amount = ?, net_amt = ?, discount = ? , tax_amt = ? , no_art = ? ,gross_weight = ? , tare_weight = ? , net_weight = ? " + " amount = ?, net_amt = ?, discount = ? , tax_amt = ? , no_art = ? ,gross_weight = ? , tare_weight = ? , net_weight = ? "
+ " where tran_id = ? " ; + " where tran_id = ? " ;
pstmt= conn.prepareStatement( sql ); pstmt= conn.prepareStatement( sql );
//System.out.println("Fourth sql ["+sql + "]"); //System.out.println("Fourth sql ["+sql + "]");
pstmt.setDouble( 1, amount ); pstmt.setDouble( 1, amount );
pstmt.setDouble( 2, netAmount ); pstmt.setDouble( 2, netAmount );
pstmt.setDouble( 3, discAmount ); pstmt.setDouble( 3, discAmount );
pstmt.setDouble( 4, taxAmount ); pstmt.setDouble( 4, taxAmount );
pstmt.setDouble( 5, noArt ); pstmt.setDouble( 5, noArt );
pstmt.setDouble( 6, grossWeight );////added by kunal on 06/AUG/13 pstmt.setDouble( 6, grossWeight );////added by kunal on 06/AUG/13
pstmt.setDouble( 7, tareWeight );//added by kunal on 06/AUG/13 pstmt.setDouble( 7, tareWeight );//added by kunal on 06/AUG/13
pstmt.setDouble( 8, netWeight );//added by kunal on 06/AUG/13 pstmt.setDouble( 8, netWeight );//added by kunal on 06/AUG/13
pstmt.setString( 9, tranId ); pstmt.setString( 9, tranId );
pstmt.executeUpdate(); pstmt.executeUpdate();
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
conn.commit();
}
catch(Exception e) }
{ catch(Exception e)
e.printStackTrace(); {
throw new ITMException(e); e.printStackTrace();
} throw new ITMException(e);
finally
{ try {
try System.out.println(">>>>>>>>>>>>In catch Before rollback>>>");
{ conn.rollback();
if(pstmt != null)pstmt.close(); } catch (SQLException e1) {
pstmt = null; // TODO Auto-generated catch block
}catch(Exception d) e1.printStackTrace();
{
d.printStackTrace(); }
throw new ITMException(d);
} }
} finally
return ""; {
} try
{
}// end of DissIssuePosSaveEJB class if(pstmt != null)pstmt.close();
pstmt = null;
if(conn != null)
{
conn.close();
}
}catch(Exception d)
{
d.printStackTrace();
throw new ITMException(d);
}
}
return "";
}
}// end of DissIssuePosSaveEJB class
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