How To Show Error Message In Linq C#

Dec 3 2015 7:53 AM
Below Is Code for my requirement
I wanna display error message if received amount is greater than total amount using LinQ query



var invoiceInfo = from invoice in InvoiceData
if(invoice.ReceivedAmount>invoice.TotalAmount)
MessageBox.Show("You Have Entered More Amount Than Invoice Amount")
else
select new InvoiceMaster
{
InvoiceId = invoice.InvoiceId,
InvoiceNumber = invoice.InvoiceNumber,
InvoiceDate = invoice.InvoiceDate,
TotalAmount = invoice.TotalAmount,
ReceivedAmount = invoice.ReceivedAmount

}

Answers (3)