Esempio n. 1
0
 public EditManufacturerWindow(DataGrid dataGrid)
 {
     InitializeComponent();
     DataGrid            = dataGrid;
     dictionaryCountries = Country.GetCountries().OrderBy(x => x.CountryName).ToList();
     foreach (Country country in dictionaryCountries)
     {
         CountriesComboBox.Items.Add(country.CountryName);
     }
 }
Esempio n. 2
0
        public BuyProductWindow(int drugID,
                                List <Tuple <Drug, int, string> > basket, string login) : this()
        {
            Login      = login;
            ShowedDrug = new Drug(drugID);
            Basket     = basket;
            NumericUpDown numericUpDown = new NumericUpDown
            {
                FontSize = 25,
                Height   = 40,
                Value    = 1,
                Name     = "numericUpDown"
            };

            Grid.SetColumn(numericUpDown, 0);
            Grid.SetRow(numericUpDown, 0);
            emptyGrid.Children.Add(numericUpDown);

            DrugNameLabel.Content   = $"{ShowedDrug.Drug_name}, {ShowedDrug.Weight_Volume}";
            PriceLabel.Content      = $"{ShowedDrug.Retail_price} грн.";
            Availability.Content    = ShowedDrug.Current_amount > 0 ? "В наличии" : "Нет в наличии";
            Availability.Foreground = ShowedDrug.Current_amount > 0 ? Brushes.Green : Brushes.Red;
            BitmapImage bitmap = new BitmapImage();

            bitmap.BeginInit();
            bitmap.UriSource = new Uri(ShowedDrug.URL_photo, UriKind.Absolute);
            bitmap.EndInit();
            DrugImage.Source = bitmap;


            Label label = new Label();

            label.Content += "Производители: ";
            label.FontSize = 16;
            for (int i = 0; i < ShowedDrug.ManufacturersList.Count; i++)
            {
                label.Content += ShowedDrug.ManufacturersList[i].ManufacturerName;
                if (i != ShowedDrug.ManufacturersList.Count - 1)
                {
                    label.Content += ", ";
                }
            }
            ManufacturersChar.Children.Add(label);
            ShowedDrug.ManufacturersList.Distinct(new ManufacturerComparer());
            List <Country> list = Country.GetCountries();

            Label CountryLabel = new Label
            {
                FontSize = 16
            };

            if (ShowedDrug.ManufacturersList.Count > 1)
            {
                CountryLabel.Content += "Страны-производители: ";
            }
            else
            {
                CountryLabel.Content += "Страна-производитель: ";
            }
            for (int i = 0; i < ShowedDrug.ManufacturersList.Count; i++)
            {
                string countryname = list
                                     .Where(x => x.CountryID == ShowedDrug.ManufacturersList[i].CountryID)
                                     .Select(x => x.CountryName)
                                     .First()
                                     .ToString();

                CountryLabel.Content += countryname;
                if (i != ShowedDrug.ManufacturersList.Count - 1)
                {
                    CountryLabel.Content += ", ";
                }
            }
            CountriesChar.Children.Add(CountryLabel);

            if (ShowedDrug.WPricesList.Count > 0)
            {
                ShowedDrug.WPricesList = ShowedDrug.WPricesList.OrderBy(x => x.Minimal_amount_of_product).ToList();
                foreach (WholesalePriceClient wp in ShowedDrug.WPricesList)
                {
                    TextBlock textBlock = new TextBlock
                    {
                        FontSize = 18,
                        Text     = $"При заказе от {wp.Minimal_amount_of_product} шт.\n {wp.Price} грн."
                    };
                    WholesalePrices.Children.Add(textBlock);
                }
            }

            ApplicationTextBox.Text = ShowedDrug.Application;
            WarningTextBox.Text     = ShowedDrug.Warning;
            DescriptionTextBox.Text = ShowedDrug.Description;
        }
Esempio n. 3
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            dictionaryManufacturers = Manufacturer.GetManufacturers();
            dictionarySymptoms      = Symptom.GetSymptoms();
            dictionaryCountries     = Country.GetCountries();

            foreach (Manufacturer manufacturer in dictionaryManufacturers)
            {
                CheckBox checkBox = new CheckBox
                {
                    Content = manufacturer.ManufacturerName
                };
                ManufacturerScrollViewer.Children.Add(checkBox);
            }
            foreach (Country country in dictionaryCountries)
            {
                CheckBox checkBox = new CheckBox
                {
                    Content = country.CountryName
                };
                checkBox.Click += CountryCheckBoxChange;
                CountryScrollViewer.Children.Add(checkBox);
            }
            foreach (Symptom symptom in dictionarySymptoms)
            {
                Button button = new Button();
                button.Click  += SymptomButton_Click;
                button.Content = symptom.SymptomName;
                SymptomScrollViewer.Children.Add(button);
            }

            //Randoming purchases

            //List<Drug> listOfDrugs = Drug.GetAllDrugs();

            //Random random = new Random();
            //for (int i = 0; i < 100; i++)
            //{
            //    int number = random.Next() % listOfDrugs.Count;
            //    int amount = random.Next() % 10 + 1;
            //    string wprice = "";

            //    if (listOfDrugs[number].WPricesList.Count > 0)
            //    {
            //        int j = 0;
            //        while (j < listOfDrugs[number].WPricesList.Count
            //            && amount >= listOfDrugs[number].WPricesList[j].Minimal_amount_of_product)
            //        {
            //            j++;
            //        }
            //        if (j != 0)
            //        {
            //            wprice = listOfDrugs[number].WPricesList[j - 1].Price;
            //        }
            //    }
            //    if (wprice != String.Empty)
            //    {
            //        List<Tuple<Drug, int, string>> d = new List<Tuple<Drug, int, string>>() {
            //            new Tuple<Drug, int, string>(listOfDrugs[number], amount, wprice)
            //        };
            //        Drug.AddPurchase(d, "newuser");
            //    }
            //    else
            //    {
            //        List<Tuple<Drug, int, string>> d = new List<Tuple<Drug, int, string>>() {
            //            new Tuple<Drug, int, string>(listOfDrugs[number], amount, listOfDrugs[number].Retail_price)
            //        };
            //        Drug.AddPurchase(d, "newuser");
            //    }

            //}

            ShowContent(FormFilterRequest());
        }