예제 #1
0
        private void AddProduct()
        {
            IMessageSourceAccessor messageResolver = ObjectFactory.GetInstance<IMessageSourceAccessor>();
            POLineItemViewModel vm = DataContext as POLineItemViewModel;
            vm.SelectedProduct = cmbProducts.SelectedItem as POLineItemProductLookupItem;
            if (vm.SelectedProduct == null)
            {
                MessageBox.Show("Please select product ");
                return;
            }
            else if (vm.Qty <= 0)
            {
                MessageBox.Show("Please Enter valid Quantity ");
                return;
            }
            else
            {

                MessageBoxResult isConfirmed = MessageBox.Show("Add Product : " + vm.SelectedProduct.ProductDesc + " of quantity = " + vm.Qty, "Confirm " + messageResolver.GetText("sl.po.name"), MessageBoxButton.OKCancel);

                if (isConfirmed == MessageBoxResult.OK)
                {
                    MultipleAddProduct pro = new MultipleAddProduct()
                    {
                        Product = vm.SelectedProduct,
                        Quantity = vm.Qty,
                        TotalPrice = vm.TotalPrice,
                        UnitPrice = vm.UnitPrice,
                        Vat = vm.Vat,
                        VatAmount = vm.VatAmount,
                        LineItemVatValue = vm.LineItemVatValue,
                        LineItemType = vm.LineItemType,
                    };
                    vm.AddProduct(pro);
                    vm.ClearAndSetup.Execute(null);
                    vm.IsNew = true;
                    cmbProducts.SelectedItem = null;
                    rb1.IsChecked = true;
                }
            }
        }
예제 #2
0
        public void AddProductSummary(MultipleAddProduct mp)
        {
            decimal qt = Qty;

            if (mp.LineItemType == LineItemType.Bulk)
                qt = _productPackagingSummaryService.GetProductQuantityInBulk(SelectedProduct.ProductId)*Qty;
            _productPackagingSummaryService.AddProduct(mp.Product.ProductId, qt, false, !IsAdd, false);
            List<PackagingSummary> summarypro = _productPackagingSummaryService.GetProductSummary();
            foreach (PackagingSummary item in summarypro)
            {
                decimal productUnitPrice = ProductPriceCalc(item.Product);
                decimal productUnitVat = ProductVatCalc(item.Product);
                decimal productCost = productUnitPrice*item.Quantity;
                decimal productVat = productUnitVat*productCost;

                CalculateProductSummary(item.Product.Id, item.Product.Description, item.Quantity, productUnitPrice,
                                        productCost + productVat, productUnitVat, productVat, item.ParentProductId,
                                        item.IsEditable);
            }
        }
예제 #3
0
        private void AddProduct()
        {
            _vm.SelectedProduct = cmbProducts.SelectedItem as POLineItemProductLookupItem;
            if (_vm.SelectedProduct == null)
            {
                MessageBox.Show(/*"Select a product in the products dropdown list."*/
                    _messageResolver.GetText("sl.order.addlineitem.modal.messageBox.productNotSelectedErrorMsg")
                    , _messageResolver.GetText("sl.order.addlineitem.modal.messageBox.errorCatpion")/*"Distributr: Add Order Line Items"*/
                    , MessageBoxButton.OK);
                return;
            }
            else if (_vm.Qty <= 0)
            {
                MessageBox.Show(/*"Quantity should not be zero or empty."*/
                    _messageResolver.GetText("sl.order.addlineitem.modal.messageBox.zeroQtyErrorMsg")
                    , _messageResolver.GetText("sl.order.addlineitem.modal.messageBox.errorCatpion") /*"Distributr: Add Order Line Items"*/
                    , MessageBoxButton.OK); ;
                return;
            }
            else
            {
                //string msg = "";
                //if (_vm.SelectedProduct.ProductId != Guid.Empty)
                //    msg = "Add Product : " + _vm.SelectedProduct.ProductDesc + " of quantity = " + _vm.Qty;
                //else
                //{
                //    msg = _messageResolver.GetText("sl.order.addlineitem.modal.messageBox.confirmMsg");/* "Are you sure you want to insert added products";*/
                //}
                //MessageBoxResult isConfirmed = MessageBox.Show(msg + "?", _messageResolver.GetText("sl.order.addlineitem.modal.messageBox.confirmCaption")
                //    /*"Distributr: Confirm Order"*/
                //    , MessageBoxButton.OKCancel);

                //if (isConfirmed == MessageBoxResult.OK)
                //{
                    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);
                    _vm.RunClearAndSetup();
                    _vm.IsNew = true;
                    cmbProducts.SelectedIndex = 0;
                    rbUnits.IsChecked = true;
                //}
            }
        }
예제 #4
0
 public void AddProduct(MultipleAddProduct product)
 {
     MultipleProduct.Add(product);
     AddProductSummary(product);
 }
예제 #5
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);
            }
        }