Ejemplo n.º 1
0
 public void Initialize(OrderCase entity)
 {
     Initialize();
     SelectedId           = entity.Id;
     Account.SelectedItem = entity.Account;
     Date.SelectedDate    = entity.Date;
     Payment.Text         = entity.Payment;
     Price.Text           = entity.Price.ToString();
 }
Ejemplo n.º 2
0
 private void Update_Click(object sender, RoutedEventArgs e)
 {
     if (OrderTable.SelectedIndex >= 0)
     {
         OrderCase Item = (dynamic)OrderTable.SelectedItem;
         OrderEditView.IsEnabled  = true;
         OrderEditView.Visibility = Visibility.Visible;
         OrderEditView.Initialize(Item);
         EditHeight.Height = new GridLength(120);
     }
 }
Ejemplo n.º 3
0
        private void Remove_Click(object sender, RoutedEventArgs e)
        {
            var result = MessageBox.Show("Are you sure to delete selected data?", "Требуется подстверждение!", MessageBoxButton.YesNo, MessageBoxImage.Warning);

            if (result == MessageBoxResult.Yes && OrderTable.SelectedIndex >= 0)
            {
                OrderCase Item = (dynamic)OrderTable.SelectedItem;
                db.Orders.Remove(db.Orders.Where(e => e.Id == Item.Id).Single());
                db.SaveChanges();
                Initialize();
            }
        }
        public void mapProcessedOrders()
        {
            foreach (Order order in orderList)
            {
                foreach (Shop shop in shopList)
                {
                    decimal distance = calculateDistance(shop, order);
                    order.distances.Add(shop.name, distance);

                    orderCases.Add(new OrderCase
                    {
                        shop        = shop,
                        orderNumber = order.orderNumber,
                        distance    = calculateDistance(shop, order)
                    });
                }
            }


            //orderCases.OrderBy(c => c.distance).ToList();
            orderCases.Sort((case1, case2) => case1.distance < case2.distance ? -1 : 1);

            int leftOrderNumber = orderList.Count;

            for (int i = 0; i < orderCases.Count; i++)
            {
                OrderCase orderCase = orderCases[i];

                Console.WriteLine(orderCase.shop.name + "//" + orderCase.orderNumber + " //" + orderCase.distance);
                Console.WriteLine();

                if (assignedOrders.ContainsKey(orderCase.orderNumber) == false)
                {
                    if (orderCase.shop.currentOrderState < orderCase.shop.maxOrderLimit && leftOrderNumber > (SUM_MIN_LIMIT - orderCase.shop.maxOrderLimit))
                    {
                        assignedOrders.Add(orderCase.orderNumber, orderCase.shop.name);
                        leftOrderNumber--;
                        orderCase.shop.currentOrderState = orderCase.shop.currentOrderState + 1;
                    }
                }
            }

            Console.WriteLine("   ");
        }