コード例 #1
0
ファイル: MainWindow.xaml.cs プロジェクト: miki1840/BootCamp
        private void RaportButton_Click(object sender, RoutedEventArgs e)
        {
            if (_dataBase.Count > 0)
            {
                EMainMenu chose = 0;
                chose += MenuComboBox.SelectedIndex;
                ScoreLable.Content = "";
                ProductRaportWindow productRaportWindow;
                OrdersRaportWindow  ordersRaportWindow;
                switch (chose)
                {
                case EMainMenu.QuantityOfOrdersByName:
                    var resultQuantityOfOrdersByName = Task <List <ProductRow> > .Run(() =>
                    {
                        return(_raportGenerator.QuantityOfOrdersByName());
                    });

                    productRaportWindow = new ProductRaportWindow();
                    productRaportWindow.Init(resultQuantityOfOrdersByName.Result,
                                             "Ilość zamówień pogrupowanych po nazwie");
                    productRaportWindow.Show();
                    break;

                case EMainMenu.ListOfOrders:
                    var resultListOfOrders =
                        Task <List <Order> > .Run(() => { return(_raportGenerator.ListOfOrders()); });

                    ordersRaportWindow = new OrdersRaportWindow();
                    ordersRaportWindow.Init(resultListOfOrders.Result, "Łączna kwota zamówień");
                    ordersRaportWindow.Show();
                    break;

                case EMainMenu.AvreageCostOfClientOrder:
                    if (TextBox1.Text.Length > 0)
                    {
                        string clientId = TextBox1.Text;     //być może warunki
                        var    resultAvreageCostOfClientOrtder = Task <double> .Run(() =>
                        {
                            return(_raportGenerator.AvreageCostOfClientsOrder(clientId));
                        });

                        ScoreLable.Content = "Średnia wartość zamówień klienta o identyfikatorze: " + clientId +
                                             " to: " + Math.Round(resultAvreageCostOfClientOrtder.Result, 2);
                    }

                    break;

                case EMainMenu.AvreageCostOfOrder:
                    var resultAvreageCostOfOrdre = Task <double> .Run(() =>
                    {
                        return(_raportGenerator.AverageCostOfOrfder());
                    });

                    ScoreLable.Content = "Średnia wartość zamówienia wynosi: " +
                                         Math.Round(resultAvreageCostOfOrdre.Result, 2);
                    break;

                case EMainMenu.ListOfClientsOrders:
                    if (TextBox1.Text.Length > 0)
                    {
                        string clientId = TextBox1.Text;     //być może warunki
                        var    resultListOfClientsorders = Task <List <Order> > .Run(() =>
                        {
                            return(_raportGenerator.ListOfClientsOrders(clientId));
                        });

                        ordersRaportWindow = new OrdersRaportWindow();
                        ordersRaportWindow.Init(resultListOfClientsorders.Result,
                                                "Lista zamówień dla klienta o identyfikatorze " + clientId);
                        ordersRaportWindow.Show();
                    }

                    break;

                case EMainMenu.QuantityOfClientsOrdersByName:
                    if (TextBox1.Text.Length > 0)
                    {
                        string clientId = TextBox1.Text;     //być może warunki
                        var    resultQuantityOfClientsOrdersByName = Task <List <ProductRow> > .Run(() =>
                        {
                            return(_raportGenerator.QuantiOfCleintsOrdersByName(clientId));
                        });

                        productRaportWindow = new ProductRaportWindow();
                        productRaportWindow.Init(resultQuantityOfClientsOrdersByName.Result, "Lista produktów zakupionych przez klienta o identyfikatorze: " + clientId);
                        productRaportWindow.Show();
                    }

                    break;

                case EMainMenu.OrdersBetwenCost:
                    double lowerBound, upperBound;
                    if (double.TryParse(TextBox1.Text, out lowerBound) &&
                        double.TryParse(TextBox2.Text, out upperBound))
                    {
                        var resultOrdersBetweanCost = Task <List <Order> > .Run(() =>
                        {
                            return(_raportGenerator.OrdersBetwenCost(lowerBound, upperBound));
                        });

                        ordersRaportWindow = new OrdersRaportWindow();
                        ordersRaportWindow.Init(resultOrdersBetweanCost.Result,
                                                "Zamówienia na kwotę od " + lowerBound + " do " + upperBound);
                        ordersRaportWindow.Show();
                    }

                    break;

                case EMainMenu.SumedCostOfOrders:
                    var resultSumedCostOfOrders =
                        Task <double> .Run(() => { return(_raportGenerator.SumedCostOfOrdes()); });

                    ScoreLable.Content = "Łączna suma zamówień wynosi: " + Math.Round(resultSumedCostOfOrders.Result, 2);
                    break;

                case EMainMenu.SumedCostOfClientOrders:
                    if (TextBox1.Text.Length > 0)
                    {
                        string clientId = TextBox1.Text;     //być może warunki
                        var    resultSumedCostOfClientOrders = Task <double> .Run(() =>
                        {
                            return(_raportGenerator.SumCostOfClientsOrders(clientId));
                        });

                        ScoreLable.Content = "Łączny koszt zamówień klienta o identyfikatorze " + clientId +
                                             " to " +
                                             Math.Round((double)resultSumedCostOfClientOrders.Result, 2);
                    }

                    break;

                case EMainMenu.QuantityOdClientOrders:
                    if (TextBox1.Text.Length > 0)
                    {
                        string clientId = TextBox1.Text;     //być może warunk
                        var    resultQuantityOfClientOrders = Task <int> .Run(() =>
                        {
                            return(_raportGenerator.QuantityOfClientOrders(clientId));
                        });

                        ScoreLable.Content = "Ilość zamówień klienta o identyfikatorze " + clientId + " to " +
                                             resultQuantityOfClientOrders.Result;
                    }

                    break;

                case EMainMenu.QuantityOfOrders:
                    var resultQuantityOfOrders =
                        Task <int> .Run(() => { return(_raportGenerator.QuantityOfOrders()); });

                    ScoreLable.Content = "Ilość wszystkich zamówień to " + resultQuantityOfOrders.Result;
                    break;
                }
            }
            else
            {
                MessageBox.Show("Baza danych jest pusta.");
            }
        }
コード例 #2
0
ファイル: MainWindow.xaml.cs プロジェクト: miki1840/BootCamp
        private void MenuComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            EMainMenu chose = 0;

            chose += MenuComboBox.SelectedIndex;
            switch (chose)
            {
            case EMainMenu.AvreageCostOfClientOrder:
                HideFields();
                Lable1.Visibility   = Visibility.Visible;
                Lable1.Content      = "Identyfikator klienta: ";
                TextBox1.Text       = "";
                TextBox1.Visibility = Visibility.Visible;
                break;

            case EMainMenu.AvreageCostOfOrder:
                HideFields();
                break;

            case EMainMenu.ListOfClientsOrders:
                HideFields();
                Lable1.Visibility   = Visibility.Visible;
                Lable1.Content      = "Identyfikator klienta: ";
                TextBox1.Visibility = Visibility.Visible;
                break;

            case EMainMenu.ListOfOrders:
                HideFields();
                break;

            case EMainMenu.OrdersBetwenCost:
                Lable1.Visibility   = Visibility.Visible;
                Lable1.Content      = "Minimalna wartość:";
                TextBox1.Visibility = Visibility.Visible;
                Lable2.Visibility   = Visibility.Visible;
                Lable2.Content      = "Maksymalna Wartość";
                TextBox2.Visibility = Visibility.Visible;
                break;

            case EMainMenu.SumedCostOfOrders:
                HideFields();
                break;

            case EMainMenu.SumedCostOfClientOrders:
                HideFields();
                Lable1.Visibility   = Visibility.Visible;
                Lable1.Content      = "Identyfikator klienta: ";
                TextBox1.Visibility = Visibility.Visible;
                break;

            case EMainMenu.QuantityOfOrders:
                HideFields();
                break;

            case EMainMenu.QuantityOdClientOrders:
                HideFields();
                Lable1.Visibility   = Visibility.Visible;
                Lable1.Content      = "Identyfikator klienta: ";
                TextBox1.Visibility = Visibility.Visible;
                break;

            case EMainMenu.QuantityOfOrdersByName:
                HideFields();
                break;

            case EMainMenu.QuantityOfClientsOrdersByName:
                HideFields();
                Lable1.Visibility   = Visibility.Visible;
                Lable1.Content      = "Identyfikator klienta: ";
                TextBox1.Visibility = Visibility.Visible;
                break;
            }
        }