public NavOrder AddOrder(NavOrder order) { try { Order o = new Order() { No = order.No, NoSpecified = true, Klient = order.CustomerNo, KlientSpecified = true, Kwota_do_zapłaty = order.TotalCost, Kwota_do_zapłatySpecified = true, Potwierdzenie_dostawy = order.IsDelivered, Potwierdzenie_dostawySpecified = true, Data_zamówienia = DateTime.Now, Data_zamówieniaSpecified = true }; _order_service.Create(ref o); foreach (NavOrderItem item in order.OrderItems) { OrderedItems oi = new OrderedItems() { Ilość = item.Count, Towar = item.ProductNo, Cena_zakupu = item.PurchasePrice, Koszt = item.Cost, Zamówienie = item.OrderNo, IlośćSpecified = true, TowarSpecified = true, ZamówienieSpecified = true, Cena_zakupuSpecified = true, KosztSpecified = true }; _orderItems_service.Create(ref oi); } return order; } catch { return null; } }
public bool EditOrder(NavOrder order) { try { foreach(NavOrderItem noi in order.OrderItems) { _orderItems_service.Delete(noi.Key); } Order o = new Order() { No = order.No, Data_dostarczenia = order.OrderDeliveryDate, Data_zamówienia = order.OrderDate, Klient = order.CustomerNo, Kwota_do_zapłaty = order.TotalCost, Potwierdzenie_dostawy = order.IsDelivered }; _order_service.Update(ref o); foreach (NavOrderItem item in order.OrderItems) { OrderedItems oi = new OrderedItems() { Cena_zakupu = item.PurchasePrice, Ilość = item.Count, Koszt = item.Cost, Towar = item.ProductNo, Zamówienie = item.OrderNo, Key = item.Key }; _orderItems_service.Create(ref oi); } return true; } catch { return false; } }
public NavOrder GetOrderById(int id) { try { NavOrder order = new NavOrder(_order_service.Read(id)); OrderedItems_Filter[] item_filter = { new OrderedItems_Filter() { Criteria = "=" + order.No, Field = OrderedItems_Fields.Zamówienie } }; List<NavOrderItem> n_orderItems = new List<NavOrderItem>(); List<OrderedItems> orderItems = new List<OrderedItems>(_orderItems_service.ReadMultiple(item_filter, "", int.MaxValue)); foreach (OrderedItems item in orderItems) { n_orderItems.Add(new NavOrderItem(item)); } order.OrderItems = n_orderItems; return order; } catch { return null; } }
public bool ConfirmOrderDelivery(NavOrder order) { try { Order o = new Order() { No = order.No, NoSpecified = true, Data_dostarczenia = order.OrderDeliveryDate, Data_zamówienia = order.OrderDate, Klient = order.CustomerNo, Kwota_do_zapłaty = order.TotalCost, Potwierdzenie_dostawy = order.IsDelivered, Potwierdzenie_dostawySpecified = true }; _order_service.Update(ref o); return true; } catch { throw; } }