public NopsCalcForm()
        {
            InitializeComponent();
            appNopsCalc = CalcNops.Instance;
            appNopsCalc.LoadDataForTour();
            myNopsDataTable = appNopsCalc.NopsDataTable;
            //dataGridView.DataSource = myNopsDataTable;
            //N.PK, SkiYear, Event, AgeGroup, V.SortSeq as SortSeqDiv, N.SortSeq, Base, Adj, RatingOpen, RatingRec, RatingMedian, OverallBase, OverallExp, EventsReqd
            //dataGridView.Columns["PK"].Visible = false;

            ScoreList.Add( new ScoreEntry( "Slalom", 0, "", 0 ) );
            ScoreList.Add(new ScoreEntry("Trick", 0, "", 0));
            ScoreList.Add(new ScoreEntry("Jump", 0, "", 0));
            ScoreList.Add(new ScoreEntry("Overall", 0, "", 0));

            Event1.Text = ScoreList[0].Event + ": ";
            Score1.Text = Convert.ToString(ScoreList[0].Score);
            Nops1.Text = Convert.ToString(ScoreList[0].Nops);

            Event2.Text = ScoreList[1].Event + ": ";
            Score2.Text = Convert.ToString(ScoreList[1].Score);
            Nops2.Text = Convert.ToString(ScoreList[1].Nops);

            Event3.Text = ScoreList[2].Event + ": ";
            Score3.Text = Convert.ToString(ScoreList[2].Score);
            Nops3.Text = Convert.ToString(ScoreList[2].Nops);

            Event4.Text = ScoreList[3].Event + ": ";
            Nops4.Text = Convert.ToString(ScoreList[3].Nops);
        }
        public ScoreEntry()
        {
            InitializeComponent();

            appNopsCalc = CalcNops.Instance;
            appNopsCalc.LoadDataForTour();
            ScoreList.Add( new Common.ScoreEntry( "Slalom", 0, "", 0 ) );
        }
        private bool execUpdateNops()
        {
            //Update NOPS values due to unavailable 2014 NOPS tables
            //Prior to version 1.0.1.82
            bool curReturnValue = true;

            SqlCeCommand sqlStmt = null;
            SqlCeConnection myDbConn = null;
            DataTable myDataTable = new DataTable();
            StringBuilder curSqlStmt = new StringBuilder();
            List<Common.ScoreEntry> curScoreList = new List<Common.ScoreEntry>();
            int rowsProc, rowUpdateCount = 0;

            try {
                myDbConn = new global::System.Data.SqlServerCe.SqlCeConnection();
                myDbConn.ConnectionString = Properties.Settings.Default.waterskiConnectionStringApp;
                myDbConn.Open();
                sqlStmt = myDbConn.CreateCommand();

                myNopsCalc = CalcNops.Instance;
                myNopsCalc.LoadDataForTour();
                curScoreList.Add( new Common.ScoreEntry( "Trick", 0, "", 0 ) );

                curSqlStmt = new StringBuilder();
                curSqlStmt.Append( "Select PK, SanctionId, MemberId, AgeGroup, Score, Round " );
                curSqlStmt.Append( "From TrickScore " );
                curSqlStmt.Append( "Where SanctionId = '" + mySanctionNum + "' " );
                curSqlStmt.Append( "Order by AgeGroup, MemberId, Round " );
                myDataTable = getData( curSqlStmt.ToString() );

                rowUpdateCount = 0;
                foreach (DataRow curRow in myDataTable.Rows) {
                    try {
                        curScoreList[0].Nops = 0;
                        curScoreList[0].Score = Convert.ToDecimal( (Int16)curRow["Score"] );
                        myNopsCalc.calcNops( (String)curRow["AgeGroup"], curScoreList );

                        sqlStmt.CommandText = "Update TrickScore "
                            + "SET NopsScore = " + Math.Round( curScoreList[0].Nops, 1 ).ToString() + " "
                            + "WHERE PK = " + (Int64)curRow["PK"]
                            + "  And NopsScore != " + Math.Round( curScoreList[0].Nops, 1 ).ToString() + " ";
                        rowsProc = sqlStmt.ExecuteNonQuery();
                        rowUpdateCount += rowsProc;
                        if (rowsProc == 0) {
                            //MessageBox.Show( "Record for " + (String)curRow["MemberId"] + " not updated \nCalculated value is " + Math.Round( curScoreList[0].Nops, 1 ).ToString() );
                        }
                    } catch (Exception ex) {
                        String ExcpMsg = ex.Message;
                        if (sqlStmt != null) {
                            ExcpMsg += "\n" + sqlStmt.CommandText;
                        }
                        MessageBox.Show( "Error updating trick NOPS " + "\n\nError: " + ExcpMsg );
                        curReturnValue = false;
                    }
                }
                MessageBox.Show( myDataTable.Rows.Count.ToString() + " Trick scores read"
                    + "\nTrick NOPS scores updated = " + rowUpdateCount.ToString()
                    + "\nNote: Records with no change in score were bypassed" );

                curScoreList[0].Event = "Jump";
                curSqlStmt = new StringBuilder();
                curSqlStmt.Append( "Select PK, SanctionId, MemberId, AgeGroup, ScoreFeet, Round " );
                curSqlStmt.Append( "From JumpScore " );
                curSqlStmt.Append( "Where SanctionId = '" + mySanctionNum + "' " );
                curSqlStmt.Append( "Order by AgeGroup, MemberId, Round " );
                myDataTable = getData( curSqlStmt.ToString() );

                rowUpdateCount = 0;
                foreach (DataRow curRow in myDataTable.Rows) {
                    try {
                        curScoreList[0].Nops = 0;
                        curScoreList[0].Score = (Decimal)curRow["ScoreFeet"];
                        myNopsCalc.calcNops( (String)curRow["AgeGroup"], curScoreList );

                        sqlStmt.CommandText = "Update JumpScore "
                            + "SET NopsScore = " + Math.Round( curScoreList[0].Nops, 1 ).ToString() + " "
                            + "WHERE PK = " + (Int64)curRow["PK"]
                            + "  And NopsScore != " + Math.Round( curScoreList[0].Nops, 1 ).ToString() + " ";
                        rowsProc = sqlStmt.ExecuteNonQuery();
                        rowUpdateCount += rowsProc;
                        if (rowsProc == 0) {
                            //MessageBox.Show( "Record for " + (String)curRow["MemberId"] + " not updated \nCalculated value is " + Math.Round( curScoreList[0].Nops, 1 ).ToString() );
                        }
                    } catch (Exception ex) {
                        String ExcpMsg = ex.Message;
                        if (sqlStmt != null) {
                            ExcpMsg += "\n" + sqlStmt.CommandText;
                        }
                        MessageBox.Show( "Error updating jump NOPS \n\nError: " + ExcpMsg );
                        curReturnValue = false;
                    }
                }
                MessageBox.Show( myDataTable.Rows.Count.ToString() + " Jump scores read"
                    + "\nJump NOPS scores updated = " + rowUpdateCount.ToString()
                    + "\nNote: Records with no change in score were bypassed" );

                curScoreList[0].Event = "Slalom";
                curSqlStmt = new StringBuilder();
                curSqlStmt.Append( "Select PK, SanctionId, MemberId, AgeGroup, Score, Round " );
                curSqlStmt.Append( "From SlalomScore " );
                curSqlStmt.Append( "Where SanctionId = '" + mySanctionNum + "' " );
                curSqlStmt.Append( "Order by AgeGroup, MemberId, Round " );
                myDataTable = getData( curSqlStmt.ToString() );

                rowUpdateCount = 0;
                foreach (DataRow curRow in myDataTable.Rows) {
                    try {
                        curScoreList[0].Nops = 0;
                        curScoreList[0].Score = (Decimal)curRow["Score"];
                        myNopsCalc.calcNops( (String)curRow["AgeGroup"], curScoreList );

                        sqlStmt.CommandText = "Update SlalomScore "
                            + "SET NopsScore = " + Math.Round( curScoreList[0].Nops, 1 ).ToString() + " "
                            + "WHERE PK = " + (Int64)curRow["PK"]
                            + "  And NopsScore != " + Math.Round( curScoreList[0].Nops, 1 ).ToString() + " ";
                        rowsProc = sqlStmt.ExecuteNonQuery();
                        rowUpdateCount += rowsProc;
                        if (rowsProc == 0) {
                            //MessageBox.Show( "Record for " + (String)curRow["MemberId"] + " not updated \nCalculated value is " + Math.Round( curScoreList[0].Nops, 1 ).ToString() );
                        }
                    } catch (Exception ex) {
                        String ExcpMsg = ex.Message;
                        if (sqlStmt != null) {
                            ExcpMsg += "\n" + sqlStmt.CommandText;
                        }
                        MessageBox.Show( "Error updating Slalom NOPS \n\nError: " + ExcpMsg );
                        curReturnValue = false;
                    }
                }
                MessageBox.Show( myDataTable.Rows.Count.ToString() + " Slalom scores read"
                    + "\nSlalom NOPS scores updated = " + rowUpdateCount.ToString()
                    + "\nNote: Records with no change in score were bypassed" );

            } catch (Exception excp) {
                String curMsg = ":Error attempting to update 2015 Nops values \n" + excp.Message;
                MessageBox.Show( curMsg );
                curReturnValue = false;
            } finally {
                myDbConn.Close();
            }
            return curReturnValue;
        }
        public ScoreEntrySeg3()
        {
            InitializeComponent();

            appNopsCalc = CalcNops.Instance;
            appNopsCalc.LoadDataForTour();
            ScoreList.Add(new Common.ScoreEntry("Jump", 0, "", 0));
            TimeInTolImg.DisplayIndex = 16;

            myCheckEventRecord = new CheckEventRecord();

            jumpRecapDataGridView.AutoGenerateColumns = false;

            //RampHeightTextBox.Visible = false;
            //BoatSpeedTextBox.Visible = false;
        }