Commit 40b68f37 authored by cshah's avatar cshah

Changes in tran_date column in itemchange and wfvaldata method


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@91694 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 692a8a95
......@@ -11,6 +11,7 @@ import java.util.*;
import java.util.Date;
import java.sql.*;
import org.w3c.dom.*;
import javax.xml.parsers.*;
import javax.ejb.*;
import javax.naming.InitialContext;
......@@ -36,12 +37,13 @@ public class CustStock extends ValidatorEJB //implements SessionBean
{
}
*/
public String wfValData() throws RemoteException,ITMException
{
return "";
}
public String wfValData(String xmlString, String formNo, String editFlag) throws RemoteException,ITMException
// Commented by Chandni Shah 17-Apr-2012
/*public String wfValData(String xmlString, String formNo, String editFlag) throws RemoteException,ITMException
{
Document dom = null;
String errString = "";
......@@ -56,10 +58,69 @@ public class CustStock extends ValidatorEJB //implements SessionBean
}
errString = wfValData(dom, formNo, editFlag);
return (errString);
}*/
// Added by Chandni Shah 17-Apr-2012
public String wfValData(String xmlString, String xmlString1, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException
{
String errString = null;
Document dom = null;
Document dom1 = null;
Document dom2 = null;
try
{
//System.out.println("xmlString:-" + xmlString );
dom = parseString(xmlString);
dom1 = parseString(xmlString1);
errString = wfValData(dom,dom1,dom2,objContext,editFlag,xtraParams);
}
catch(Exception e)
{
//System.out.println("Exception : SOrderFormEJB : wfValData(String xmlString) : ==>\n"+e.getMessage());
throw new ITMException( e );
}
return (errString);
}
public String wfValData(String xmlString, String xmlString1,String xmlString2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException
{
String errString = null;
Document dom = null;
Document dom1 = null;
Document dom2 = null;
try
{
System.out.println("cHANDNI 11 xmlString:-" + xmlString );
System.out.println("cHANDNI 12 xmlString:-" + xmlString1 );
//long startTime = System.currentTimeMillis();
dom = parseString(xmlString);
dom1 = parseString(xmlString1);
System.out.println("Chandni 13 dom"+dom);
System.out.println("Chandni 14 dom"+dom1);
if (xmlString2.trim().length() > 0 )
{
dom2 = parseString("<Root>" + xmlString2+ "</Root>");
}
System.out.println("Chandni 15 dom"+dom2);
//long endTime = System.currentTimeMillis();
//long totalTime = endTime - startTime;
//System.out.println(xmlString2);
//System.out.println("start Time Spend :: "+startTime+" Milliseconds");
//System.out.println("End Time Spend :: "+endTime+" Milliseconds");
//System.out.println("Total Time Spend :: "+totalTime+" Milliseconds");
public String wfValData(Document dom, String formNo, String editFlag) throws RemoteException,ITMException
errString = wfValData(dom,dom1,dom2,objContext,editFlag,xtraParams);
}
catch(Exception e)
{
//System.out.println("Exception : SOrderFormEJB : wfValData(String xmlString) : ==>\n"+e.getMessage());
throw new ITMException( e );
}
return (errString);
}
// Commented by Chandni Shah 17-Apr-2012
//public String wfValData(Document dom, String formNo, String editFlag) throws RemoteException,ITMException
public String wfValData(Document dom, Document dom1,Document dom2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException
{
// Added by Chandni Shah 17-Apr-2012
boolean checkNextCol = true;
String columnName = "";
String columnValue = "";
......@@ -101,51 +162,61 @@ public class CustStock extends ValidatorEJB //implements SessionBean
try
{
System.out.println("CustStockEJB validation");
AppConnectParm appConnect = new AppConnectParm();
//System.out.println("CustStockEJB validation");
/*AppConnectParm appConnect = new AppConnectParm();
Properties p = appConnect.getProperty();
InitialContext ctx = new InitialContext(p);
itmDBAccess = (ITMDBAccessLocal)ctx.lookup("ibase/ITMDBAccessEJB/local");
*/
//itmDBAccess = itmDBAccessHome.create();
ibase.webitm.utility.GenericUtility genericUtility = new ibase.webitm.utility.GenericUtility();
conn = getConnection();
userId = getColumnValue( "user_id", dom );
currentFormNo = Integer.parseInt( formNo );
userId = genericUtility.getColumnValue( "user_id", dom );
//currentFormNo = Integer.parseInt( formNo );
currentFormNo = Integer.parseInt( objContext ); // Added by Chandni Shah 17-Apr-2012
switch ( currentFormNo )
{
case 1:
columnValue = getColumnValue( "tran_date", dom );
System.out.println("currentFormNo:::"+currentFormNo);
columnValue = genericUtility.getColumnValue("tran_date", dom );
System.out.println("columnValue 11:"+columnValue);
if(columnValue != null)
{
siteCode = getColumnValue( "site_code", dom );
siteCode = genericUtility.getColumnValue( "site_code", dom );
System.out.println("columnValue 12:"+columnValue+"_and checkNextCol:"+checkNextCol);
if ( columnValue.length() != 0 && checkNextCol )
{
System.out.println("inside columnValue:::");
errCode = nfCheckPeriod("SAL",getDateObject(columnValue),siteCode);
if (errCode.length() != 0)
{
System.out.println("errCode k ander");
//errString = getErrorString("",errCode,userId);
//checkNextCol = false;
errString = itmDBAccess.getErrorString("tran_date",errCode,userId,null,conn);
//errString = itmDBAccess.getErrorString("tran_date",errCode,userId);//,null,conn);
errString = getErrorString("tran_date",errCode,userId);//,null,conn); // Change by Chandni Shah 17-Apr-2012
break;
}
}
}
columnValue = getColumnValue("cust_code",dom);
//columnValue = getColumnValue("cust_code",dom);
columnValue = genericUtility.getColumnValue("cust_code",dom); // Change by Chandni Shah 17-Apr-2012
if(columnValue != null)
{
siteCode = getColumnValue("site_code",dom);
//siteCode = getColumnValue("site_code",dom);
siteCode = genericUtility.getColumnValue("site_code",dom);
System.out.println("siteCode [" +siteCode+ "]");
tranDate = getColumnValue("tran_date",dom);
tranDate = genericUtility.getColumnValue("tran_date",dom);
if (columnValue.length() != 0 && checkNextCol)
{
errCode = isCustomer(siteCode,columnValue,"S-CSTK",conn);
System.out.println("errCode [" +errCode+ "]");
if (errCode.length() !=0 )
{
//errString = getErrorString("cust_code",errCode,userId);
errString = getErrorString("cust_code",errCode,userId);
//checkNextCol = false;
errString = itmDBAccess.getErrorString("cust_code",errCode,userId,null,conn);
//errString = itmDBAccess.getErrorString("cust_code",errCode,userId);//,null,conn);
break;
}
}
......@@ -162,20 +233,20 @@ public class CustStock extends ValidatorEJB //implements SessionBean
{
if (rs.getInt(1) == 0)
{
//errString = getErrorString("cust_code","VTSITECUST",userId);
errString = getErrorString("cust_code","VTSITECUST",userId);
//checkNextCol = false;
errString = itmDBAccess.getErrorString("cust_code","VTSITECUST",userId,null,conn);
//errString = itmDBAccess.getErrorString("cust_code","VTSITECUST",userId);//,null,conn);
break;
}
}
}
else
{
/*Select count(1) into :cnt
/* Select count(1) into :cnt
From customer
Where cust_code = :mval
And (case when channel_partner is null then 'N' else channel_partner end ) = 'N';
If cnt = 0 Then errcode = "VTCUST"*/
If cnt = 0 Then errcode = "VTCUST" */
sqlCnt = "SELECT COUNT(1) COUNT FROM CUSTOMER WHERE CUST_CODE = '" + columnValue + "' And (CASE WHEN CHANNEL_PARTNER IS NULL THEN 'N' ELSE CHANNEL_PARTNER END ) = 'N'";
System.out.println("sql :\n"+sqlCnt);
stmt = conn.createStatement();
......@@ -183,7 +254,8 @@ public class CustStock extends ValidatorEJB //implements SessionBean
if (rs.next() && rs.getInt( "COUNT" ) == 0)
{
//errCode = "VTCUST";
errString = itmDBAccess.getErrorString("cust_code","VTCUST",userId,null,conn);
//errString = itmDBAccess.getErrorString("cust_code","VTCUST",userId);//,null,conn);
errString = getErrorString("cust_code","VTCUST",userId);//,null,conn);
break;
}
}
......@@ -193,10 +265,11 @@ public class CustStock extends ValidatorEJB //implements SessionBean
stmt = null;
}
}
columnValue = getColumnValue("site_code",dom);
//columnValue = getColumnValue("site_code",dom);
columnValue = genericUtility.getColumnValue("site_code",dom);
if(columnValue != null)
{
custCode = getColumnValue("cust_code",dom);
custCode = genericUtility.getColumnValue("cust_code",dom);
if (checkNextCol)
{
sqlCnt = "SELECT NVL(COUNT(*),0) FROM SITE WHERE SITE_CODE = '"+columnValue+"'";
......@@ -207,10 +280,10 @@ public class CustStock extends ValidatorEJB //implements SessionBean
{
if (rs.getInt(1)==0)
{
//errString = getErrorString("site_code","VTSITECD1",userId);
errString = getErrorString("site_code","VTSITECD1",userId);
//checkNextCol = false;
errString = itmDBAccess.getErrorString("site_code","VTSITECD1",userId,null,conn);
//errString = itmDBAccess.getErrorString("site_code","VTSITECD1",userId);//,null,conn);
break;
}
}
......@@ -233,10 +306,10 @@ public class CustStock extends ValidatorEJB //implements SessionBean
{
if (rs.getInt(1)==0)
{
//errString = getErrorString("site_code","VTSITECUST",userId);
errString = getErrorString("site_code","VTSITECUST",userId);
//checkNextCol = false;
errString = itmDBAccess.getErrorString("site_code","VTSITECUST",userId,null,conn);
//errString = itmDBAccess.getErrorString("site_code","VTSITECUST",userId);//,null,conn);
break;
}
}
......@@ -249,7 +322,7 @@ public class CustStock extends ValidatorEJB //implements SessionBean
}
//SHWETA 2/14/2005 --Not required at the time of validation
columnValue = getColumnValue("tran_id__last",dom);
columnValue = genericUtility.getColumnValue("tran_id__last",dom);
if (columnValue != null)
{
Statement stmt14 = null;
......@@ -291,11 +364,11 @@ public class CustStock extends ValidatorEJB //implements SessionBean
}
}
}
columnValue = getColumnValue("to_date",dom);
columnValue = genericUtility.getColumnValue("to_date",dom);
if (columnValue != null)
{
frdate1 = getColumnValue("from_date",dom);
tranDate1 = getColumnValue("tran_date",dom);
frdate1 = genericUtility.getColumnValue("from_date",dom);
tranDate1 = genericUtility.getColumnValue("tran_date",dom);
if (!columnValue.equals("") && checkNextCol)
{
frdate2 = getDateObject(frdate1);
......@@ -304,20 +377,22 @@ public class CustStock extends ValidatorEJB //implements SessionBean
if (todate.compareTo(frdate2) < 0)
{
//errCode = "VFRTODATE";
errString = itmDBAccess.getErrorString("to_date","VFRTODATE",userId,null,conn);
//errString = itmDBAccess.getErrorString("to_date","VFRTODATE",userId);//,null,conn);
errString = getErrorString("to_date","VFRTODATE",userId);//,null,conn);
break;
}
else if (tranDate2.compareTo(todate) < 0)
{
//errCode = "VTDATE9";
errString = itmDBAccess.getErrorString("to_date","VTDATE9",userId,null,conn);
//errString = itmDBAccess.getErrorString("to_date","VTDATE9",userId);//,null,conn);
errString = getErrorString("to_date","VTDATE9",userId);//,null,conn);
break;
}
else
{
custCode = getColumnValue("cust_code",dom);
siteCode = getColumnValue("site_code",dom);
itemSer = getColumnValue("item_ser",dom);
custCode = genericUtility.getColumnValue("cust_code",dom);
siteCode = genericUtility.getColumnValue("site_code",dom);
itemSer = genericUtility.getColumnValue("item_ser",dom);
if (itemSer.length() == 0)
{
selQueryBuff = new StringBuffer();
......@@ -344,7 +419,7 @@ public class CustStock extends ValidatorEJB //implements SessionBean
if (rs.getInt(1) > 0 && editFlag.equals("A"))
{
//errCode = "VTDUPREC";
errString = itmDBAccess.getErrorString("to_date","VTDUPREC",userId,null,conn);
errString = itmDBAccess.getErrorString("to_date","VTDUPREC",userId);//,null,conn);
break;
}
}
......@@ -375,13 +450,14 @@ public class CustStock extends ValidatorEJB //implements SessionBean
if (rs.getInt(1) == 0)
{
//errCode = "VTITMSER1";
errString = itmDBAccess.getErrorString("item_ser","VTITMSER1",userId,null,conn);
//errString = itmDBAccess.getErrorString("item_ser","VTITMSER1",userId);//,null,conn);
errString = getErrorString("item_ser","VTITMSER1",userId);//,null,conn);
break;
}
else
{
custCode = getColumnValue("cust_code",dom);
itemSer = getColumnValue("item_ser",dom);
custCode = genericUtility.getColumnValue("cust_code",dom);
itemSer = genericUtility.getColumnValue("item_ser",dom);
selQueryBuff = new StringBuffer();
selQueryBuff.append("SELECT NVL(COUNT(*),0) FROM CUSTOMER_SERIES WHERE CUST_CODE = '");
selQueryBuff.append(custCode).append("' AND ITEM_SER = '");
......@@ -394,7 +470,8 @@ public class CustStock extends ValidatorEJB //implements SessionBean
if (rs2.getInt(1) == 0)
{
//errCode = "VTITEMSER4";
errString = itmDBAccess.getErrorString("item_ser","VTITEMSER4",userId,null,conn);
//errString = itmDBAccess.getErrorString("item_ser","VTITEMSER4",userId);//,null,conn);
errString = getErrorString("item_ser","VTITEMSER4",userId);//,null,conn);
break;
}
}
......@@ -426,7 +503,7 @@ public class CustStock extends ValidatorEJB //implements SessionBean
errcode = 'VTINVSCHDT'
end if
end if*/
columnValue = getColumnValue("sch_date__1",dom);
columnValue = genericUtility.getColumnValue("sch_date__1",dom);
if(columnValue != null)
{
sdfFormat = new SimpleDateFormat(getApplDateFormat());
......@@ -434,11 +511,12 @@ public class CustStock extends ValidatorEJB //implements SessionBean
if ( schDate.compareTo(getDateObject(sdfFormat.format( new Date()))) < 0 )
{
//errCode = "VTINVSCHDT";
errString = itmDBAccess.getErrorString("sch_date__1","VTINVSCHDT",userId,null,conn);
//errString = itmDBAccess.getErrorString("sch_date__1","VTINVSCHDT",userId);//,null,conn);
errString = getErrorString("sch_date__1","VTINVSCHDT",userId);//,null,conn);
break;
}
}
columnValue = getColumnValue("sch_date__2",dom);
columnValue =genericUtility.getColumnValue("sch_date__2",dom);
if(columnValue != null)
{
sdfFormat = new SimpleDateFormat(getApplDateFormat());
......@@ -446,11 +524,12 @@ public class CustStock extends ValidatorEJB //implements SessionBean
if ( schDate2.compareTo(getDateObject(sdfFormat.format( new Date()))) < 0 )
{
//errCode = "VTINVSCHDT";
errString = itmDBAccess.getErrorString("sch_date__2","VTINVSCHDT",userId,null,conn);
//errString = itmDBAccess.getErrorString("sch_date__2","VTINVSCHDT",userId);//,null,conn);
errString = getErrorString("sch_date__2","VTINVSCHDT",userId);//,null,conn);
break;
}
}
columnValue = getColumnValue("sch_date__3",dom);
columnValue = genericUtility.getColumnValue("sch_date__3",dom);
if(columnValue != null)
{
sdfFormat = new SimpleDateFormat(getApplDateFormat());
......@@ -458,11 +537,12 @@ public class CustStock extends ValidatorEJB //implements SessionBean
if ( schDate3.compareTo(getDateObject(sdfFormat.format( new Date()))) < 0 )
{
//errCode = "VTINVSCHDT";
errString = itmDBAccess.getErrorString("sch_date__3","VTINVSCHDT",userId,null,conn);
//errString = itmDBAccess.getErrorString("sch_date__3","VTINVSCHDT",userId);//,null,conn);
errString = getErrorString("sch_date__3","VTINVSCHDT",userId);//,null,conn);
break;
}
}
columnValue = getColumnValue("sch_date__4",dom);
columnValue = genericUtility.getColumnValue("sch_date__4",dom);
if(columnValue != null)
{
sdfFormat = new SimpleDateFormat(getApplDateFormat());
......@@ -470,11 +550,12 @@ public class CustStock extends ValidatorEJB //implements SessionBean
if ( schDate4.compareTo(getDateObject(sdfFormat.format( new Date()))) < 0 )
{
//errCode = "VTINVSCHDT";
errString = itmDBAccess.getErrorString("sch_date__4","VTINVSCHDT",userId,null,conn);
//errString = itmDBAccess.getErrorString("sch_date__4","VTINVSCHDT",userId);//,null,conn);
errString = getErrorString("sch_date__4","VTINVSCHDT",userId);//,null,conn);
break;
}
}
columnValue = getColumnValue("sch_date__5",dom);
columnValue = genericUtility.getColumnValue("sch_date__5",dom);
if(columnValue != null)
{
sdfFormat = new SimpleDateFormat(getApplDateFormat());
......@@ -482,11 +563,12 @@ public class CustStock extends ValidatorEJB //implements SessionBean
if ( schDate5.compareTo(getDateObject(sdfFormat.format( new Date()))) < 0 )
{
//errCode = "VTINVSCHDT";
errString = itmDBAccess.getErrorString("sch_date__5","VTINVSCHDT",userId,null,conn);
//errString = itmDBAccess.getErrorString("sch_date__5","VTINVSCHDT",userId);//,null,conn);
errString = getErrorString("sch_date__5","VTINVSCHDT",userId);//,null,conn);
break;
}
}
columnValue = getColumnValue("sch_date__6",dom);
columnValue = genericUtility.getColumnValue("sch_date__6",dom);
if(columnValue != null)
{
sdfFormat = new SimpleDateFormat(getApplDateFormat());
......@@ -494,7 +576,8 @@ public class CustStock extends ValidatorEJB //implements SessionBean
if ( schDate6.compareTo(getDateObject(sdfFormat.format( new Date()))) < 0 )
{
//errCode = "VTINVSCHDT";
errString = itmDBAccess.getErrorString("sch_date__6","VTINVSCHDT",userId,null,conn);
//errString = itmDBAccess.getErrorString("sch_date__6","VTINVSCHDT",userId);//,null,conn);
errString = getErrorString("sch_date__6","VTINVSCHDT",userId);//,null,conn);
break;
}
}
......@@ -881,8 +964,8 @@ public class CustStock extends ValidatorEJB //implements SessionBean
double saless = 0;
double clStk = 0;
int currentFormNo = 0;
int mon = 0;
int days =0;
//int mon = 0;
//int days =0;
float rateValue = 0f;
String opValue = "";
......@@ -1218,12 +1301,13 @@ public class CustStock extends ValidatorEJB //implements SessionBean
else if (currentColumn.trim().equals("tran_date"))
{
tranDate = getColumnValue("tran_date",dom1);
System.out.println("tranDate---"+tranDate);
trnDate = getDateObject(tranDate);
Calendar calendar = new GregorianCalendar();
calendar.setTime(trnDate);
mon = calendar.get(Calendar.MONTH);
year = calendar.get(Calendar.YEAR);
//mon = calendar.get(Calendar.MONTH);
//year = calendar.get(Calendar.YEAR);
columnValue = genericUtility.getValidDateString( columnValue , getApplDateFormat() , "dd-MMM-yyyy" );
/* Commented By Chandni As Date is not setting Properly 19-Apr-2012
if (getApplDateFormat().equalsIgnoreCase("dd-MM-yyyy"))
{
if (mon <= 8)
......@@ -1272,10 +1356,25 @@ public class CustStock extends ValidatorEJB //implements SessionBean
else if (getApplDateFormat().equalsIgnoreCase("dd-MMM-yyyy"))
{
lastDate = days + "-" + tranDate.substring(3, 6) + "-" + year;
}
}*/
/* Commented By Chandni As Date is not setting Properly
valueXmlString.append("<tran_date>").append(lastDate).append("</tran_date>\r\n");
valueXmlString.append("<from_date>").append(firstDate).append("</from_date>\r\n");
valueXmlString.append("<to_date>").append(lastDate).append("</to_date>\r\n");
Comment Ended*/
//Added by chandni 19-Apr-2012
calendar.setTime(trnDate);
calendar.set(Calendar.DAY_OF_MONTH,1);
System.out.println("getApplDateFormat()----"+getApplDateFormat());
java.text.SimpleDateFormat dtf = new SimpleDateFormat( getApplDateFormat() );
valueXmlString.append("<from_date>").append(dtf.format( calendar.getTime() )).append("</from_date>\r\n");
int ld = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
calendar.set(Calendar.DAY_OF_MONTH,ld);
System.out.println("Date : " + calendar.getTime());
System.out.println("Last Date: " + lastDate);
valueXmlString.append("<tran_date>").append(dtf.format( calendar.getTime() )).append("</tran_date>\r\n");
valueXmlString.append("<to_date>").append(dtf.format( calendar.getTime() )).append("</to_date>\r\n");
/*select code into :ls_prd_code from period
where fr_date <= :ld_tran_date and to_date >= :ld_tran_date ;
dw_edit.setitem (1, "prd_code", ls_prd_code)*/
......
......@@ -1117,8 +1117,8 @@ public class CustStockItem extends ValidatorEJB //implements SessionBean
double saless = 0;
double clStk = 0;
int currentFormNo = 0;
int mon = 0;
int days =0;
//int mon = 0;
//int days =0;
float rateValue = 0f;
String opValue = "";
......@@ -1576,9 +1576,10 @@ public class CustStockItem extends ValidatorEJB //implements SessionBean
trnDate = getDateObject(tranDate);
Calendar calendar = new GregorianCalendar();
calendar.setTime(trnDate);
mon = calendar.get(Calendar.MONTH);
year = calendar.get(Calendar.YEAR);
//mon = calendar.get(Calendar.MONTH);
//year = calendar.get(Calendar.YEAR);
columnValue = genericUtility.getValidDateString( columnValue , getApplDateFormat() , "dd-MMM-yyyy" );
/* Commented By Chandni As Date is not setting Properly 19-Apr-2012
if (getApplDateFormat().equalsIgnoreCase("dd-MM-yyyy"))
{
if (mon <= 8)
......@@ -1628,9 +1629,26 @@ public class CustStockItem extends ValidatorEJB //implements SessionBean
{
lastDate = days + "-" + tranDate.substring(3, 6) + "-" + year;
}
*/
/* Commented By Chandni As Date is not setting Properly
valueXmlString.append("<tran_date>").append(lastDate).append("</tran_date>\r\n");
valueXmlString.append("<from_date>").append(firstDate).append("</from_date>\r\n");
valueXmlString.append("<to_date>").append(lastDate).append("</to_date>\r\n");
Comment Ended*/
//Added by chandni 19-Apr-2012
calendar.setTime(trnDate);
calendar.set(Calendar.DAY_OF_MONTH,1);
System.out.println("getApplDateFormat()----"+getApplDateFormat());
java.text.SimpleDateFormat dtf = new SimpleDateFormat( getApplDateFormat() );
valueXmlString.append("<from_date>").append(dtf.format( calendar.getTime() )).append("</from_date>\r\n");
int ld = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
calendar.set(Calendar.DAY_OF_MONTH,ld);
System.out.println("Date : " + calendar.getTime());
System.out.println("Last Date: " + lastDate);
valueXmlString.append("<tran_date>").append(dtf.format( calendar.getTime() )).append("</tran_date>\r\n");
valueXmlString.append("<to_date>").append(dtf.format( calendar.getTime() )).append("</to_date>\r\n");
/*select code into :ls_prd_code from period
where fr_date <= :ld_tran_date and to_date >= :ld_tran_date ;
dw_edit.setitem (1, "prd_code", ls_prd_code)*/
......
......@@ -11,6 +11,7 @@ import java.util.*;
import java.util.Date;
import java.sql.*;
import org.w3c.dom.*;
import javax.xml.parsers.*;
import javax.ejb.*;
import javax.naming.InitialContext;
......@@ -36,12 +37,13 @@ public class CustStock extends ValidatorEJB //implements SessionBean
{
}
*/
public String wfValData() throws RemoteException,ITMException
{
return "";
}
public String wfValData(String xmlString, String formNo, String editFlag) throws RemoteException,ITMException
// Commented by Chandni Shah 17-Apr-2012
/*public String wfValData(String xmlString, String formNo, String editFlag) throws RemoteException,ITMException
{
Document dom = null;
String errString = "";
......@@ -56,10 +58,69 @@ public class CustStock extends ValidatorEJB //implements SessionBean
}
errString = wfValData(dom, formNo, editFlag);
return (errString);
}*/
// Added by Chandni Shah 17-Apr-2012
public String wfValData(String xmlString, String xmlString1, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException
{
String errString = null;
Document dom = null;
Document dom1 = null;
Document dom2 = null;
try
{
//System.out.println("xmlString:-" + xmlString );
dom = parseString(xmlString);
dom1 = parseString(xmlString1);
errString = wfValData(dom,dom1,dom2,objContext,editFlag,xtraParams);
}
catch(Exception e)
{
//System.out.println("Exception : SOrderFormEJB : wfValData(String xmlString) : ==>\n"+e.getMessage());
throw new ITMException( e );
}
return (errString);
}
public String wfValData(String xmlString, String xmlString1,String xmlString2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException
{
String errString = null;
Document dom = null;
Document dom1 = null;
Document dom2 = null;
try
{
System.out.println("cHANDNI 11 xmlString:-" + xmlString );
System.out.println("cHANDNI 12 xmlString:-" + xmlString1 );
//long startTime = System.currentTimeMillis();
dom = parseString(xmlString);
dom1 = parseString(xmlString1);
System.out.println("Chandni 13 dom"+dom);
System.out.println("Chandni 14 dom"+dom1);
if (xmlString2.trim().length() > 0 )
{
dom2 = parseString("<Root>" + xmlString2+ "</Root>");
}
System.out.println("Chandni 15 dom"+dom2);
//long endTime = System.currentTimeMillis();
//long totalTime = endTime - startTime;
//System.out.println(xmlString2);
//System.out.println("start Time Spend :: "+startTime+" Milliseconds");
//System.out.println("End Time Spend :: "+endTime+" Milliseconds");
//System.out.println("Total Time Spend :: "+totalTime+" Milliseconds");
public String wfValData(Document dom, String formNo, String editFlag) throws RemoteException,ITMException
errString = wfValData(dom,dom1,dom2,objContext,editFlag,xtraParams);
}
catch(Exception e)
{
//System.out.println("Exception : SOrderFormEJB : wfValData(String xmlString) : ==>\n"+e.getMessage());
throw new ITMException( e );
}
return (errString);
}
// Commented by Chandni Shah 17-Apr-2012
//public String wfValData(Document dom, String formNo, String editFlag) throws RemoteException,ITMException
public String wfValData(Document dom, Document dom1,Document dom2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException
{
// Added by Chandni Shah 17-Apr-2012
boolean checkNextCol = true;
String columnName = "";
String columnValue = "";
......@@ -101,51 +162,61 @@ public class CustStock extends ValidatorEJB //implements SessionBean
try
{
System.out.println("CustStockEJB validation");
AppConnectParm appConnect = new AppConnectParm();
//System.out.println("CustStockEJB validation");
/*AppConnectParm appConnect = new AppConnectParm();
Properties p = appConnect.getProperty();
InitialContext ctx = new InitialContext(p);
itmDBAccess = (ITMDBAccessLocal)ctx.lookup("ibase/ITMDBAccessEJB/local");
*/
//itmDBAccess = itmDBAccessHome.create();
ibase.webitm.utility.GenericUtility genericUtility = new ibase.webitm.utility.GenericUtility();
conn = getConnection();
userId = getColumnValue( "user_id", dom );
currentFormNo = Integer.parseInt( formNo );
userId = genericUtility.getColumnValue( "user_id", dom );
//currentFormNo = Integer.parseInt( formNo );
currentFormNo = Integer.parseInt( objContext ); // Added by Chandni Shah 17-Apr-2012
switch ( currentFormNo )
{
case 1:
columnValue = getColumnValue( "tran_date", dom );
System.out.println("currentFormNo:::"+currentFormNo);
columnValue = genericUtility.getColumnValue("tran_date", dom );
System.out.println("columnValue 11:"+columnValue);
if(columnValue != null)
{
siteCode = getColumnValue( "site_code", dom );
siteCode = genericUtility.getColumnValue( "site_code", dom );
System.out.println("columnValue 12:"+columnValue+"_and checkNextCol:"+checkNextCol);
if ( columnValue.length() != 0 && checkNextCol )
{
System.out.println("inside columnValue:::");
errCode = nfCheckPeriod("SAL",getDateObject(columnValue),siteCode);
if (errCode.length() != 0)
{
System.out.println("errCode k ander");
//errString = getErrorString("",errCode,userId);
//checkNextCol = false;
errString = itmDBAccess.getErrorString("tran_date",errCode,userId,null,conn);
//errString = itmDBAccess.getErrorString("tran_date",errCode,userId);//,null,conn);
errString = getErrorString("tran_date",errCode,userId);//,null,conn); // Change by Chandni Shah 17-Apr-2012
break;
}
}
}
columnValue = getColumnValue("cust_code",dom);
//columnValue = getColumnValue("cust_code",dom);
columnValue = genericUtility.getColumnValue("cust_code",dom); // Change by Chandni Shah 17-Apr-2012
if(columnValue != null)
{
siteCode = getColumnValue("site_code",dom);
//siteCode = getColumnValue("site_code",dom);
siteCode = genericUtility.getColumnValue("site_code",dom);
System.out.println("siteCode [" +siteCode+ "]");
tranDate = getColumnValue("tran_date",dom);
tranDate = genericUtility.getColumnValue("tran_date",dom);
if (columnValue.length() != 0 && checkNextCol)
{
errCode = isCustomer(siteCode,columnValue,"S-CSTK",conn);
System.out.println("errCode [" +errCode+ "]");
if (errCode.length() !=0 )
{
//errString = getErrorString("cust_code",errCode,userId);
errString = getErrorString("cust_code",errCode,userId);
//checkNextCol = false;
errString = itmDBAccess.getErrorString("cust_code",errCode,userId,null,conn);
//errString = itmDBAccess.getErrorString("cust_code",errCode,userId);//,null,conn);
break;
}
}
......@@ -162,20 +233,20 @@ public class CustStock extends ValidatorEJB //implements SessionBean
{
if (rs.getInt(1) == 0)
{
//errString = getErrorString("cust_code","VTSITECUST",userId);
errString = getErrorString("cust_code","VTSITECUST",userId);
//checkNextCol = false;
errString = itmDBAccess.getErrorString("cust_code","VTSITECUST",userId,null,conn);
//errString = itmDBAccess.getErrorString("cust_code","VTSITECUST",userId);//,null,conn);
break;
}
}
}
else
{
/*Select count(1) into :cnt
/* Select count(1) into :cnt
From customer
Where cust_code = :mval
And (case when channel_partner is null then 'N' else channel_partner end ) = 'N';
If cnt = 0 Then errcode = "VTCUST"*/
If cnt = 0 Then errcode = "VTCUST" */
sqlCnt = "SELECT COUNT(1) COUNT FROM CUSTOMER WHERE CUST_CODE = '" + columnValue + "' And (CASE WHEN CHANNEL_PARTNER IS NULL THEN 'N' ELSE CHANNEL_PARTNER END ) = 'N'";
System.out.println("sql :\n"+sqlCnt);
stmt = conn.createStatement();
......@@ -183,7 +254,8 @@ public class CustStock extends ValidatorEJB //implements SessionBean
if (rs.next() && rs.getInt( "COUNT" ) == 0)
{
//errCode = "VTCUST";
errString = itmDBAccess.getErrorString("cust_code","VTCUST",userId,null,conn);
//errString = itmDBAccess.getErrorString("cust_code","VTCUST",userId);//,null,conn);
errString = getErrorString("cust_code","VTCUST",userId);//,null,conn);
break;
}
}
......@@ -193,10 +265,11 @@ public class CustStock extends ValidatorEJB //implements SessionBean
stmt = null;
}
}
columnValue = getColumnValue("site_code",dom);
//columnValue = getColumnValue("site_code",dom);
columnValue = genericUtility.getColumnValue("site_code",dom);
if(columnValue != null)
{
custCode = getColumnValue("cust_code",dom);
custCode = genericUtility.getColumnValue("cust_code",dom);
if (checkNextCol)
{
sqlCnt = "SELECT NVL(COUNT(*),0) FROM SITE WHERE SITE_CODE = '"+columnValue+"'";
......@@ -207,10 +280,10 @@ public class CustStock extends ValidatorEJB //implements SessionBean
{
if (rs.getInt(1)==0)
{
//errString = getErrorString("site_code","VTSITECD1",userId);
errString = getErrorString("site_code","VTSITECD1",userId);
//checkNextCol = false;
errString = itmDBAccess.getErrorString("site_code","VTSITECD1",userId,null,conn);
//errString = itmDBAccess.getErrorString("site_code","VTSITECD1",userId);//,null,conn);
break;
}
}
......@@ -233,10 +306,10 @@ public class CustStock extends ValidatorEJB //implements SessionBean
{
if (rs.getInt(1)==0)
{
//errString = getErrorString("site_code","VTSITECUST",userId);
errString = getErrorString("site_code","VTSITECUST",userId);
//checkNextCol = false;
errString = itmDBAccess.getErrorString("site_code","VTSITECUST",userId,null,conn);
//errString = itmDBAccess.getErrorString("site_code","VTSITECUST",userId);//,null,conn);
break;
}
}
......@@ -249,7 +322,7 @@ public class CustStock extends ValidatorEJB //implements SessionBean
}
//SHWETA 2/14/2005 --Not required at the time of validation
columnValue = getColumnValue("tran_id__last",dom);
columnValue = genericUtility.getColumnValue("tran_id__last",dom);
if (columnValue != null)
{
Statement stmt14 = null;
......@@ -291,11 +364,11 @@ public class CustStock extends ValidatorEJB //implements SessionBean
}
}
}
columnValue = getColumnValue("to_date",dom);
columnValue = genericUtility.getColumnValue("to_date",dom);
if (columnValue != null)
{
frdate1 = getColumnValue("from_date",dom);
tranDate1 = getColumnValue("tran_date",dom);
frdate1 = genericUtility.getColumnValue("from_date",dom);
tranDate1 = genericUtility.getColumnValue("tran_date",dom);
if (!columnValue.equals("") && checkNextCol)
{
frdate2 = getDateObject(frdate1);
......@@ -304,20 +377,22 @@ public class CustStock extends ValidatorEJB //implements SessionBean
if (todate.compareTo(frdate2) < 0)
{
//errCode = "VFRTODATE";
errString = itmDBAccess.getErrorString("to_date","VFRTODATE",userId,null,conn);
//errString = itmDBAccess.getErrorString("to_date","VFRTODATE",userId);//,null,conn);
errString = getErrorString("to_date","VFRTODATE",userId);//,null,conn);
break;
}
else if (tranDate2.compareTo(todate) < 0)
{
//errCode = "VTDATE9";
errString = itmDBAccess.getErrorString("to_date","VTDATE9",userId,null,conn);
//errString = itmDBAccess.getErrorString("to_date","VTDATE9",userId);//,null,conn);
errString = getErrorString("to_date","VTDATE9",userId);//,null,conn);
break;
}
else
{
custCode = getColumnValue("cust_code",dom);
siteCode = getColumnValue("site_code",dom);
itemSer = getColumnValue("item_ser",dom);
custCode = genericUtility.getColumnValue("cust_code",dom);
siteCode = genericUtility.getColumnValue("site_code",dom);
itemSer = genericUtility.getColumnValue("item_ser",dom);
if (itemSer.length() == 0)
{
selQueryBuff = new StringBuffer();
......@@ -344,7 +419,7 @@ public class CustStock extends ValidatorEJB //implements SessionBean
if (rs.getInt(1) > 0 && editFlag.equals("A"))
{
//errCode = "VTDUPREC";
errString = itmDBAccess.getErrorString("to_date","VTDUPREC",userId,null,conn);
errString = itmDBAccess.getErrorString("to_date","VTDUPREC",userId);//,null,conn);
break;
}
}
......@@ -375,13 +450,14 @@ public class CustStock extends ValidatorEJB //implements SessionBean
if (rs.getInt(1) == 0)
{
//errCode = "VTITMSER1";
errString = itmDBAccess.getErrorString("item_ser","VTITMSER1",userId,null,conn);
//errString = itmDBAccess.getErrorString("item_ser","VTITMSER1",userId);//,null,conn);
errString = getErrorString("item_ser","VTITMSER1",userId);//,null,conn);
break;
}
else
{
custCode = getColumnValue("cust_code",dom);
itemSer = getColumnValue("item_ser",dom);
custCode = genericUtility.getColumnValue("cust_code",dom);
itemSer = genericUtility.getColumnValue("item_ser",dom);
selQueryBuff = new StringBuffer();
selQueryBuff.append("SELECT NVL(COUNT(*),0) FROM CUSTOMER_SERIES WHERE CUST_CODE = '");
selQueryBuff.append(custCode).append("' AND ITEM_SER = '");
......@@ -394,7 +470,8 @@ public class CustStock extends ValidatorEJB //implements SessionBean
if (rs2.getInt(1) == 0)
{
//errCode = "VTITEMSER4";
errString = itmDBAccess.getErrorString("item_ser","VTITEMSER4",userId,null,conn);
//errString = itmDBAccess.getErrorString("item_ser","VTITEMSER4",userId);//,null,conn);
errString = getErrorString("item_ser","VTITEMSER4",userId);//,null,conn);
break;
}
}
......@@ -426,7 +503,7 @@ public class CustStock extends ValidatorEJB //implements SessionBean
errcode = 'VTINVSCHDT'
end if
end if*/
columnValue = getColumnValue("sch_date__1",dom);
columnValue = genericUtility.getColumnValue("sch_date__1",dom);
if(columnValue != null)
{
sdfFormat = new SimpleDateFormat(getApplDateFormat());
......@@ -434,11 +511,12 @@ public class CustStock extends ValidatorEJB //implements SessionBean
if ( schDate.compareTo(getDateObject(sdfFormat.format( new Date()))) < 0 )
{
//errCode = "VTINVSCHDT";
errString = itmDBAccess.getErrorString("sch_date__1","VTINVSCHDT",userId,null,conn);
//errString = itmDBAccess.getErrorString("sch_date__1","VTINVSCHDT",userId);//,null,conn);
errString = getErrorString("sch_date__1","VTINVSCHDT",userId);//,null,conn);
break;
}
}
columnValue = getColumnValue("sch_date__2",dom);
columnValue =genericUtility.getColumnValue("sch_date__2",dom);
if(columnValue != null)
{
sdfFormat = new SimpleDateFormat(getApplDateFormat());
......@@ -446,11 +524,12 @@ public class CustStock extends ValidatorEJB //implements SessionBean
if ( schDate2.compareTo(getDateObject(sdfFormat.format( new Date()))) < 0 )
{
//errCode = "VTINVSCHDT";
errString = itmDBAccess.getErrorString("sch_date__2","VTINVSCHDT",userId,null,conn);
//errString = itmDBAccess.getErrorString("sch_date__2","VTINVSCHDT",userId);//,null,conn);
errString = getErrorString("sch_date__2","VTINVSCHDT",userId);//,null,conn);
break;
}
}
columnValue = getColumnValue("sch_date__3",dom);
columnValue = genericUtility.getColumnValue("sch_date__3",dom);
if(columnValue != null)
{
sdfFormat = new SimpleDateFormat(getApplDateFormat());
......@@ -458,11 +537,12 @@ public class CustStock extends ValidatorEJB //implements SessionBean
if ( schDate3.compareTo(getDateObject(sdfFormat.format( new Date()))) < 0 )
{
//errCode = "VTINVSCHDT";
errString = itmDBAccess.getErrorString("sch_date__3","VTINVSCHDT",userId,null,conn);
//errString = itmDBAccess.getErrorString("sch_date__3","VTINVSCHDT",userId);//,null,conn);
errString = getErrorString("sch_date__3","VTINVSCHDT",userId);//,null,conn);
break;
}
}
columnValue = getColumnValue("sch_date__4",dom);
columnValue = genericUtility.getColumnValue("sch_date__4",dom);
if(columnValue != null)
{
sdfFormat = new SimpleDateFormat(getApplDateFormat());
......@@ -470,11 +550,12 @@ public class CustStock extends ValidatorEJB //implements SessionBean
if ( schDate4.compareTo(getDateObject(sdfFormat.format( new Date()))) < 0 )
{
//errCode = "VTINVSCHDT";
errString = itmDBAccess.getErrorString("sch_date__4","VTINVSCHDT",userId,null,conn);
//errString = itmDBAccess.getErrorString("sch_date__4","VTINVSCHDT",userId);//,null,conn);
errString = getErrorString("sch_date__4","VTINVSCHDT",userId);//,null,conn);
break;
}
}
columnValue = getColumnValue("sch_date__5",dom);
columnValue = genericUtility.getColumnValue("sch_date__5",dom);
if(columnValue != null)
{
sdfFormat = new SimpleDateFormat(getApplDateFormat());
......@@ -482,11 +563,12 @@ public class CustStock extends ValidatorEJB //implements SessionBean
if ( schDate5.compareTo(getDateObject(sdfFormat.format( new Date()))) < 0 )
{
//errCode = "VTINVSCHDT";
errString = itmDBAccess.getErrorString("sch_date__5","VTINVSCHDT",userId,null,conn);
//errString = itmDBAccess.getErrorString("sch_date__5","VTINVSCHDT",userId);//,null,conn);
errString = getErrorString("sch_date__5","VTINVSCHDT",userId);//,null,conn);
break;
}
}
columnValue = getColumnValue("sch_date__6",dom);
columnValue = genericUtility.getColumnValue("sch_date__6",dom);
if(columnValue != null)
{
sdfFormat = new SimpleDateFormat(getApplDateFormat());
......@@ -494,7 +576,8 @@ public class CustStock extends ValidatorEJB //implements SessionBean
if ( schDate6.compareTo(getDateObject(sdfFormat.format( new Date()))) < 0 )
{
//errCode = "VTINVSCHDT";
errString = itmDBAccess.getErrorString("sch_date__6","VTINVSCHDT",userId,null,conn);
//errString = itmDBAccess.getErrorString("sch_date__6","VTINVSCHDT",userId);//,null,conn);
errString = getErrorString("sch_date__6","VTINVSCHDT",userId);//,null,conn);
break;
}
}
......@@ -881,8 +964,8 @@ public class CustStock extends ValidatorEJB //implements SessionBean
double saless = 0;
double clStk = 0;
int currentFormNo = 0;
int mon = 0;
int days =0;
//int mon = 0;
//int days =0;
float rateValue = 0f;
String opValue = "";
......@@ -1218,12 +1301,13 @@ public class CustStock extends ValidatorEJB //implements SessionBean
else if (currentColumn.trim().equals("tran_date"))
{
tranDate = getColumnValue("tran_date",dom1);
System.out.println("tranDate---"+tranDate);
trnDate = getDateObject(tranDate);
Calendar calendar = new GregorianCalendar();
calendar.setTime(trnDate);
mon = calendar.get(Calendar.MONTH);
year = calendar.get(Calendar.YEAR);
//mon = calendar.get(Calendar.MONTH);
//year = calendar.get(Calendar.YEAR);
columnValue = genericUtility.getValidDateString( columnValue , getApplDateFormat() , "dd-MMM-yyyy" );
/* Commented By Chandni As Date is not setting Properly 19-Apr-2012
if (getApplDateFormat().equalsIgnoreCase("dd-MM-yyyy"))
{
if (mon <= 8)
......@@ -1272,10 +1356,25 @@ public class CustStock extends ValidatorEJB //implements SessionBean
else if (getApplDateFormat().equalsIgnoreCase("dd-MMM-yyyy"))
{
lastDate = days + "-" + tranDate.substring(3, 6) + "-" + year;
}
}*/
/* Commented By Chandni As Date is not setting Properly
valueXmlString.append("<tran_date>").append(lastDate).append("</tran_date>\r\n");
valueXmlString.append("<from_date>").append(firstDate).append("</from_date>\r\n");
valueXmlString.append("<to_date>").append(lastDate).append("</to_date>\r\n");
Comment Ended*/
//Added by chandni 19-Apr-2012
calendar.setTime(trnDate);
calendar.set(Calendar.DAY_OF_MONTH,1);
System.out.println("getApplDateFormat()----"+getApplDateFormat());
java.text.SimpleDateFormat dtf = new SimpleDateFormat( getApplDateFormat() );
valueXmlString.append("<from_date>").append(dtf.format( calendar.getTime() )).append("</from_date>\r\n");
int ld = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
calendar.set(Calendar.DAY_OF_MONTH,ld);
System.out.println("Date : " + calendar.getTime());
System.out.println("Last Date: " + lastDate);
valueXmlString.append("<tran_date>").append(dtf.format( calendar.getTime() )).append("</tran_date>\r\n");
valueXmlString.append("<to_date>").append(dtf.format( calendar.getTime() )).append("</to_date>\r\n");
/*select code into :ls_prd_code from period
where fr_date <= :ld_tran_date and to_date >= :ld_tran_date ;
dw_edit.setitem (1, "prd_code", ls_prd_code)*/
......
......@@ -1117,8 +1117,8 @@ public class CustStockItem extends ValidatorEJB //implements SessionBean
double saless = 0;
double clStk = 0;
int currentFormNo = 0;
int mon = 0;
int days =0;
//int mon = 0;
//int days =0;
float rateValue = 0f;
String opValue = "";
......@@ -1576,9 +1576,10 @@ public class CustStockItem extends ValidatorEJB //implements SessionBean
trnDate = getDateObject(tranDate);
Calendar calendar = new GregorianCalendar();
calendar.setTime(trnDate);
mon = calendar.get(Calendar.MONTH);
year = calendar.get(Calendar.YEAR);
//mon = calendar.get(Calendar.MONTH);
//year = calendar.get(Calendar.YEAR);
columnValue = genericUtility.getValidDateString( columnValue , getApplDateFormat() , "dd-MMM-yyyy" );
/* Commented By Chandni As Date is not setting Properly 19-Apr-2012
if (getApplDateFormat().equalsIgnoreCase("dd-MM-yyyy"))
{
if (mon <= 8)
......@@ -1628,9 +1629,26 @@ public class CustStockItem extends ValidatorEJB //implements SessionBean
{
lastDate = days + "-" + tranDate.substring(3, 6) + "-" + year;
}
*/
/* Commented By Chandni As Date is not setting Properly
valueXmlString.append("<tran_date>").append(lastDate).append("</tran_date>\r\n");
valueXmlString.append("<from_date>").append(firstDate).append("</from_date>\r\n");
valueXmlString.append("<to_date>").append(lastDate).append("</to_date>\r\n");
Comment Ended*/
//Added by chandni 19-Apr-2012
calendar.setTime(trnDate);
calendar.set(Calendar.DAY_OF_MONTH,1);
System.out.println("getApplDateFormat()----"+getApplDateFormat());
java.text.SimpleDateFormat dtf = new SimpleDateFormat( getApplDateFormat() );
valueXmlString.append("<from_date>").append(dtf.format( calendar.getTime() )).append("</from_date>\r\n");
int ld = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
calendar.set(Calendar.DAY_OF_MONTH,ld);
System.out.println("Date : " + calendar.getTime());
System.out.println("Last Date: " + lastDate);
valueXmlString.append("<tran_date>").append(dtf.format( calendar.getTime() )).append("</tran_date>\r\n");
valueXmlString.append("<to_date>").append(dtf.format( calendar.getTime() )).append("</to_date>\r\n");
/*select code into :ls_prd_code from period
where fr_date <= :ld_tran_date and to_date >= :ld_tran_date ;
dw_edit.setitem (1, "prd_code", ls_prd_code)*/
......
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