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

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

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

            // Serialize the purchase order, and close the TextWriter.
            serializer.Serialize(writer, p, c);
            writer.Close();
        }
Example #2
0
        private 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)
            {

            }


        }