Commit ea1a0a4c authored by dpawar's avatar dpawar

added stock updated code


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@94518 ce508802-f39f-4f6c-b175-0d175dae99d5
parent b422ad91
......@@ -8,7 +8,7 @@ import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.ActionHandlerEJB;
import java.sql.*;
import java.util.Map;
import java.util.*;
import java.util.StringTokenizer;
import javax.ejb.Stateless;
......@@ -45,17 +45,21 @@ public class StockValAdjTranConf extends ActionHandlerEJB implements StockValAdj
Connection conn=null;
String confirmed = "";
PreparedStatement pstmt=null;
String errString="",sql="";
String errString="",sql="",loginEmpCode="",siteCode="",itemCode="",locCode="",lotNo="",lotSl="";
double PriceListRate=0,amount=0;
ConnDriver ConnDriver = new ConnDriver();
Map <String,String>updateStockMap =new HashMap<String,String>();
int updCnt=0;
int updCnt=0,count=0;
ITMDBAccessLocal itmdbAccess=new ITMDBAccessEJB();
try
{
ConnDriver connDriver = null;
connDriver = new ConnDriver();
conn = connDriver.getConnectDB("DriverValidator");
conn = connDriver.getConnectDB("DriverValidator");
loginEmpCode=GenericUtility.getInstance().getValueFromXTRA_PARAMS(xtraParams,"loginEmpCode");
loginEmpCode=loginEmpCode==null ? "" :loginEmpCode.trim();
System.out.println("loginEmpCode---->>["+loginEmpCode+"]");
conn.setAutoCommit(false);
sql = "select confirmed from stock_val_adj WHERE tran_id = ?";
pstmt = conn.prepareStatement(sql);
......@@ -87,25 +91,49 @@ public class StockValAdjTranConf extends ActionHandlerEJB implements StockValAdj
}
GenericUtility genericUtility=new GenericUtility();
String loginCode=genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginEmpCode");
System.out.println("Login Code ------->> "+loginCode);
sql="update stock_val_adj set confirmed = ?,conf_date = ?, emp_code__aprv = ? where tran_id = ?";
pstmt=conn.prepareStatement(sql);
pstmt.setString(1, "Y");
pstmt.setDate(2, new java.sql.Date(System.currentTimeMillis()));
pstmt.setString(3,loginCode);
pstmt.setString(4, tranId);
//VTCONSUCC
tranId=tranId==null ? "" :tranId.trim();
sql="select h.site_code,d.rate,d.item_code,d.loc_code,d.lot_no,d.lot_sl "
+ "from stock_val_adj h,stock_val_adj_det d where h.tran_id=d.tran_id and d.tran_id = ?";
pstmt=conn.prepareStatement(sql);
pstmt.setString(1, tranId);
rs=pstmt.executeQuery();
while(rs.next()){
siteCode=checkNull(rs.getString(1));
PriceListRate=rs.getDouble(2);
itemCode=checkNull(rs.getString(4));
locCode=checkNull(rs.getString(5));
lotNo=checkNull(rs.getString(6));
lotSl=checkNull(rs.getString(7));
updateStockMap.put("price_list_rate",Double.toString(PriceListRate));
updateStockMap.put("item_code",itemCode);
updateStockMap.put("site_code",siteCode);
updateStockMap.put("loc_code",locCode);
updateStockMap.put("lot_no",lotNo);
updateStockMap.put("lot_sl",lotSl);
count=updateStockRateAsPerPriceListRate(conn, updateStockMap);
System.out.println("updateStockRateAsPerPriceListRate count-->["+count+"]");
if(count > 0){
count=updateStockValAdj(conn, loginEmpCode, tranId);
System.out.println("updateStockValAdj-->>["+count+"]");
if(count > 0){
//confirmed messages show.............
}
}else{
//disply error message.
}
}
updCnt=pstmt.executeUpdate();
if (updCnt > 0)
{
System.out.println("successfully confirmed");
conn.commit();
errString = itmdbAccess.getErrorString("", "VTCONSUCC", "", "", conn);
return errString;
}
......@@ -163,31 +191,60 @@ public class StockValAdjTranConf extends ActionHandlerEJB implements StockValAdj
return errString;
}
public int updateStockRateAsPerPriceListRate(Connection conn,Map<String,String> updateStockMap){
PreparedStatement pstmt=null;
String sql="";
int count=0;
try{
sql="update stock set rate = ? where item_code= ? and site_code = ? and loc_code = ? "
+ "and lot_no = ? and lot_sl = ?";
public int updateStockRateAsPerPriceListRate(Connection conn,Map<String,String> updateStockMap){
PreparedStatement pstmt=null;
String sql="";
int count=0;
try{
sql="update stock set rate = ? where item_code= ? and site_code = ? and loc_code = ? "
+ "and lot_no = ? and lot_sl = ?";
pstmt=conn.prepareStatement(sql);
pstmt.setDouble(1,Double.parseDouble(updateStockMap.get("price_list_rate")));
pstmt.setString(2,updateStockMap.get("item_code"));
pstmt.setString(3,updateStockMap.get("site_code"));
pstmt.setString(4,updateStockMap.get("loc_code"));
pstmt.setString(5,updateStockMap.get("lot_no"));
pstmt.setString(6,updateStockMap.get("lot_sl"));
pstmt=conn.prepareStatement(sql);
pstmt.setDouble(1,Double.parseDouble(updateStockMap.get("price_list_rate")));
pstmt.setString(2,updateStockMap.get("item_code"));
pstmt.setString(3,updateStockMap.get("site_code"));
pstmt.setString(4,updateStockMap.get("loc_code"));
pstmt.setString(5,updateStockMap.get("lot_no"));
pstmt.setString(6,updateStockMap.get("lot_sl"));
count=pstmt.executeUpdate();
count=pstmt.executeUpdate();
}
catch(Exception e){
System.out.println("Exception in updateStockRateAsPerPriceListRate----------");
e.printStackTrace();
}
return count;
}
catch(Exception e){
System.out.println("Exception in updateStockRateAsPerPriceListRate----------");
e.printStackTrace();
}
return count;
}
}
private int updateStockValAdj(Connection conn,String loginEmpCodeL,String tranId){
PreparedStatement pstmt=null;
String sql="";
int updCnt=0;
try{
sql="update stock_val_adj set confirmed = ?,conf_date = ?, emp_code__aprv = ? where tran_id = ?";
pstmt=conn.prepareStatement(sql);
pstmt.setString(1, "Y");
pstmt.setDate(2, new java.sql.Date(System.currentTimeMillis()));
pstmt.setString(3,loginEmpCodeL);
pstmt.setString(4, tranId);
updCnt=pstmt.executeUpdate();
System.out.println("updateStockValAdj----->>["+updCnt+"]");
return updCnt;
}
catch(Exception e){
e.printStackTrace();
return -1;
}
}
private String checkNull(String input){
if(input==null)
return "";
return input.trim();
}
}
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