Exemplo n.º 1
0
        private void submitBtn_Click(object sender, RoutedEventArgs e)
        {
            string orderIDStr = orderIDTxt.Text.Trim();
            int    orderID;

            bool success = int.TryParse(orderIDStr, out orderID);

            if (!success)
            {
                errorLbl.Text = "Order ID is not a number";
            }
            else if (statusComboBox.SelectedItem == null)
            {
                errorLbl.Text = "Please input all field";
            }
            else
            {
                OrderMediator mediator = new OrderMediator();

                string status = (string)((ComboBoxItem)statusComboBox.SelectedValue).Content;
                Order  order  = mediator.getOrder(orderID);
                if (order == null)
                {
                    errorLbl.Text = "Order doesn't exist";
                }
                else
                {
                    order.status = status;
                    order        = mediator.updateOrder(orderID, order);
                    if (order == null)
                    {
                        MessageBox.Show("Change status failed!");
                    }
                    else
                    {
                        MessageBox.Show("Change Status success");
                    }
                    refresh();
                }
            }
        }
Exemplo n.º 2
0
        private void orderIDTxt_TextChanged(object sender, TextChangedEventArgs e)
        {
            string orderIDStr = orderIDTxt.Text.Trim();
            int    orderID;

            bool success = int.TryParse(orderIDStr, out orderID);

            if (!success && orderIDTxt.Text != "")
            {
                errorLbl.Text = "Order ID is not a number";
            }
            else
            {
                errorLbl.Text = "";
                OrderMediator mediator = new OrderMediator();
                if (mediator.getOrder(orderID) == null)
                {
                    orderDetailView.ItemsSource = null;
                    return;
                }
                orderDetailView.ItemsSource = mediator.getAllOrderDetail(orderID);
            }
        }