1

我有两个名为arraylist1arraaylist2的数组列表。

Arraylist1 having fileds instock,Productcode,productname,batchnNo,saledQty,discount and amount, Which stores values from database table named ProductDetails.

Arraylist2 having fields Productcode,minQuantity,maxQuantity,discount,discountType, which stores values from different table  named DiscountDetails.

我们需要 根据productcode比较arraylist1 和 arraylist2 。如果产品代码相同,那么我需要检查 来自 arraylist1 的特定产品代码的 saledQty,我们需要检查天气它将落在 arraylist2 的 minQuantity 和 maxQuantity 之间的范围内。(最小数量<=销售数量<=最大数量

如果它落在 minQuantity 和 maxQuantity 的范围之间,我们需要从arraylist2中获取该特定 productCode 的折扣,并且我们需要将其显示在arraylist1中该特定代码的折扣列的位置。

任何人都可以帮助我..提前谢谢。

4

1 回答 1

1

您是否尝试在数据库 SQL 查询端解决此问题。这可以很容易地放入 sql 查询中。

编辑以回应否决:

试试这个 SQL,而不是处理两个列表。如果saledqty介于 min 和 max 之间,这将给出所有带有折扣代码的产品,否则给出 product.discount 是什么。

select p.instock, p.Productcode, p.productname, p.batchnNo, p.saledQty, p.amount, 
        isnull(d.discount, p.discount)
from 
    ProductDetails p
left join 
        DiscountDetails d on p.Productcode = d.Productcode 
        and p.saledQty between d.minQuantity and d.maxQuantity

如果只对具有有效折扣的产品感兴趣,则将left join(外连接)更改为join(内连接)。

于 2013-06-19T11:39:11.857 回答