Ejemplo n.º 1
0
        // End competition
        public void EndCompetitionMaster()
        {
            // Disable buttons
            btnNext.IsEnabled = false;
            btnBack.IsEnabled = false;

            btnEnd.IsEnabled     = false;
            setTeamBtn.IsEnabled = false;

            // End competiton
            listViewCompetitiors.ItemsSource = null;
            stackPanelShots.IsEnabled        = false;
            btnSetShots.IsEnabled            = false;
            btnSearch.IsEnabled      = false;
            btnSearchClear.IsEnabled = false;
            btnResetShots.IsEnabled  = false;

            FillUnfiled();

            //Show Shots
            roundChanged(Competition.Round, Competition.TarType);

            //Sorts by hits & total score
            Competition.EndCompetition();

            //Enable Statistics in the end
            menuItemStat.IsEnabled = true;

            WindowStatistics winstat = new WindowStatistics(Competition);

            winstat.Show();

            WriteToDB();
            /* Write to DB + message */
            MessageBox.Show("Competition ended, oppening statisctics window.", "End", MessageBoxButton.OK, MessageBoxImage.Exclamation);
            mainW.ReloadSource();
            Close();
        }
Ejemplo n.º 2
0
        // IMPLEMENTACIJA LOADANJA IZ DB
        public void LoadFromDB()
        {
            PreciseShooting competition = new PreciseShooting(long.Parse(labelId.Content.ToString()), labelTitle.Content.ToString(), labelRange.Content.ToString(), DateTime.Parse(labelDate.Content.ToString()), int.Parse(labelType.Content.ToString()), int.Parse(labelShots.Content.ToString()), int.Parse(labelRounds.Content.ToString()));
            Shooter         cshooter;

            if (competition == null)
            {
                return;
            }

            try
            {
                using (SQLiteConnection conn = dBManager.GetConnection())
                {
                    SQLiteCommand command = conn.CreateCommand();
                    command.CommandText = dBManager.sqlLibrary["selectForStatistics"];
                    command.Parameters.Add(new SQLiteParameter("cid", competition.Id));
                    conn.Open();


                    using (SQLiteDataReader reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            cshooter = new Shooter(long.Parse(reader["id"].ToString()), reader["name"].ToString(), reader["surname"].ToString(), reader["cname"].ToString(), reader["team"].ToString());

                            List <int?> nullhits = new List <int?>();

                            nullhits.Add(reader.GetInt32(6));
                            nullhits.Add(reader.GetInt32(7));
                            nullhits.Add(reader.GetInt32(8));
                            nullhits.Add(reader.GetInt32(9));
                            nullhits.Add(reader.GetInt32(10));
                            nullhits.Add(reader.GetInt32(11));
                            nullhits.Add(reader.GetInt32(12));
                            nullhits.Add(reader.GetInt32(13));
                            nullhits.Add(reader.GetInt32(14));
                            nullhits.Add(reader.GetInt32(15));
                            nullhits.Add(reader.GetInt32(16));
                            nullhits.Add(reader.GetInt32(17));

                            List <int> hits = new List <int>();
                            // Fill non null
                            foreach (int?hit in nullhits)
                            {
                                if (hit != null)
                                {
                                    hits.Add((int)hit);
                                }
                                else
                                {
                                    break;
                                }
                            }

                            // If shoots length discreptency break
                            if (hits.Count != 13 - competition.TarType)
                            {
                                MessageBox.Show("Data corupted!", "Error!");
                                return;
                            }
                            cshooter.ScoresPRound.Add(hits);

                            //Fill remaining hits with lists filled with zero
                            for (int i = 1; i < competition.Round; i++)
                            {
                                cshooter.ScoresPRound.Add(new List <int>(new int[13 - competition.TarType]));
                            }
                            // Add Constructed shooter
                            competition.Shooters.Add(cshooter);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message, "Exception");
            }
            competition.EndCompetition();
            WindowStatistics statWin = new WindowStatistics(competition);

            statWin.Show();
        }
Ejemplo n.º 3
0
        //At the end show statistics
        private void menuItemStat_Click(object sender, RoutedEventArgs e)
        {
            WindowStatistics window = new WindowStatistics(Competition);

            window.Show();
        }