Stock Update

Stock Update

Hello,
I have an application where i want to update the stock.
Data is as follows:
Design No.:      Shade No.:      Quantity:
56459               250                  35.00
56459               250                  35.00
56459               250                  35.00

Now i want to dispatch 35.00 meters and it should update the record as follows:
Data is not supposed to be deleted

Design No.:      Shade No.:      Quantity:
56459               250                  35.00
56459               250                  35.00
56459               250                  0.00

Code as follows:
  1. if(Outward_Type == "Fabric")
  2. {
  3. for each  rec_Fab in Fabric
  4. {
  5. Fabric_Obj = Fabric_Stock_Master[Shade_No == input.Fabric.Shade_No];
  6. for each  rec_Fab_Obj in Fabric_Obj
  7. {
  8. if(rec_Fab.Design_No == rec_Fab_Obj.Design_No)
  9. {
  10. if(rec_Fab.Quantity > rec_Fab_Obj.Balance_Quantity)
  11. {
  12. rec_Fab.Quantity=rec_Fab.Quantity - rec_Fab_Obj.Balance_Quantity;
  13. rec_Fab_Obj.Balance_Quantity=0;
  14. }
  15. else if(rec_Fab.Quantity == rec_Fab_Obj.Balance_Quantity)
  16. {
  17. rec_Fab_Obj.Balance_Quantity=rec_Fab_Obj.Balance_Quantity - rec_Fab.Quantity;
  18. }
  19. }
  20. }
  21. }
  22. }
But the data is updated as follows:

Design No.:      Shade No.:      Quantity:
56459               250                  0.00
56459               250                  0.00
56459               250                  0.00

I have tried giving range while fetching but it wont work for me as i wont be deleting the data.

Thank you