/// <summary>
 /// Methods
 /// </summary>
 private WareHouseProductModel LoadProducts()
 {
     try
     {
         var wareHouseList = _wareHouseData.GetProducts();
         var products      = _mapper.Map <List <WareHouseProductModel> >(wareHouseList);
         WareHouseProducts = new BindableCollection <WareHouseProductModel>(products);
         var sumOfNetPrices          = wareHouseList.Sum(x => x.NetPrice * x.QuantityInStock);
         var sumOfSellPrices         = wareHouseList.Sum(x => x.SellPrice * x.QuantityInStock);
         WareHouseProductModel model = new WareHouseProductModel
         {
             SellPrice = sumOfSellPrices,
             NetPrice  = sumOfNetPrices
         };
         return(model);
     }
     catch (Exception ex)
     {
         MessageBox.Show("Message: \n" + ex.Message + '\n' +
                         "StackTrase: \n" + ex.StackTrace + '\n' +
                         "InnerException: \n" + ex.InnerException);
         return(new WareHouseProductModel
         {
             SellPrice = 0,
             NetPrice = 0
         });
     }
 }
 public void RefreshView()
 {
     modelSums       = LoadProducts();
     SumOfNetPrices  = "Сума цін купівлі = " + modelSums.NetPrice.ToString("c");
     SumOfSellPrices = "Сума цін продажу = " + modelSums.SellPrice.ToString("c");
     this.Refresh();
 }
Exemplo n.º 3
0
 public void RefreshSums()
 {
     modelSums       = CountSums();
     SumOfNetPrices  = "Сума цін купівлі: " + modelSums.NetPrice.ToString("c");
     SumOfSellPrices = "Сума цін продажу: " + modelSums.SellPrice.ToString("c");
     Profit          = "Прибуток: " + (modelSums.SellPrice - modelSums.NetPrice).ToString("c");
 }
Exemplo n.º 4
0
 /// <summary>
 /// Event handlers
 /// </summary>
 public void Handle(MakeToBuyEventModel products)
 {
     LoadClients();
     ProductsForOrder = products.ToBuyProducts;
     modelSums        = CountSums();
     SumOfNetPrices   = "Сума цін купівлі: " + modelSums.NetPrice.ToString("c");
     SumOfSellPrices  = "Сума цін продажу: " + modelSums.SellPrice.ToString("c");
     Profit           = "Прибуток: " + (modelSums.SellPrice - modelSums.NetPrice).ToString("c");
 }
 /// <summary>
 /// Event handlers
 /// </summary>
 public void Handle(OrderEventModel order)
 {
     LoadClients();
     ProductsForOrder = order.OrderProducts;
     LoadMaxQuantities();
     modelSums       = CountSums();
     SumOfNetPrices  = "Сума цін купівлі: " + modelSums.NetPrice.ToString("c");
     SumOfSellPrices = "Сума цін продажу: " + modelSums.SellPrice.ToString("c");
     Profit          = "Прибуток: " + (modelSums.SellPrice - modelSums.NetPrice).ToString("c");
 }
Exemplo n.º 6
0
        /// <summary>
        /// Methods
        /// </summary>
        private WareHouseProductModel CountSums()
        {
            var sumOfNetPrices          = ProductsForOrder.Sum(x => x.NetPrice * x.QuantityInStock);
            var sumOfSellPrices         = ProductsForOrder.Sum(x => x.SellPrice * x.QuantityInStock);
            WareHouseProductModel model = new WareHouseProductModel
            {
                SellPrice = sumOfSellPrices,
                NetPrice  = sumOfNetPrices
            };

            return(model);
        }
 public WareHauseViewModel(IMapper mapper, IEventAggregator events, MakeOrderViewModel makeOrderView,
                           IWindowManager windowManager, IWareHouseData wareHouseData)
 {
     Thread.CurrentThread.CurrentCulture = new CultureInfo("de-DE");
     _mapper        = mapper;
     _wareHouseData = wareHouseData;
     _events        = events;
     _events.Subscribe(this);
     _windowManager  = windowManager;
     _makeOrdersView = makeOrderView;
     modelSums       = LoadProducts();
     SumOfNetPrices  = "Сума цін купівлі: " + modelSums?.NetPrice.ToString("c");
     SumOfSellPrices = "Сума цін продажу: " + modelSums?.SellPrice.ToString("c");
 }
Exemplo n.º 8
0
 public void RefreshSums()
 {
     try
     {
         modelSums       = CountSums();
         SumOfNetPrices  = "Сума цін купівлі: " + modelSums.NetPrice.ToString("c");
         SumOfSellPrices = "Сума цін продажу: " + modelSums.SellPrice.ToString("c");
         Profit          = "Прибуток: " + (modelSums.SellPrice - modelSums.NetPrice).ToString("c");
     }
     catch (Exception ex)
     {
         MessageBox.Show("Message: \n" + ex.Message + '\n' +
                         "StackTrase: \n" + ex.StackTrace + '\n' +
                         "InnerException: \n" + ex.InnerException);
     }
 }
        private void LoadPlaceholder()
        {
            WareHouseProductModel placeholder = new WareHouseProductModel()
            {
                FactoryNumber      = "",
                Name               = "",
                Set                = "",
                Type               = "",
                QuantityInStock    = 0,
                ProductDescription = "",
                NetPrice           = 0,
                SellPrice          = 0
            };

            ProductsToAdd.Add(placeholder);
        }
Exemplo n.º 10
0
 /// <summary>
 /// Event handlers
 /// </summary>
 public void Handle(OrderDetailsEventModel order)
 {
     try
     {
         LoadOrder(order);
         modelSums       = CountSums();
         SumOfNetPrices  = "Сума цін купівлі: " + modelSums.NetPrice.ToString("c");
         SumOfSellPrices = "Сума цін продажу: " + modelSums.SellPrice.ToString("c");
         Profit          = "Прибуток: " + (modelSums.SellPrice - modelSums.NetPrice).ToString("c");
     }
     catch (Exception ex)
     {
         MessageBox.Show("Message: \n" + ex.Message + '\n' +
                         "StackTrase: \n" + ex.StackTrace + '\n' +
                         "InnerException: \n" + ex.InnerException);
     }
 }
 /// <summary>
 /// Event handlers
 /// </summary>
 public void Handle(ToBuyDetailsEventModel toBuys)
 {
     try
     {
         ProductsToBuy   = toBuys.ToBuyProducts;
         SelectedClient  = toBuys.Client;
         modelSums       = CountSums();
         SumOfNetPrices  = "Сума цін купівлі: " + modelSums.NetPrice.ToString("c");
         SumOfSellPrices = "Сума цін продажу: " + modelSums.SellPrice.ToString("c");
         Profit          = "Прибуток: " + (modelSums.SellPrice - modelSums.NetPrice).ToString("c");
     }
     catch (Exception ex)
     {
         MessageBox.Show("Message: \n" + ex.Message + '\n' +
                         "StackTrase: \n" + ex.StackTrace + '\n' +
                         "InnerException: \n" + ex.InnerException);
     }
 }
Exemplo n.º 12
0
        public static string isWrongWareHouseProductMassageToBuy(WareHouseProductModel wareHouseProductModel)
        {
            wareHouseProductModel.FactoryNumber = Regex.Replace(wareHouseProductModel.FactoryNumber, @"\s+", "");

            string message = "Неправильно введено: \n";

            if (String.IsNullOrEmpty(wareHouseProductModel.FactoryNumber) ||
                IsDigitsOnly(wareHouseProductModel.FactoryNumber) == false ||
                wareHouseProductModel.FactoryNumber.Length != 10)
            {
                message += $"Заводський номер: {wareHouseProductModel.FactoryNumber}.\n";
            }
            if (String.IsNullOrEmpty(wareHouseProductModel.Name))
            {
                message += $"Ви забули ввести ім'я: {wareHouseProductModel.FactoryNumber}.\n";
            }
            if (String.IsNullOrEmpty(wareHouseProductModel.Set))
            {
                message += $"Ви забули ввести сервіз: {wareHouseProductModel.FactoryNumber}.\n";
            }
            if (String.IsNullOrEmpty(wareHouseProductModel.Type))
            {
                message += $"Ви забули ввести тип: {wareHouseProductModel.FactoryNumber}.\n";
            }
            if (wareHouseProductModel.Photo == null)
            {
                message += $"Ви забули вибрати фото: {wareHouseProductModel.FactoryNumber}.\n";
            }
            if (wareHouseProductModel.QuantityInStock < 0)
            {
                message += $"Неправильно введена кількість: {wareHouseProductModel.FactoryNumber}.\n";
            }
            if (wareHouseProductModel.NetPrice < 0)
            {
                message += $"Неправильно введена ціна покупки: {wareHouseProductModel.FactoryNumber}.\n";
            }
            if (wareHouseProductModel.SellPrice < 0)
            {
                message += $"Неправильно введена ціна продажу: {wareHouseProductModel.FactoryNumber}.\n";
            }
            return(message);
        }
        public void isCorrectWareHouseProductToBuy_ShouldCheck(string factoryNumber, string name, string set, string type,
                                                               int quantityInStock, decimal netPrice, decimal sellPrice, bool _expected)
        {
            WareHouseProductModel product = new WareHouseProductModel()
            {
                FactoryNumber   = factoryNumber,
                Name            = name,
                Set             = set,
                Type            = type,
                Photo           = goodImage,
                QuantityInStock = quantityInStock,
                NetPrice        = netPrice,
                SellPrice       = sellPrice
            };

            bool actual = InputHelper.isCorrectWareHouseProductToBuy(product);

            bool expected = _expected;

            Assert.Equal(actual, expected);
        }
Exemplo n.º 14
0
        public static bool isCorrectWareHouseProduct(WareHouseProductModel wareHouseProductModel)
        {
            wareHouseProductModel.FactoryNumber = Regex.Replace(wareHouseProductModel.FactoryNumber, @"\s+", "");

            if (String.IsNullOrEmpty(wareHouseProductModel.FactoryNumber) ||
                IsDigitsOnly(wareHouseProductModel.FactoryNumber) == false ||
                wareHouseProductModel.FactoryNumber.Length != 10)
            {
                return(false);
            }
            if (String.IsNullOrEmpty(wareHouseProductModel.Name))
            {
                return(false);
            }
            if (String.IsNullOrEmpty(wareHouseProductModel.Set))
            {
                return(false);
            }
            if (String.IsNullOrEmpty(wareHouseProductModel.Type))
            {
                return(false);
            }
            if (wareHouseProductModel.Photo == null)
            {
                return(false);
            }
            if (wareHouseProductModel.QuantityInStock < 0)
            {
                return(false);
            }
            if (wareHouseProductModel.NetPrice <= 0)
            {
                return(false);
            }
            if (wareHouseProductModel.SellPrice <= 0)
            {
                return(false);
            }
            return(true);
        }