示例#1
0
        private void CartOpenLabelClick(object sender, MouseButtonEventArgs e)
        {
            string Login = "";

            if (Registration.Header.ToString() != "Зарегистрироваться")
            {
                Login = Registration.Header.ToString().Substring(Registration.Header.ToString().IndexOf(',') + 2);
            }
            CartWindow cartWindow = new CartWindow(basket, Login);

            cartWindow.ShowDialog();
        }
示例#2
0
        private void BuyButton_Click(object sender, RoutedEventArgs e)
        {
            var element = emptyGrid.Children.Cast <UIElement>().
                          First(el => Grid.GetColumn(el) == 0 && Grid.GetRow(el) == 0);
            NumericUpDown numericUp = (element as NumericUpDown);

            int boughtAmount;

            if (!Int32.TryParse(numericUp.Value.ToString(), out boughtAmount))
            {
                MessageBox.Show("Проверьте правильность ввода данных");
            }
            else
            {
                string wprice = "";

                if (ShowedDrug.WPricesList.Count > 0)
                {
                    int i = 0;
                    while (i < ShowedDrug.WPricesList.Count &&
                           boughtAmount >= ShowedDrug.WPricesList[i].Minimal_amount_of_product)
                    {
                        i++;
                    }
                    if (i != 0)
                    {
                        wprice = ShowedDrug.WPricesList[i - 1].Price;
                    }
                }
                if (boughtAmount < ShowedDrug.Current_amount)
                {
                    if (wprice != String.Empty)
                    {
                        Basket.Add(new Tuple <Drug, int, string>(ShowedDrug, boughtAmount, wprice));
                    }
                    else
                    {
                        Basket.Add(new Tuple <Drug, int, string>(ShowedDrug,
                                                                 boughtAmount, ShowedDrug.Retail_price));
                    }
                    CartWindow cartWindow = new CartWindow(Basket, Login);
                    Hide();
                    cartWindow.ShowDialog();
                    Close();
                }
                else
                {
                    MessageBox.Show($"На данный момент у нас не имеется " +
                                    $"этот продукт в таком количестве {boughtAmount}");
                }
            }
        }