public void DeleteDetail(string PName) { SalesDetail sod = SDetails.Where(x => x.ProductName == PName).FirstOrDefault(); if (sod != null) { SDetails.Remove(sod); ItemAmount = SDetails.Sum(x => x.Amount); } }
public void SaveDetail() { if (SDetail.ProductId != 0) { SalesDetail sod = SDetails.Where(x => x.ProductId == SDetail.ProductId).FirstOrDefault(); if (sod == null) { sod = new SalesDetail(); SDetails.Add(sod); } else { SDetail.Quantity += sod.Quantity; } SDetail.toCopy <SalesDetail>(sod); ClearDetail(); ItemAmount = SDetails.Sum(x => x.Amount); } }