Dear Mr. Dharmendra Das,
Thank you for your reply.
I inform you that this Discount has a discount on the product while DiscountTotal is a reduction for the total. So it's different
In your answer there is no report parameter.
Total
=Sum((Fields!UnitPrice.Value * Fields!Quantity.Value), "DataSet1") - Sum((Fields!Discount.Value * Fields!Quantity.Value), "DataSet1")
Discount Total
=Parameters!pDiscountTotal.Value
Retur Total
=Parameters!pReturTotal.Value
Total Net
for expression is not yet appropriate
You can see the results in this sharing link :
Capture12-07-2024
should the result be : 550-(100+200) = 250
=Sum((Fields!UnitPrice.Value * Fields!Quantity.Value), "DataSet1") - Sum((Fields!Discount.Value * Fields!Quantity.Value), "DataSet1")-(Parameters!pDiscountTotal.Value+Parameters!pReturTotal.Value)
Code
Private Sub Form1_Load(sender As Object, e As System.EventArgs) Handles MyBase.Load
Dim order = OrderBusiness.GetOrder()
Me.OrderDetailBindingSource.DataSource = order.OrderDetails
Dim datasource As New ReportDataSource("DataSet1", Me.OrderDetailBindingSource)
Me.ReportViewer1.LocalReport.DataSources.Add(datasource)
Dim p() As Microsoft.Reporting.WinForms.ReportParameter = {
New Microsoft.Reporting.WinForms.ReportParameter("pDiscountTotal", order.DiscountTotal.ToString()),
New Microsoft.Reporting.WinForms.ReportParameter("pReturTotal", order.ReturTotal.ToString())
}
Me.ReportViewer1.LocalReport.SetParameters(p)
Me.ReportViewer1.RefreshReport()
End Sub
Public Class Order
Public Property CustomerName As String
Public Property DiscountTotal As Integer
Public Property ReturTotal As Integer
Public Property OrderDetails As List(Of OrderDetail)
End Class
Public Class OrderDetail
Public Property ProductName As String
Public Property UnitPrice As Integer
Public Property Quantity As Integer
Public Property Discount As Integer
End Class
Public Class OrderBusiness
Public Shared Function GetOrder() As Order
Return New Order() With {
.CustomerName = "John Doe",
.DiscountTotal = 100,
.ReturTotal = 200,
.OrderDetails = New List(Of OrderDetail)() From {
New OrderDetail() With {
.ProductName = "Foo",
.UnitPrice = 100,
.Quantity = 1,
.Discount = 0
},
New OrderDetail() With {
.ProductName = "Bar",
.UnitPrice = 200,
.Quantity = 2,
.Discount = 50
},
New OrderDetail() With {
.ProductName = "Baz",
.UnitPrice = 50,
.Quantity = 3,
.Discount = 0
}
}
}
End Function
End Class