I have a list of objects (Invoices). these objects have a qty property.
I have a product return form which has a qty for the product being returned.
When the return line is submitted. I populate a gridview with the submitted line so another part can be entered if needed before submitting the entire returns form.
When the line is submitted, I need the return qty to be subtracted from the invoiced qty in the object… I’ve done this using the following code…
returnInvoices[GridView3.SelectedIndex].OrderLineQty = returnInvoices[GridView3.SelectedIndex].OrderLineQty - Convert.ToDouble(txtReturnProdQty.Text, userCulture);
returnInvoices is a reference to the List<Invoice> and OrderLineQty is a double datatype.
I was just wondering if there’s a better (tidier?) way of subtracting the invoiced qty?
The reason for the subtraction if because if the invoiced line is greater than 1 but the part is serialized, the part must be entered one at a time, so I need the qty to decrease as they are added to the return form, so that they can’t over return, if that makes sense!
please be gentle… i’m new and still learning c#/OOP!
thanks 🙂
Use the -= operator:
See http://msdn.microsoft.com/en-us/library/6a71f45d(v=vs.110).aspx for a list of all available operators.