Commit 04881722 authored by nkhan's avatar nkhan

this component will be display item details on itemDetails.jsp page


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@104313 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 32ad50f5
package ibase.webitm.ejb.dis;
import ibase.webitm.ejb.ValidatorEJB;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
public class ItemDetails extends ValidatorEJB
{
@SuppressWarnings({ "unchecked", "rawtypes" })
public ArrayList getItemListDetails(String itemCode)
{
String sql = "";
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
ArrayList itemList = new ArrayList();
boolean isExists = false;
try
{
conn = getConnection();
sql = "SELECT I1.ITEM_PARNT, I1.DESCR AS PARENT_DESCR, I1.PHY_ATTRIB_2, I1.PHY_ATTRIB_6, I1.PHY_ATTRIB_4, I.DESCR, (SELECT SUM(S.QUANTITY - S.ALLOC_QTY - CASE WHEN S.HOLD_QTY IS NULL THEN 0 ELSE S.HOLD_QTY END ) FROM STOCK S WHERE S.ITEM_CODE = '311208' GROUP BY S.ITEM_CODE) AS STOCk FROM ITEM I1, ITEM I WHERE I1.ITEM_PARNT = I.ITEM_CODE (+) AND I1.ITEM_CODE = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, checkNull(itemCode));
rs = pstmt.executeQuery();
if ( rs.next())
{
itemList.add(checkNullAndBlank( rs.getString("ITEM_PARNT") ));
itemList.add(checkNullAndBlank( rs.getString("PARENT_DESCR") ));
itemList.add(checkNullAndBlank( rs.getString("PHY_ATTRIB_2") ));
itemList.add(checkNullAndBlank( rs.getString("PHY_ATTRIB_6") ));
itemList.add(checkNullAndBlank( rs.getString("PHY_ATTRIB_4") ));
itemList.add(checkNullAndBlank( rs.getString("DESCR") ));
itemList.add(checkNullAndBlank( rs.getString("STOCk") ));
isExists = true;
}
if(!isExists)
{
itemList.add("");
itemList.add("");
itemList.add("");
itemList.add("");
itemList.add("");
itemList.add("");
itemList.add("");
}
if (rs != null)
{
rs.close();
rs = null;
}
if (pstmt != null )
{
pstmt.close();
pstmt = null;
}
}
catch (Exception e)
{
System.out.println("ItemListDetails.getItemListDetails()["+e.getMessage()+"]");
e.printStackTrace();
}
finally
{
try
{
if (rs != null)
{
rs.close();
rs = null;
}
if (pstmt != null )
{
pstmt.close();
pstmt = null;
}
if (conn != null )
{
conn.close();
conn = null;
}
}
catch (Exception e)
{
System.out.println("ItemListDetails.getItemListDetails()");
e.printStackTrace();
}
}
System.out.println("ItemListDetails from ItemListDetails =======>>["+itemList+"]");
return itemList;
}
@SuppressWarnings({ "rawtypes", "unchecked" })
public String getDocId(String itemCode)
{
System.out.println("inside getDocIDImages");
PreparedStatement pstmt = null;
ResultSet rs = null;
String sql = "";
String errString = "";
Connection conn = null;
ArrayList itemList = new ArrayList();
try
{
conn = getConnection();
sql = " SELECT DOC_TRANSACTION_LINK.DOC_ID FROM DOC_TRANSACTION_LINK DOC_TRANSACTION_LINK, DOC_CONTENTS DOC_CONTENTS, ITEM ITEM "
+ " WHERE DOC_TRANSACTION_LINK.DOC_ID = DOC_CONTENTS.DOC_ID AND (TRIM(DOC_TRANSACTION_LINK.REF_ID) = TRIM(ITEM.ITEM_PARNT) OR "
+ " TRIM(DOC_TRANSACTION_LINK.REF_ID) = TRIM(ITEM.ITEM_CODE)) AND ITEM.ITEM_CODE = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, itemCode);
rs = pstmt.executeQuery();
while (rs.next())
{
itemList.add(checkNull(rs.getString("DOC_ID")));
}
if (rs != null)
{
rs.close();
rs = null;
}
if (pstmt != null )
{
pstmt.close();
pstmt = null;
}
}
catch (Exception ex)
{
System.out.println("Inside catch getDocIDImages");
ex.printStackTrace();
}
finally
{
try
{
if (rs != null)
{
rs.close();
rs = null;
}
if (pstmt != null )
{
pstmt.close();
pstmt = null;
}
if (conn != null && !conn.isClosed())
{
conn.close();
conn = null;
}
}
catch (Exception e)
{
System.out.println("ItemListDetails.getDocId()["+e.getMessage()+"]");
}
}
errString = itemList.toString();
errString = errString.substring(1, errString.length() - 1);
System.out.println("errString ::::::::["+errString+"]");
return errString;
}
private String checkNull( String input )
{
if ( input == null )
{
input = "";
}
return input.trim();
}
private String checkNullAndBlank( String input )
{
if ( input == null )
{
input = " ";
}
return input;
}
}
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