Пример #1
0
        private void listAgeDivisionsComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (listAgeDivisionsComboBox.SelectedValue != null)
            {
                String curAgeGroup     = listAgeDivisionsComboBox.SelectedValue.ToString();
                String myFilterCommand = "AgeGroup = '" + curAgeGroup + "'";

                dataGridView.Rows.Clear();
                DataGridViewRow curViewRow;
                int             curIdx      = 0;
                DataRow[]       curFindRows = myNopsDataTable.Select(myFilterCommand);
                foreach (DataRow curDataRow in curFindRows)
                {
                    curIdx     = dataGridView.Rows.Add();
                    curViewRow = dataGridView.Rows[curIdx];
                    //N.PK, SkiYear, Event, AgeGroup, V.SortSeq as SortSeqDiv, N.SortSeq, Base, Adj, RatingOpen, RatingRec, RatingMedian, OverallBase, OverallExp, EventsReqd
                    curViewRow.Cells["Event"].Value        = (String)curDataRow["Event"];
                    curViewRow.Cells["AgeGroup"].Value     = (String)curDataRow["AgeGroup"];
                    curViewRow.Cells["RatingRec"].Value    = ((Decimal)curDataRow["RatingRec"]).ToString("####0.00");
                    curViewRow.Cells["RatingMedian"].Value = ((Decimal)curDataRow["RatingMedian"]).ToString("####0.00");
                    curViewRow.Cells["Base"].Value         = ((Decimal)curDataRow["Base"]).ToString("#####0");
                    curViewRow.Cells["Adj"].Value          = ((Decimal)curDataRow["Adj"]).ToString("##0.00");
                    curViewRow.Cells["OverallBase"].Value  = ((Decimal)curDataRow["OverallBase"]).ToString("##0");
                    curViewRow.Cells["OverallExp"].Value   = ((Decimal)curDataRow["OverallExp"]).ToString("#.000");
                    curViewRow.Cells["EventsReqd"].Value   = (byte)curDataRow["EventsReqd"];
                }

                if (ScoreList[idxSlalom].Score > 0 || ScoreList[idxTrick].Score > 0 || ScoreList[idxJump].Score > 0)
                {
                    appNopsCalc.calcNops(listAgeDivisionsComboBox.SelectedValue.ToString(), ScoreList);
                    Nops1.Text = Math.Round(ScoreList[idxSlalom].Nops, 1).ToString();
                    Nops2.Text = Math.Round(ScoreList[idxTrick].Nops, 1).ToString();
                    Nops3.Text = Math.Round(ScoreList[idxJump].Nops, 1).ToString();
                    Nops4.Text = Math.Round(ScoreList[idxOverall].Nops, 1).ToString();

                    if (ScoreList[idxSlalom].Score > 0)
                    {
                        calcSlalomScoreText(ScoreList[idxSlalom].Score, curAgeGroup);
                    }
                }
            }
        }
        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);
        }