private void commentsBtn_Click_1(object sender, RoutedEventArgs e) { CommentBox cBox = new CommentBox(); cBox.UpdateBtnText = "Close"; cBox.Title = "Comments"; cBox.IsReadOnly = true; cBox.Comment = ViewModel.SelectedJobOrderInfo.Approval.Comments; cBox.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); } } }
private void positiveDecisionBtn_Click(object sender, RoutedEventArgs e) { if (NewEnquiryViewModel.HasErrors) { string message = string.Format("Failed!. Fill in the highlighted fields and Click Create again"); InformUser(message); return; } CommentBox commentBox = new CommentBox(Util.GetParentWindow(this)); if (commentBox.ShowDialog() == true) { string userComment = commentBox.Comment; if (positiveDecisionBtn.Content.ToString() == "Create") { //if (NewEnquiryViewModel.HasErrors) //{ // string message = string.Format("Failed to Create !. Fill in the highlighted fields and Click Create again"); // InformUser(message); // return; //} Order newOrder = NewEnquiryViewModel.CreateNewOrder(userComment); if (newOrder != null) { SetButtonsVisibility(System.Windows.Visibility.Collapsed); string message = string.Format("Enquiry Successfully Created. ID : {0}", newOrder.OrderID.ToString()); InformUser(message); Navigate(OrderManagerTab.AllOrders); } } else if (positiveDecisionBtn.Content.ToString() == "Approve") { try { if (NewEnquiryViewModel.UpdateOrderStatus("approved the Order", userComment, OrderStatusEnum.EnquiryApproved)) { SetButtonText(positiveDecisionBtn, "Confirm"); SetButtonText(negativeDecisionBtn, "Cancel"); string message = "Enquiry approved successfully"; InformUser(message); NewEnquiryViewModel.OnPropertyChanged("CanUpdateEnquiry"); //Call to rebind in UI } else MessageBox.Show("Enquiry approval failed!!!", "Failed", MessageBoxButton.OK, MessageBoxImage.Error); } catch (Exception ex) { MessageBox.Show("Enquiry approval failed!!!" + Environment.NewLine + ex.Message, "Failed", MessageBoxButton.OK, MessageBoxImage.Error); } } else if (positiveDecisionBtn.Content.ToString() == "Confirm") { try { if (!NewEnquiryViewModel.HasErrors) { if (NewEnquiryViewModel.UpdateOrderStatus("confirmed the Order", userComment, OrderStatusEnum.OrderConfirmed)) { SetButtonsVisibility(System.Windows.Visibility.Collapsed); string message = "Enquiry confirmed successfully"; InformUser(message); NewEnquiryViewModel.OnPropertyChanged("CanUpdateEnquiry"); //Call to rebind in UI } else MessageBox.Show("Enquiry confirming failed!!!", "Failed", MessageBoxButton.OK, MessageBoxImage.Error); } } catch (Exception ex) { MessageBox.Show("Enquiry confirming failed!!!" + Environment.NewLine + ex.Message, "Failed", MessageBoxButton.OK, MessageBoxImage.Error); } } else { SetButtonsVisibility(System.Windows.Visibility.Collapsed); } } }
public bool Reject() { try { CommentBox cBox = new CommentBox(); if (cBox.ShowDialog() == true) { StringBuilder comment = new StringBuilder(); comment.AppendLine("Rejected on " + DBResources.Instance.GetServerTime() + " by " + DBResources.Instance.CurrentUser.UserName); comment.AppendLine(cBox.Comment); comment.Append(ViewModel.JO.Approval.Comments); ViewModel.JO.Approval.Comments = comment.ToString(); ViewModel.JO.Approval.IsApproved = false; DBResources.Instance.Save(); ViewModel.JO.RefreshInfoJobOrderInfo(); } } catch (Exception ex) { MessageBox.Show(ex.Message); return false; } return true; }
private void negativeBtn_Click_1(object sender, RoutedEventArgs e) { if (negativeBtn.Content.ToString() == "Discard") { Reset(); if (PurchaseOrderStatusChanged != null) { PurchaseOrderStatusChanged(PurchaseOrderState.Discarded); } } else if (negativeBtn.Content.ToString() == "Reject") { CommentBox cBox = new CommentBox(); cBox.ShowDialog(); ViewModel.PurchaseOrder.Approval.IsApproved = false; StringBuilder sb = new StringBuilder(); sb.AppendLine("Rejected By " + DBResources.Instance.CurrentUser.UserName + " at " + DBResources.Instance.GetServerTime().ToString()); sb.AppendLine(cBox.Comment); sb.AppendLine(); ViewModel.PurchaseOrder.Approval.Comments = sb.ToString() + ViewModel.PurchaseOrder.Approval.Comments; DBResources.Instance.Save(); SetUIAccesibility(PurchaseOrderState.Rejeted); } ViewModel.PurchaseOrder.RefreshUIProperties(); }
public bool Persist(bool isSubmit) { m_ViewModel.HasUserClickedSaveOrSubmit = true; if (m_ViewModel.HasError) { InformUser("Errors highlighted in red color !. Fix it and retry"); } else { if (isSubmit) { CommentBox commentBox = new CommentBox(Util.GetParentWindow(this)); if ((commentBox.ShowDialog() == true)) { if (m_ViewModel.Save(isSubmit, commentBox.Comment)) { btnAddNewItem.Visibility = System.Windows.Visibility.Collapsed; materialsGrid.IsReadOnly = true; return true; } return false; } } else return m_ViewModel.Save(isSubmit, ""); } return false; }