示例#1
0
        private void SearchOrderButton_Click(object sender, RoutedEventArgs e)
        {
            int SearchNumber;

            if (int.TryParse(SearchWordText.Text, out SearchNumber))
            {
                List <Order> orderlist  = new List <Order>();
                var          orderlist1 = OrderDatabase.GetItemAsync(SearchNumber).Result;

                if (orderlist1 != null)
                {
                    orderlist.Add(orderlist1);

                    List <OrderGoods> ordergoods1 = new List <OrderGoods>();
                    ordergoods1 = OrderGoodsDatabase.GetItemsAsync().Result;

                    var query_where1 = from a in ordergoods1 where a.OrderID.Equals(orderlist[0].OrderID) select a;

                    List <OrderGoods> ordergoods2 = new List <OrderGoods>();

                    foreach (var a in query_where1)
                    {
                        ordergoods2.Add(a);
                    }

                    List <Goods> goodslist1 = new List <Goods>();
                    goodslist1 = GetGoodsToList(ordergoods2);

                    var query = from ordergoods in ordergoods2 join goodslist in goodslist1 on ordergoods.GoodsID equals goodslist.GoodsID select new { Name = goodslist.Name, Price = goodslist.Price, TotalPrice = (goodslist.Price * ordergoods.GoodsQauntity), GoodsQauntity = ordergoods.GoodsQauntity };
                    ListViewOfOrder.ItemsSource = query;

                    List <OrderTransport> transport = new List <OrderTransport>();
                    transport = OrderTransportDatabase.GetItemsAsync().Result;

                    var query_where4 = from a in transport where a.TransportID.Equals(orderlist[0].TransportID) select a;

                    foreach (var a in query_where4)
                    {
                        transport.Add(a);
                    }

                    List <Customer> customer    = new List <Customer>();
                    var             query_where = CustomerDatabase.GetItemAsync(orderlist[0].CustomerID).Result;
                    customer.Add(query_where);

                    List <Address> address       = new List <Address>();
                    var            query_address = AddressDatabase.GetItemAsync(orderlist[0].CustomerID).Result;
                    address.Add(query_address);

                    List <ContactInformation> contactinformation = new List <ContactInformation>();
                    var query_contactinformation = ContactInformationDatabase.GetItemAsync(orderlist[0].CustomerID).Result;
                    contactinformation.Add(query_contactinformation);

                    Name.Text      = customer[0].Name + " " + customer[0].Surname;
                    Address.Text   = address[0].Street + ", " + address[0].Town + ", " + address[0].PostNumber.ToString();
                    Transport.Text = transport[0].TypeOfTransport;
                    Phone.Text     = contactinformation[0].Phone.ToString();
                    Mail.Text      = contactinformation[0].Email.ToString();
                    Price.Text     = orderlist[0].OrderPrice.ToString();

                    ChangeVisibility();
                }
                else
                {
                    ChangeVisibility1();
                    SearchWordText.Text = "";
                    Warning.Visibility  = Visibility.Visible;
                }
            }
            else
            {
                ChangeVisibility1();
                SearchWordText.Text = "";
                Warning.Visibility  = Visibility.Visible;
            }
        }