コード例 #1
0
        public void OrdersSearch(SearchWindow window)
        {
            string name     = window.TxtSearchOrderName.Text;
            string price    = window.TxtSearchOrderPrice.Text;
            string quantity = window.TxtSearchOrderQuantity.Text;
            string statusId = window.CbOrderStatusId.Text;

            List <Order> order = new OrderCRUD().GetOrders();

            if (!String.IsNullOrEmpty(name))
            {
                order.RemoveAll(x => x.Name.ToLower() != name.ToLower());
            }

            if (!String.IsNullOrEmpty(price))
            {
                order.RemoveAll(x => x.Price != Convert.ToDecimal(price));
            }

            if (!String.IsNullOrEmpty(quantity))
            {
                order.RemoveAll(x => x.Quantity != Convert.ToInt32(quantity));
            }

            if (!String.IsNullOrEmpty(statusId))
            {
                order.RemoveAll(x => x.OrderStatusId != Convert.ToInt32(statusId));
            }

            if (order.Count > 0)
            {
                BindDataGrid(order);
                window.Close();
            }
            else
            {
                MessageBox.Show("There are no results", "Information");
            }
        }