/// <summary>
 /// Create a new Party object.
 /// </summary>
 /// <param name="partyID">Initial value of the PartyID property.</param>
 /// <param name="partyDate">Initial value of the PartyDate property.</param>
 /// <param name="partyTotal">Initial value of the PartyTotal property.</param>
 public static Party CreateParty(global::System.Guid partyID, global::System.DateTime partyDate, global::System.Double partyTotal)
 {
     Party party = new Party();
     party.PartyID = partyID;
     party.PartyDate = partyDate;
     party.PartyTotal = partyTotal;
     return party;
 }
Esempio n. 2
0
        private void SaveButton_Click(object sender, RoutedEventArgs e)
        {
            if (OrderStackPanel.Children.Count == 0)
                return;

            this.Cursor = Cursors.Wait;

            bool hasOrderBeenAdded = false;

            using (ThirtyOneEntities te = new ThirtyOneEntities())
            {
                Guid partyID = Guid.NewGuid();
                Party p = new Party();
                p.PartyID = partyID;
                p.PartyDate = Convert.ToDateTime(PartyDatePicker.Text);
                p.PartyTotal = partyTotal;

                foreach (UIElement ele in OrderStackPanel.Children)
                {
                    if (ele is OrderControl)
                    {
                        OrderControl oc = ele as OrderControl;

                        if (oc.CustomerID == Guid.Empty)
                            continue;

                        if (oc.ProductSubTotal == 0)
                            continue;

                        hasOrderBeenAdded = true;

                        Order order = new Order();
                        order.CustomerID = oc.CustomerID;
                        order.IsPaid = oc.IsPaid;
                        order.OrderDate = p.PartyDate;
                        order.OrderID = Guid.NewGuid();
                        order.OrderShipping = oc.ShippingTotal;
                        order.OrderSubTotal = oc.ProductSubTotal;
                        order.OrderTax = oc.TaxTotal;
                        order.OrderTotal = oc.TotalPrice;
                        order.PartyID = p.PartyID;

                        if (order.IsPaid)
                            order.PaymentTypeID = oc.PaymentTypeID;
                        else
                            order.PaymentTypeID = GetNonePaymentTypeID();

                        te.AddToOrders(order);

                        //oc.BeginRemoveStoryboard();
                    }
                }

                if (hasOrderBeenAdded)
                {
                    te.AddToParties(p);
                    te.SaveChanges();
                }
            }

            this.Cursor = Cursors.Arrow;
        }
 /// <summary>
 /// Deprecated Method for adding a new object to the Parties EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToParties(Party party)
 {
     base.AddObject("Parties", party);
 }