public void AddItemByBarCode(string code) { string unitofmeasure; Item item; DaoController.Current.GetItemByBarCode(code, out item, out unitofmeasure); if (item != null) { var sl = SalesLines.FirstOrDefault(i => i.No_ == item.No_ && i.OrderType == 0 && i.UnitOfMeasureCode == unitofmeasure); if (sl == null) { decimal?price = DaoController.Current.GetsalesPrice(item.No_, unitofmeasure, Order.Sell_toCustomerNo, Order.CurrentCustomer.CustomerPriceGroup); if (price == null) { price = item.UnitPrice; } var ind = SalesLines != null && SalesLines.Count() > 0 ? SalesLines.Max(i => i.LineNo_) + 100 : 100; var nl = new SalesLine { DocumentNo_ = Order.No_, DocumentType = 1, LineNo_ = ind, Type = 2, No_ = item.No_, Description = item.Description, Quantity = 1, UnitPrice = price, Sell_toCustomerNo = Order.Sell_toCustomerNo, LocationCode = App.Current.PosSetting.Settings_Location, AmountIncludingVAT = Math.Round(price.Value, 2, MidpointRounding.AwayFromZero), UnitOfMeasureCode = unitofmeasure, OrderType = (int)OrderTypes.Ok, LineDiscountAmount = 0, LineDiscountPercent = 0 }; (SalesLines as List <SalesLine>).Add(nl); } else { sl.Quantity = sl.Quantity + 1; sl.AmountIncludingVAT = Math.Round(sl.Quantity.Value * sl.UnitPrice.Value, 2, MidpointRounding.AwayFromZero); } Order.AmountIncludingVat = SalesLines.Sum(i => i.AmountIncludingVAT); RefreshGrid(); RefreshSummary(); } }
public void DeleteSalesLine(int line_no) { if (Order.OrderBaseType == OrderBaseTypes.Released) { var sl = ((List <ReleasedSalesLine>)_salesLines).FirstOrDefault(i => i.LineNo_ == line_no); if (sl != null) { ((List <ReleasedSalesLine>)_salesLines).Remove(sl); } } else { var sl = ((List <SalesLine>)_salesLines).FirstOrDefault(i => i.LineNo_ == line_no); if (sl != null) { ((List <SalesLine>)_salesLines).Remove(sl); } } Order.AmountIncludingVat = SalesLines.Sum(i => i.AmountIncludingVAT); RefreshSummary(); // RaisePropertyChanged(() => SalesLines); }