private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            if (orderControl.CustomerID == Guid.Empty)
            {
                return;
            }

            using (ThirtyOneEntities te = new ThirtyOneEntities())
            {
                Order order = new Order();
                order.CustomerID    = orderControl.CustomerID;
                order.IsPaid        = orderControl.IsPaid;
                order.OrderDate     = Convert.ToDateTime(PartyDatePicker.Text);
                order.OrderID       = Guid.NewGuid();
                order.OrderShipping = orderControl.ShippingTotal;
                order.OrderSubTotal = orderControl.ProductSubTotal;
                order.OrderTax      = orderControl.TaxTotal;
                order.OrderTotal    = orderControl.TotalPrice;

                if (order.IsPaid && orderControl.PaymentTypeID != null)
                {
                    order.PaymentTypeID = orderControl.PaymentTypeID;
                }
                else
                {
                    order.PaymentTypeID = GetNonePaymentTypeID();
                }

                te.AddToOrders(order);
                te.SaveChanges();
            }

            orderControl.BeginRemoveStoryboard();

            Storyboard saveCompleteSB = (Storyboard)FindResource("SaveCompleteStoryboard");

            saveCompleteSB.Begin();
        }
Пример #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;
        }
Пример #3
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;
        }
Пример #4
0
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            if (orderControl.CustomerID == Guid.Empty)
                return;

            using (ThirtyOneEntities te = new ThirtyOneEntities())
            {
                Order order = new Order();
                order.CustomerID = orderControl.CustomerID;
                order.IsPaid = orderControl.IsPaid;
                order.OrderDate = Convert.ToDateTime(PartyDatePicker.Text);
                order.OrderID = Guid.NewGuid();
                order.OrderShipping = orderControl.ShippingTotal;
                order.OrderSubTotal = orderControl.ProductSubTotal;
                order.OrderTax = orderControl.TaxTotal;
                order.OrderTotal = orderControl.TotalPrice;

                if (order.IsPaid && orderControl.PaymentTypeID != null)
                    order.PaymentTypeID = orderControl.PaymentTypeID;
                else
                    order.PaymentTypeID = GetNonePaymentTypeID();

                te.AddToOrders(order);
                te.SaveChanges();
            }

            orderControl.BeginRemoveStoryboard();

            Storyboard saveCompleteSB = (Storyboard)FindResource("SaveCompleteStoryboard");
            saveCompleteSB.Begin();
        }