private FactureDetailsModel FactureDetailsBuild() { FactureDetailsModel facture_detail = new FactureDetailsModel(); try { facture_detail.Product = Product.Id; facture_detail.ProductName = Product.Name; if ((Price != null)) { facture_detail.Price = (decimal)Price; if (Currency != null) { facture_detail.Currency = Currency.Id; facture_detail.FullPrice = Price.ToString() + " " + Currency.Symbol; } else { MessageBox.Show("Currency is required when you add a price", "Failed", MessageBoxButton.OK, MessageBoxImage.Error); return(null); } SetTotal(); facture_detail.Total = Total; } if (Quantity != null) { facture_detail.Quantity = Quantity; } if (Size != null) { facture_detail.Size = Size.Id; facture_detail.SizeSymbol = Size.Size; } } catch (Exception e) { MessageBox.Show("Data is Empty", "Failed", MessageBoxButton.OK, MessageBoxImage.Error); return(null); } return(facture_detail); }
public void AddProduct() { // Create Entry for BindableCollection and Insert It FactureDetailsModel fd = FactureDetailsBuild(); if (fd != null) { if (FactureDetailsList == null) { FactureDetailsList = new List <FactureDetailsModel> { fd }; FactureDetails = new BindableCollection <FactureDetailsModel>(FactureDetailsList); } else { FactureDetailsList.Add(fd); FactureDetails = new BindableCollection <FactureDetailsModel>(FactureDetailsList); } } }
public void DeleteDetail(FactureDetailsModel fd) { FactureDetailsList.Remove(fd); FactureDetails = new BindableCollection <FactureDetailsModel>(FactureDetailsList); }