Пример #1
0
        private void UpdateTotalPriceAndTotalProfit()
        {
            OrderProductRecordList.ItemsSource = null;
            OrderProductRecordList.ItemsSource = OrderProductRecords;

            decimal totalPrice  = new decimal();
            decimal totalProfit = new decimal();

            foreach (OrderProductRecordModel orderProductRecord in OrderProductRecords)
            {
                totalPrice  += orderProductRecord.OrderProduct.GetTotalPrice;
                totalProfit += orderProductRecord.OrderProduct.GetTotalProfit;
            }

            OrderTotalPriceValue.Value = totalPrice;
            TotalProfitValue.Value     = totalProfit;

            if (CashRadioButton.IsChecked == true)
            {
                CustomerWillPayNowValue.Value   = totalPrice;
                CustomerWillPayLaterValue.Value = 0;
            }
            else
            {
                CustomerWillPayNowValue.Value   = 0;
                CustomerWillPayLaterValue.Value = totalPrice;
            }

            // Scrol to the last
            if (OrderProductRecords.Count > 0)
            {
                OrderProductRecordList.ScrollIntoView(OrderProductRecords.Last());
            }
        }
Пример #2
0
        private void RemoveSelectedProductButton_Click(object sender, RoutedEventArgs e)
        {
            OrderProductRecordModel orderProductRecord = (OrderProductRecordModel)OrderProductRecordList.SelectedItem;

            if (orderProductRecord != null)
            {
                OrderProductRecords.Remove(orderProductRecord);
                UpdateTotalPriceAndTotalProfit();
            }
        }
Пример #3
0
        private void AddOrderProductButton_Click(object sender, RoutedEventArgs e)
        {
            OrderProductRecordModel orderProductRecord = new OrderProductRecordModel();

            OrderProductModel orderProduct = new OrderProductModel();

            orderProduct.Product   = (ProductModel)ProductNameSearchValue.SelectedItem;
            orderProduct.Quantity  = (float)OrderProductQuantityValue.Value.Value;
            orderProduct.SalePrice = StockSalePriceValue.Value.Value;

            orderProductRecord.Stock        = (StockModel)SBarCodeSearchValue.SelectedItem;
            orderProductRecord.OrderProduct = orderProduct;

            if (CheckIfThisStockAddedBefore(orderProductRecord) == false)
            {
                // Validation
                GlobalConfig.OrderProductRecordValidator = new OrderProductRecordValidator();

                ValidationResult result = GlobalConfig.OrderProductRecordValidator.Validate(orderProductRecord);

                if (result.IsValid == false)
                {
                    MessageBox.Show(result.Errors[0].ErrorMessage);
                }
                else
                {
                    orderProductRecord = OrderProductRecord.DiscountAndProfitCalculations(orderProductRecord);

                    OrderProductRecords.Add(orderProductRecord);
                    UpdateTotalPriceAndTotalProfit();
                }
            }
            else
            {
                MessageBox.Show("This stock is used before in this order if you need to adjust it remove and add again.");
            }
        }