if(!CVUtility.isModuleVisible("Promotion",promotionID, this.dataSource))
throw new AuthorizationFailedException("Promotion - getItemLines");
*/
CVDal cvdl = new CVDal(dataSource);
cvdl.clearParameters();
ItemLines itemlineslist = new ItemLines();
try
{
Integer startATparam = (Integer) info.get( "startATparam" ) ;
Integer EndAtparam = (Integer) info.get( "EndAtparam" ) ;
String searchString = (String) info.get( "searchString" ) ;
String sortmem = (String) info.get( "sortmem" ) ;
Character chr = ( Character ) info.get( "sortType" ) ;
char sorttype = chr.charValue();
int startat = startATparam.intValue();
int endat = EndAtparam.intValue();
int beginindex = Math.max( startat- 100 , 1 ) ;
int endindex = endat + 100 ;
itemlineslist.setSortMember( sortmem );
String strSQL = "";
String appendStr = "";
if ( sorttype == 'A' )
{
strSQL = "select * from `promoitem` pi , `item` i where PromotionID ="+promotionID + " and pi.itemid = i.itemid order by "+ sortmem + " limit "+(beginindex-1) +" , "+ (endindex+1) +";" ;
}else
{
strSQL = "select * from `promoitem` pi , `item` i where PromotionID ="+promotionID +" and pi.itemid = i.itemid order by "+ sortmem + " desc limit "+(beginindex-1) +" , "+ (endindex+1) +";" ;
}
cvdl.setSqlQuery( strSQL );
Collection col = cvdl.executeQuery();
Iterator it = col.iterator();
int i=0 ;
int count=0 ;
while( it.hasNext() )
{
i++;
count++;
HashMap hm = ( HashMap )it.next();
promotionID = ((Long)hm.get("PromotionID")).intValue();
int ItemID = ((Long)hm.get("ItemID")).intValue();
int Quantity = ((Long)hm.get("Quantity")).intValue();
float price = ((Number)hm.get("Price")).floatValue();
float lprice = 0.0f;
if (hm.get("listprice") != null ){
lprice = ((Number )hm.get("listprice")).floatValue();
}
float costprice = 0.0f;
if (hm.get("cost") != null ){
costprice = ((Number )hm.get("cost")).floatValue();
}
IntMember lineid = new IntMember( "LineId" , count , 10 , "URL", 'T' , false , 10 );
StringMember desc = new StringMember( "Description", (String) hm.get( "description" ) ,10 , "", 'T' , true );
StringMember sku = new StringMember( "SKU", (String) hm.get( "sku" ) ,10 , "", 'T' , true );
IntMember one = new IntMember( "PromotionID" , promotionID , 10 , "URL", 'T' , false , 10 );
IntMember two = new IntMember( "ItemID" , ItemID , 10 , "URL", 'T' , false , 10 );
IntMember three = new IntMember( "Quantity" , Quantity , 10 , "URL", 'T' , false , 10 );
StringMember Rule = new StringMember( "Rule", (String) hm.get( "Rule" ) ,10 , "", 'T' , true );
FloatMember four = new FloatMember ( "Price" , new Float( price ) , 10 , "", 'T' , true , 10 );
FloatMember listprice = new FloatMember ( "ListPrice" , new Float( lprice ) , 10 , "", 'T' , true , 10 );
FloatMember cost = new FloatMember ( "Cost" , new Float( costprice ) , 10 , "", 'T' , true , 10 );
ItemElement ele = new ItemElement( promotionID );
ele.put("LineId", lineid );
ele.put("PromotionID", one );
ele.put("ItemId", two );
ele.put("Value" , three );// Quantity
ele.put("Type" , Rule );//Rule
ele.put("DiscountedPrice" , four );//Price
ele.put("Description" , desc );//Desc
ele.put("SKU" , sku );//SKU
ele.put("ListPrice" , listprice );//ListPrice
ele.put("Cost" , cost );//Cost
StringBuffer sb = new StringBuffer("00000000000");
sb.setLength(11);
String str = (new Integer(i)).toString();
sb.replace((sb.length()-str.length()),(sb.length()),str);
String newOrd = sb.toString();
itemlineslist.put( newOrd , ele );
itemlineslist.setListType( "PromotionItem" );
cvdl.clearParameters();
cvdl.destroy();
}
}