예제 #1
0
 private void InformUser(string message)
 {
     PopupBox informer = new PopupBox();
     informer.Message = message;
     informer.PopupButton = PopupButton.OK;
     informer.ShowDialog();
 }
        private void negativeDecisionBtn_Click(object sender, RoutedEventArgs e)
        {

            if (negativeDecisionBtn.Content.ToString() == "Discard")
            {
                PopupBox actionConfirmer = new PopupBox(Util.GetParentWindow(this));
                actionConfirmer.Message = "Are you sure to discard the new enquiry ?";
                actionConfirmer.PopupButton = PopupButton.YesNo;
                bool? result = actionConfirmer.ShowDialog();
                if (result != null && result.Value == true)
                {
                    Navigate(OrderManagerTab.MyTasks);
                }
                return;
            }

            CommentBox commentBox = new CommentBox(Util.GetParentWindow(this));
            if (commentBox.ShowDialog() == true)
            {
                string userComment = commentBox.Comment;
                if (negativeDecisionBtn.Content.ToString() == "Reject")
                {
                    try
                    {
                        if (NewEnquiryViewModel.UpdateOrderStatus("rejected the Enquiry", userComment, OrderStatusEnum.EnquiryRejected))
                        {
                            SetButtonsVisibility(System.Windows.Visibility.Collapsed);
                            InformUser("Enquiry rejected");
                        }
                        else
                            InformUser("Unable to reject enquiry");
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Enquiry rejection failed!!!" + Environment.NewLine + ex.Message, "Failed", MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                }
                else if (negativeDecisionBtn.Content.ToString() == "Cancel")
                {
                    try
                    {
                        if (NewEnquiryViewModel.UpdateOrderStatus("cancelled the Enquiry", userComment, OrderStatusEnum.EnquiryCancelled))
                        {
                            SetButtonsVisibility(System.Windows.Visibility.Collapsed);
                            InformUser("Enquiry cancelled");
                        }
                        else
                            InformUser("Unable to cancel the enquiry");
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Enquiry cancellation failed!!!" + Environment.NewLine + ex.Message, "Failed", MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                }
                else
                {
                    SetButtonsVisibility(System.Windows.Visibility.Collapsed);
                }
            }

        }