bool deletePurchasesDetail(int PurchasesDetailID) { objPurchasesDetail.BeginTransaction(); objPurchasesDetail = objPurchasesDetail.Single(p => p.PurchasesDetailID == PurchasesDetailID); //var payment = objPurchasesDetail.PurchasesMaster.PaymentsForSupplier; //payment.Delete(p => p.SupplierPaymentID == payment.SupplierPaymentID); objPurchasesMaster = objPurchasesDetail.PurchasesMaster; objPurchasesMaster.TotalPurchase -= objPurchasesDetail.TotalPrice; objPurchasesMaster.Rest -= objPurchasesDetail.TotalPrice; objPurchasesMaster.Update(p => p.PurchaseID == objPurchasesMaster.PurchaseID); hfOldRest.Value = objPurchasesMaster.Rest.ToString(); // update balance objSupplier = objSupplier.Single(p => p.SupplierID == objPurchasesDetail.PurchasesMaster.SupplierID); objSupplier.Balance = (objSupplier.Balance) - (objPurchasesDetail.TotalPrice); objSupplier.Update(p => p.SupplierID == objSupplier.SupplierID); //update qty SalesManager.UpdateproductQTY(QTYOperation.Decrement, objPurchasesDetail.ProductID, objPurchasesDetail.Quantity); bool status = objPurchasesDetail.Delete(p => p.PurchasesDetailID == PurchasesDetailID); objPurchasesDetail.EndTransaction(); return(status); }