private void OrderControl_TotalUpdated(object sender, EventArgs e) { OrderControl oc = sender as OrderControl; partyTotal -= oc.OldTotal; partyTotal += oc.TotalPrice; PartyTotalTextBlock.Text = string.Format("{0:c}", partyTotal); }
private void oc_DeleteControl(object sender, EventArgs e) { OrderControl oc2 = sender as OrderControl; oc2.DeleteControl -= new EventHandler(oc_DeleteControl); OrderStackPanel.Children.Remove(oc2); CreateNewOrder(); }
private void CreateNewOrder() { orderControl = new OrderControl(); orderControl.Height = 167; orderControl.Width = 570; orderControl.Name = "oc2"; orderControl.Opacity = 0; orderControl.IsClosable = false; orderControl.IsParty = false; orderControl.DeleteControl += new EventHandler(oc_DeleteControl); OrderStackPanel.Children.Add(orderControl); }
private void AddButton_Click(object sender, RoutedEventArgs e) { OrderStackPanel.Height += 167; OrderControl oc = new OrderControl(); oc.Height = 167; oc.Width = 570; oc.Name = "oc"; oc.Opacity = 0; oc.IsClosable = true; oc.IsParty = true; oc.DeleteControl += new EventHandler(OrderControl_DeleteControl); oc.TotalUpdated += new EventHandler(OrderControl_TotalUpdated); OrderStackPanel.Children.Add(oc); }
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; }