Ejemplo n.º 1
0
        private void AddProduct(object sender)
        {
            try
            {
                _vm = DataContext as POSLineItemViewModel;
                bool isInvalid = false;
                Button cmd = (Button)sender;
                if (cmbProducts.SelectedItem == null || cmbProducts.SelectedIndex == -1 || cmbProducts.SelectedIndex == 0)
                {
                    MessageBox.Show(
                        _messageResolver.GetText("sl.pos.addlineitem.modal.message.productnotselected")/*"Select a product in product dropdown list."*/
                        , _messageResolver.GetText("sl.pos.addlineitem.modal.ok.message.caption")/*"Distributr: Add Order Line Items"*/
                        , MessageBoxButton.OK);
                    isInvalid = true;
                }
                if (Convert.ToDouble(txtQty.Text) <= 0 || txtQty.Text.Trim() == "")
                {
                    MessageBox.Show(
                        _messageResolver.GetText("sl.pos.addlineitem.modal.message.quantityzero")/*"Quantity should not be zero or empty."*/
                        , _messageResolver.GetText("sl.pos.addlineitem.modal.ok.message.caption")/*"Distributr: Add Order Line Items"*/
                        , MessageBoxButton.OK); ;
                    isInvalid = true;
                }

                if (!isInvalid)
                {
                    if (_vm.Qty > _vm.AvailableProductInv)
                    {
                        string msg = _messageResolver.GetText("sl.pos.addlineitem.modal.message.sellMoreThanAvailable");
                        /*"Sorry, you cannot sell more than the available inventory.";*/
                        if (_vm.ReceiveReturnables)
                            msg = _messageResolver.GetText("sl.pos.addlineitem.modal.message.receiveMoreThanRequired");
                        /*"Sorry, you cannot receive more than required returnables for this sale.";*/

                        MessageBox.Show(msg,
                            "!" + _messageResolver.GetText("sl.pos.addlineitem.modal.ok.message.caption")/*"Distributr: Add Order Line Items"*/
                            , MessageBoxButton.OK);
                        txtQty.Focus();
                        txtQty.SelectAll();
                        isInvalid = true;
                    }
                }

                if (!isInvalid)
                {
                    MultipleAddProduct pro = new MultipleAddProduct()
                    {
                        Product = _vm.SelectedProduct,
                        Quantity = _vm.Qty,
                        TotalPrice = _vm.TotalPrice,
                        UnitPrice = _vm.UnitPrice,
                        Vat = _vm.VatAmount,
                        VatAmount = _vm.VatAmount,
                        LineItemVatValue = _vm.LineItemVatValue,
                        LineItemType = _vm.LineItemType
                    };
                   
                    _vm.AddProduct(pro);

                    fireQtyChangedEvent = false;
                    _vm.ClearViewModel();
                    if (cmbProducts.Items.Count > 0)
                        cmbProducts.SelectedIndex = 0;
                    hlViewAdded.Text = _vm.ButtonNameText;

                    rbUnits.IsChecked = true;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message
                    , _messageResolver.GetText("sl.pos.addlineitem.modal.ok.message.caption")/*"Distributr: Add Order Line Items"*/
                    , MessageBoxButton.OK);
            }
        }
Ejemplo n.º 2
0
 private void cmbProducts_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (!isInitialized)
         return;
     try
     {
         if (cmbProducts.SelectedItem != null)
         {
             _vm = DataContext as POSLineItemViewModel;
             if (cmbProducts.SelectedIndex != 0)
             {
                 _vm.RunProductSelected();
             }
             else
             {
                 _vm.ClearViewModel();
                 cmbProducts.SelectedIndex = 0;
             }
         }
     }
     catch
     {
         MessageBox.Show(
             _messageResolver.GetText("sl.pos.addlineitem.modal.message.valueTooLarge")/*"Value was too large."*/
             , "!" + _messageResolver.GetText("sl.pos.addlineitem.modal.ok.message.caption")/*"Distributr: Add Order Line Items"*/
             , MessageBoxButton.OK);
         _vm.Qty = 0;
     }
 }