Exemplo n.º 1
0
    private void CreatePO(string filename)
    {
       
        XmlSerializer serializer =
        new XmlSerializer(typeof(PurchaseOrder));
        TextWriter writer = new StreamWriter(filename);
        PurchaseOrder po = new PurchaseOrder();

       
        Address billAddress = new Address();
        billAddress.Name = "Teresa Atkinson";
        billAddress.Line1 = "1 Main St.";
        billAddress.City = "AnyTown";
        billAddress.State = "WA";
        billAddress.Zip = "00000";
        
        po.ShipTo = billAddress;
        po.OrderDate = System.DateTime.Now.ToLongDateString();

    
        OrderedItem i1 = new OrderedItem();
        i1.ItemName = "Widget S";
        i1.Description = "Small widget";
        i1.UnitPrice = (decimal)5.23;
        i1.Quantity = 3;
        i1.Calculate();

       
        OrderedItem[] items = { i1 };
        po.OrderedItems = items;
        
        decimal subTotal = new decimal();
        foreach (OrderedItem oi in items)
        {
            subTotal += oi.LineTotal;
        }
        po.SubTotal = subTotal;
        po.ShipCost = (decimal)12.51;
        po.TotalCost = po.SubTotal + po.ShipCost;
       
        serializer.Serialize(writer, po);
        writer.Close();
    }
Exemplo n.º 2
0
        private void SerializeObject(string filename)
        {
            Console.WriteLine("Writing With TextWriter");

            XmlSerializer serializer =
            new XmlSerializer(typeof(OrderedItem));
            OrderedItem i = new OrderedItem();
            i.ItemName = "Widget";
            i.Description = "Regular Widget";
            i.Quantity = 10;
            i.UnitPrice = (decimal)2.30;
            i.Calculate();

            /* Create a StreamWriter to write with. First create a FileStream
               object, and create the StreamWriter specifying an Encoding to use. */
            FileStream fs = new FileStream(filename, FileMode.Create);
            TextWriter writer = new StreamWriter(fs, new UTF8Encoding());
            // Serialize using the XmlTextWriter.
            serializer.Serialize(writer, i);
            writer.Close();
        }
Exemplo n.º 3
0
	private void CreatePO(string filename)
	{
		// Creates an instance of the XmlSerializer class;
		// specifies the type of object to serialize.
		XmlSerializer serializer=new XmlSerializer(typeof(PurchaseOrder));
		TextWriter writer=new StreamWriter(filename);
		PurchaseOrder po=new PurchaseOrder();

		// Creates an address to ship and bill to.
		Address billAddress=new Address();
		billAddress.Name="Teresa Atkinson";
		billAddress.Line1="1 Main St.";
		billAddress.City="AnyTown";
		billAddress.State="WA";
		billAddress.Zip="00000";
		// Sets ShipTo and BillTo to the same addressee.
		po.ShipTo=billAddress;
		po.OrderDate=System.DateTime.Now.ToLongDateString();

		// Creates an OrderedItem.
		OrderedItem i1=new OrderedItem();
		i1.ItemName="Widget S";
		i1.Description="Small widget";
		i1.UnitPrice=(decimal)5.23;
		i1.Quantity=3;
		i1.Calculate();

		// Inserts the item into the array.
		OrderedItem[] items={i1};
		po.OrderedItems=items;
		// Calculate the total cost.
		decimal subTotal=new decimal();
		foreach(OrderedItem oi in items)
		{
			subTotal+=oi.LineTotal;
		}
		po.SubTotal=subTotal;
		po.ShipCost=(decimal)12.51;
		po.TotalCost=po.SubTotal+po.ShipCost;
		// Serializes the purchase order, and closes the TextWriter.
		serializer.Serialize(writer, po);
		writer.Close();
	}
 public void UpdateOrderedItem(OrderedItem OrderedItem)
 {
     try
     {
         var OrderedItemUpdate = _dBContext.OrderedItems.FirstOrDefault(aOrderedItem => aOrderedItem.OrderedItemId == aOrderedItem.OrderedItemId);
         OrderedItemUpdate.Quantity = OrderedItem.Quantity;
         if (OrderedItem.MenuItem != null)
         {
             OrderedItemUpdate.MenuItem = OrderedItem.MenuItem;
         }
         if (OrderedItem.Order != null)
         {
             OrderedItemUpdate.Order = OrderedItem.Order;
         }
         _dBContext.SaveChanges();
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 public void InsertOrderedItem(OrderedItem OrderedItem)
 {
     try
     {
         _dBContext.OrderedItems.Add(OrderedItem);
         _dBContext.SaveChanges();
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 6
0
 public void AddToOrderedItems(OrderedItem orderedItem)
 {
     base.AddObject("OrderedItems", orderedItem);
 }
Exemplo n.º 7
0
 public static OrderedItem CreateOrderedItem(long orderedItemID, decimal orderedQuantity, long productMaterialItemID, long purchaseOrderID)
 {
     OrderedItem orderedItem = new OrderedItem();
     orderedItem.OrderedItemID = orderedItemID;
     orderedItem.OrderedQuantity = orderedQuantity;
     orderedItem.ProductMaterialItemID = productMaterialItemID;
     orderedItem.PurchaseOrderID = purchaseOrderID;
     return orderedItem;
 }