按 asp.net 划分的账单详细信息



大家好,我刚刚开始学习 asp.net。现在我正在尝试开发带有sql数据库的计费软件。我想知道如何以网格视图格式计算产品的总和总计。

并且还想知道将产品数量乘以其奖品。

帮助只是在我的项目中添加一些代码

如果你的意思是SQL语句,也许可能是这样的:

计算每个售出产品的小计

select product.name [item], 
       product.price [price], 
       order.quantity [quantity], 
       product.price*order.quantity [subtotal]
from product p, order o
where o.ProductId = p.ProductId
and o.OrderId = @orderId

计算每个订单的总价可能是这样的:

select o.orderId, sum(product.price*order.quantity)
from order o, product p
group by order.OrderId
and o.ProductId=p.ProductId

此查询的结果可以发送到如下所示的网格:

myGrid.DataSource= myDataSet;  //dataset that returned the results

相关内容

最新更新