예제 #1
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            List <string> products = new List <string>();

            for (int i = 0; i < lstprod.Items.Count; i++)
            {
                for (int j = 0; j < (int)lstcnt.Items[i]; j++)
                {
                    products.Add(lstprod.Items[i].ToString());
                }
            }
            string[] cust = txtcus.Text.Split(new char[] { ' ' });
            string[] salm = txtsal.Text.Split(new char[] { ' ' });

            Dictionary <string, int> dict = new Dictionary <string, int>();

            for (int i = 0; i < lstprod.Items.Count; i++)
            {
                dict.Add(lstprod.Items[i].ToString(), (int)lstcnt.Items[i]);
            }

            dBShop.AddOrder(cust[1], salm[1], dict);


            MessageBox.Show("Спасибо за покупку");
            this.Close();
            lst1num.Items.Clear();
            lstcnt.Items.Clear();
            lstpr.Items.Clear();
            lstprod.ItemsSource = null;
            Confirm.Products.Clear();
            Confirm.Count.Clear();
        }
예제 #2
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            if (!dBShop.IsExist())
            {
                dBShop.AddSeller("Cristiano", "Ronaldo");
                dBShop.AddSeller("Andrey", "Shevchenko");

                dBShop.AddCustomer(new List <Customer>
                {
                    new Customer {
                        LastName = "Bale", FirstName = "Gareth"
                    },
                    new Customer {
                        LastName = "Benzema", FirstName = "Karim"
                    },
                    new Customer {
                        LastName = "Asensio", FirstName = "Marco"
                    },
                    new Customer {
                        LastName = "Pogba", FirstName = "Paul"
                    },
                    new Customer {
                        LastName = "Kylian", FirstName = "Mbappe"
                    }
                });

                dBShop.AddDepartment("MobilePhones", new List <Product> {
                    new Product {
                        ProductName = "IPHONE 10", Price = 20000
                    },
                    new Product {
                        ProductName = "SAMSUNG S9", Price = 18000
                    },
                    new Product {
                        ProductName = "HUAWEI P20 Lite", Price = 14000
                    }
                });
                dBShop.AddDepartment("TV", new List <Product> {
                    new Product {
                        ProductName = "LG 43UJ630V", Price = 25000
                    },
                    new Product {
                        ProductName = "SAMSUNG UE40J5200AUXUA", Price = 22000
                    },
                    new Product {
                        ProductName = "SONY KD43XE7096BR", Price = 19000
                    }
                });
                dBShop.AddDepartment("Laptops", new List <Product> {
                    new Product {
                        ProductName = "LENOVO Legion Y520-15IKBN", Price = 11000
                    },
                    new Product {
                        ProductName = "APPLE A1466 MacBook Air", Price = 15000
                    },
                    new Product {
                        ProductName = "ASUS F541NA-GO188", Price = 12000
                    }
                });
                dBShop.AddDepartment("Friges", new List <Product> {
                    new Product {
                        ProductName = "GORENJE NRK 611 PS4", Price = 16000
                    },
                    new Product {
                        ProductName = "SAMSUNG RB37J5220SA", Price = 12000
                    },
                    new Product {
                        ProductName = "LG GA-B499YLUZ", Price = 22000
                    }
                });
                dBShop.AddOrder("Benzema", "Shevchenko", new Dictionary <string, int>
                {
                    { "IPHONE 10", 2 },
                    { "ASUS F541NA-GO188", 3 }
                });
            }

            cmbcus.ItemsSource = dBShop.CustomersList();
            cmbdpt.Items.Add("Все товары");
            cmbsal.ItemsSource = dBShop.SalasmenList();
            // cmbdpt.ItemsSource = dBShop.DepartmentList();
            dBShop.DepartmentList().ForEach(item => cmbdpt.Items.Add(item));
            cmbcnt.ItemsSource = new List <int> {
                1, 2, 3, 4, 5
            };
            cmbdpt.SelectedIndex  = 0;
            cmbprod.SelectedIndex = 0;
            cmbcnt.SelectedIndex  = 0;
            cmbcus.SelectedIndex  = 0;
            cmbsal.SelectedIndex  = 0;
        }