private void OKButton_Click(object sender, RoutedEventArgs e)
        {
            _vm = DataContext as DPLineItemViewModel;
            string errorMsg = string.Empty;
            if (_vm.SelectedProduct.Id == Guid.Empty)
            {
                errorMsg += "You must select a product.\n";
            }
            if (_vm.SelectedReason.Id == Guid.Empty)
            {
                errorMsg += "You must select a reason\n";
            }
            if (_vm.Qty == 0)
            {
                errorMsg += "The quantity entered should be greater than 0.\n";
            }
            if ((_vm.AvailableQty - _vm.Qty) < 0)
            {
                errorMsg += "The quantity entered is more than available inventory.\n";
            }
            if (_vm.SelectedReason.Reason == "Others")
            {
                if (txtOtherReason.Text.Trim() == "")
                {
                    errorMsg += "You must specify other reasons.";
                }
            }

            if (!string.IsNullOrEmpty(errorMsg))
            {
                MessageBox.Show(errorMsg, "Distributr: Dispatch Products", MessageBoxButton.OK);
                return;
            }
            this.DialogResult = true;
        }
 public DispatchProductsLineItemModal()
 {
     isInitialized = false;
     InitializeComponent();
     isInitialized = true;
     _vm = this.DataContext as DPLineItemViewModel;
     this.Loaded += new RoutedEventHandler(DispatchProductsLineItemModal_Loaded);
     //this.HasCloseButton = false;
 }
 private void txtQty_TextChanged(object sender, TextChangedEventArgs e)
 {
     if (!isInitialized)
         return;
     _vm = DataContext as DPLineItemViewModel;
     decimal quantity = 0;
     bool isValidQuantity = decimal.TryParse(txtQty.Text, out quantity);
     _vm.Qty = quantity;
     try
     {
         _vm.Qty = Convert.ToDecimal(txtQty.Text);
         if ((_vm.AvailableQty - _vm.Qty) < 0)
         {
             MessageBox.Show("The quantity entered is more than available inventory");
             _vm.Qty = 0;
             return;
         }
     }
     catch
     {
         MessageBox.Show("You have enter a digit that is too big");
     }
 }
Example #4
0
 /// <summary>
 /// Provides a deterministic way to create the DPLineItemViewModel property.
 /// </summary>
 public static void CreateDPLineItemViewModel()
 {
     if (_dPLineItemViewModel == null)
     {
         _dPLineItemViewModel = new DPLineItemViewModel();
     }
 }
Example #5
0
 /// <summary>
 /// Provides a deterministic way to delete the DPLineItemViewModel property.
 /// </summary>
 public static void ClearDPLineItemViewModel()
 {
     _dPLineItemViewModel.Cleanup();
     _dPLineItemViewModel = null;
 }