Example #1
0
        private static void HandleOrderModel(ObservableCollection <OrderModel> order)
        {
            OrderStruct[]    orderStruct = new OrderStruct[order.Count];
            MerchandiseModel tmpMerch;
            string           pending = "";

            for (int i = 0; i < order.Count; i++)
            {
                tmpMerch = order[i].Merch;

                orderStruct[i].CustomerName  = order[i].CustomerName;
                orderStruct[i].OrderedAmount = order[i].OrderedAmount;
                orderStruct[i].OrderDate     = order[i].OrderDate.ToString();
                orderStruct[i].ProductName   = tmpMerch.ProductName;
                orderStruct[i].Supplier      = tmpMerch.Supplier;
                if (order[0].IsPendingOrder)
                {
                    pending = "Pending";
                }
            }
            if (order.Count == 0)
            {
                pending = "Pending";
            }

            Header h = new Header
            {
                Name   = typeof(OrderStruct).Name + pending,
                size   = Marshal.SizeOf(typeof(OrderStruct)),
                amount = order.Count
            };

            ObjectToByteArray(orderStruct, h);
        }
Example #2
0
        private static void ReadOrderStruct(BinaryReader br, Header h, ViewModel vm, bool pending)
        {
            OrderStruct[] os = new OrderStruct[h.amount];
            for (int i = 0; i < h.amount; i++)
            {
                os[i] = ReadStructData <OrderStruct>(br, h);
            }

            AddOrderStructToList(os, vm, pending);
        }