示例#1
0
        /// <summary>
        /// Binds the product details.
        /// </summary>
        /// <exception cref="System.NotImplementedException"></exception>
        private void BindProductDetails(object product)
        {
            var isExist = LstProductDetails.Where(u => u.Id == CurrentProduct.Id).FirstOrDefault();

            if (isExist == null)
            {
                LstProductDetails.Add(new ProductDTO
                {
                    Id           = CurrentProduct.Id,
                    Name         = CurrentProduct.Name,
                    Quantity     = CurrentProduct.Quantity,
                    Retail_Price = CurrentProduct.Retail_Price,
                    Discount     = CurrentProduct.Discount,
                    Amount       = (CurrentProduct.Quantity * CurrentProduct.Retail_Price)
                });
            }
            else
            {
                var found    = LstProductDetails.FirstOrDefault(x => x.Id == CurrentProduct.Id);
                int i        = LstProductDetails.IndexOf(found);
                var quantity = CurrentProduct.Quantity + found.Quantity;
                LstProductDetails[i].Quantity = quantity;

                LstProductDetails[i].Amount = (found.Retail_Price * quantity) - found.Discount;
                CollectionViewSource.GetDefaultView(this.LstProductDetails).Refresh();
            }

            var amount        = LstProductDetails.Select(u => u.Amount).Sum();
            var totalDiscount = LstProductDetails.Select(u => u.Discount).Sum();

            TotalDiscount = (decimal)totalDiscount;
            Total         = (decimal)amount;

            Mediator.NotifyColleagues("CloseProductPopUpWindow", false);
        }
示例#2
0
        /// <summary>
        /// Reset Controls to their original position
        /// </summary>
        private void ResetControls()
        {
            IsSetAsidePopUpOpen = false;
            LstProductDetails.Clear();
            LstCustomerDetail.Clear();
            ClearControls();

            ViewModelLocator.Cleanup(ViewModelType.MenuControl);
        }
示例#3
0
        //To delete selected item from datagrid

        private void DeleteItem()
        {
            if (SelectedProduct != null)
            {
                Total = Total - (decimal)SelectedProduct.Amount;
                if (SelectedProduct.Discount > 0)
                {
                    TotalDiscount -= SelectedProduct.Discount;
                    //Discount -= (decimal)SelectedProduct.Discount;
                }
                LstProductDetails.Remove(SelectedProduct);
            }
        }
示例#4
0
        private void EditDataGridCommand()
        {
            SelectedProduct.Quantity = ProductQuantity;
            SelectedProduct.Amount   = (decimal)(SelectedProduct.Quantity * SelectedProduct.Retail_Price);
            bool showErrorMessage = false;

            if (SelectedDiscountType != null)
            {
                if (SelectedDiscountType.Id == 1 && ProductDiscount < SelectedProduct.Amount)
                {
                    SelectedProduct.Discount = ProductDiscount;
                    SelectedProduct.Amount  -= ProductDiscount;
                }
                else if (SelectedDiscountType.Id == 2)
                {
                    decimal discountAmount = (decimal)(SelectedProduct.Amount * (ProductDiscount / 100));
                    if (discountAmount < SelectedProduct.Amount)
                    {
                        SelectedProduct.Discount = discountAmount;
                        SelectedProduct.Amount  -= discountAmount;
                    }
                    else
                    {
                        showErrorMessage = true;
                    }
                }
                else
                {
                    showErrorMessage = true;
                }
            }

            if (!showErrorMessage)
            {
                var totalAmount   = LstProductDetails.Select(u => u.Amount).Sum();
                var totalDiscount = LstProductDetails.Select(u => u.Discount).Sum();
                Total         = (decimal)totalAmount;
                TotalDiscount = (decimal)totalDiscount;
                IsEditProductEntryPopupOpen = false;
            }
            else
            {
                IsErrorMessageVisible = Visibility.Visible;
            }
            //SelectedProduct.Amount = Amount
        }
示例#5
0
 private void ClearGridProduct()
 {
     LstProductDetails.Clear();
     TotalDiscount = (decimal)0.0;
     Total         = (decimal)0.0;
 }