Example #1
0
        private void SerializeProductOrderData(string FileName, PurchaseOrder purchaseorder)
        {
            //initialize the XML Serializer
            XmlSerializer serializer = new XmlSerializer(typeof(PurchaseOrder));
            TextWriter    writer     = new StreamWriter(FileName);
            //boxing for data serialization
            //Creates a local objects of the passed customer/purchase order
            //references
            PurchaseOrder p = new PurchaseOrder();

            p = purchaseorder;

            OrderedProduct OP = new OrderedProduct();

            OrderedProduct [] items = { OP };
            p.OrderedProducts = items;

            double Total = new double();

            foreach (OrderedProduct oi in items)
            {
                p.TotalCost += oi.TotalCostOfProduct;
            }
            p.TotalCost = Total;

            // Serialize the purchase order, and close the TextWriter.
            serializer.Serialize(writer, p);
            writer.Close();
        }
Example #2
0
        //Customer GetCustomerByCustomerFullName(string CustomerName)
        //{
        //return data2.First(i => i.CustomerName == CustomerName);
        //}


        void AddOrderToPlaceOrder(string customerFullName, string locationOfPurchase, string productName, int quanitityOfPurchase, double costOfPurchase, DateTime date, int walbMartCurrentStockOfProduct, PurchaseOrder purchaseorder)
        {
            if (walbMartCurrentStockOfProduct >= quanitityOfPurchase && quanitityOfPurchase > 0)
            {
                var order               = new OrderedProduct(customerFullName, locationOfPurchase, productName, quanitityOfPurchase, costOfPurchase);
                var puorder             = purchaseorder;
                OrderedProduct [] items = purchaseorder.OrderedProducts;
            }
            else
            {
                throw new ArgumentOutOfRangeException(nameof(quanitityOfPurchase), "You didn't buy anything!");
            }
            if (purchaseorder == null)
            {
            }
        }