Dear Sir,
I'm Trying to make calculations in expression for value in Report Viewer/Rdlc in vb.net but Result do not match in VB.NET
I use an expression like this:
=SUM(Fields!UnitPrice.Value * Fields!Quantity.Value - Fields!Discount.Value)-(Parameters!pDiscountTotal.Value+Parameters!pReturTotal.Value)
Is there anything wrong with the code ?
Please Guide me
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
Partial Public Class Form1
Inherits Form
Public Sub New()
InitializeComponent()
End Sub
Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
Dim order = OrderBusiness.GetOrder()
Me.OrderBindingSource.DataSource = order
Me.OrderDetailBindingSource.DataSource = order.OrderDetails
Dim p() As Microsoft.Reporting.WinForms.ReportParameter = {
New Microsoft.Reporting.WinForms.ReportParameter("pCustomerName", order.CustomerName.ToString()),
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
End Class
result from code
Link image result code in report viewer
Desired result
sum(Price*Quantity-Discount)-(DiscountTotal+ReturTotal)
=600-(100+200)
TOTAL NET : 300
Thanks