public Boolean ExportScorebookPublishFmtData()
        {
            String        curMethodName = "ExportScorebookPublishFmtData";
            Boolean       returnStatus = false;
            StringBuilder outLine = new StringBuilder("");
            String        curMsg = "", curMemberId = "", curAgeGroup = "", prevAgeGroup = "";
            String        curFileFilter = "TXT files (*.txt)|*.txt|All files (*.*)|*.*";
            Int16         curRound = 0, curOverallPlcmt = 0;
            DataRow       prevRow = null;

            DataRow[] curScoreSlalomRows = null, curScoreTrickRows = null, curScoreJumpRows = null;

            try {
                curMsg = "Exporting Scorebook Publish Data";
                Log.WriteFile(curMethodName + ":begin: " + curMsg);
                String       curFilename = mySanctionNum.Trim() + "-publish.txt";
                StreamWriter outBuffer   = getExportFile(curFileFilter, curFilename);

                if (outBuffer == null)
                {
                    curMsg = "Output file not available";
                }
                else
                {
                    String curPlcmtMethod = "score"
                    , curPlcmtOverallOrg  = "agegroup"
                    , curDataType         = "best"
                    , curPointsMethod     = "nops"
                    , curPlcmtOrg         = "div";

                    myProgressInfo = new ProgressWindow();
                    myProgressInfo.setProgessMsg("Processing Scorebook Publish Data");
                    myProgressInfo.Show();
                    myProgressInfo.Refresh();
                    myProgressInfo.setProgressMax(10);

                    CalcScoreSummary curCalcSummary    = new CalcScoreSummary();
                    DataTable        mySlalomDataTable = curCalcSummary.getSlalomSummary(myTourRow, curDataType, curPlcmtMethod, curPlcmtOrg, curPointsMethod);
                    myProgressInfo.setProgressValue(1);
                    myProgressInfo.Refresh();
                    DataTable myTrickDataTable = curCalcSummary.getTrickSummary(myTourRow, curDataType, curPlcmtMethod, curPlcmtOrg, curPointsMethod);
                    myProgressInfo.setProgressValue(2);
                    myProgressInfo.Refresh();
                    DataTable myJumpDataTable = curCalcSummary.getJumpSummary(myTourRow, curDataType, curPlcmtMethod, curPlcmtOrg, curPointsMethod);
                    myProgressInfo.setProgressValue(3);
                    myProgressInfo.Refresh();
                    DataTable mySummaryDataTable = curCalcSummary.buildOverallSummary(myTourRow, mySlalomDataTable, myTrickDataTable, myJumpDataTable, curDataType, curPlcmtOverallOrg);
                    foreach (DataRow curRow in mySummaryDataTable.Rows)
                    {
                        if (((String)curRow["QualifyOverall"]).ToUpper().Equals("YES"))
                        {
                        }
                        else
                        {
                            curRow["ScoreOverall"] = 0;
                        }
                    }
                    myProgressInfo.setProgressValue(4);
                    myProgressInfo.Refresh();

                    mySummaryDataTable.DefaultView.Sort = "AgeGroup ASC, QualifyOverall Desc, ScoreOverall Desc, SkierName ASC";
                    DataTable curSummaryDataTable = mySummaryDataTable.DefaultView.ToTable();

                    myProgressInfo.setProgressMax(mySummaryDataTable.Rows.Count);
                    myProgressInfo.Refresh();

                    //Build file header line and write to file
                    writeHeader(outBuffer);

                    int curRowCount = 0;
                    foreach (DataRow curRow in curSummaryDataTable.Rows)
                    {
                        curRowCount++;
                        myProgressInfo.setProgressValue(curRowCount);
                        myProgressInfo.Refresh();

                        curMemberId = curRow["MemberId"].ToString();
                        curAgeGroup = curRow["AgeGroup"].ToString();
                        if (curAgeGroup != prevAgeGroup)
                        {
                            if (prevAgeGroup.Length > 0)
                            {
                                outBuffer.WriteLine("");
                                curOverallPlcmt = 0;
                            }

                            //Write skier identification information
                            outLine = new StringBuilder("");
                            outLine.Append(writeDivisionHeader(outBuffer, curAgeGroup));
                        }

                        curScoreSlalomRows = mySlalomDataTable.Select("MemberId = '" + curMemberId + "' AND AgeGroup = '" + curAgeGroup + "'");
                        curScoreTrickRows  = myTrickDataTable.Select("MemberId = '" + curMemberId + "' AND AgeGroup = '" + curAgeGroup + "'");
                        curScoreJumpRows   = myJumpDataTable.Select("MemberId = '" + curMemberId + "' AND AgeGroup = '" + curAgeGroup + "'");

                        //Initialize control fields
                        prevAgeGroup = curAgeGroup;

                        //Initialize output buffer
                        outLine = new StringBuilder("");

                        //Write skier identification information
                        outLine.Append(writeSkierInfo(curRow, curRound));

                        //Write skier performance summary information
                        outLine.Append(writeSkierSlalomScore(curRow, curScoreSlalomRows));

                        outLine.Append(writeSkierTrickScore(curRow, curScoreTrickRows));

                        outLine.Append(writeSkierJumpScore(curRow, curScoreJumpRows));

                        curOverallPlcmt++;
                        outLine.Append(writeSkierOverallScore(curRow, curOverallPlcmt));
                        //Write output line to file
                        outBuffer.WriteLine(outLine.ToString());
                    }

                    //Build file footer and write to file
                    outLine = new StringBuilder("");
                    outBuffer.WriteLine(outLine.ToString());

                    returnStatus = true;
                    outBuffer.Close();

                    myProgressInfo.Close();
                    if (mySummaryDataTable.Rows.Count > 0)
                    {
                        curMsg = mySummaryDataTable.Rows.Count + " skiers found and written";
                    }
                    else
                    {
                        curMsg = "No rows found";
                    }
                }
                MessageBox.Show(curMsg);
                Log.WriteFile(curMethodName + ":conplete: " + curMsg);
            } catch (Exception ex) {
                MessageBox.Show("Error:" + curMethodName + " Could not write file from data input\n\nError: " + ex.Message);
                curMsg = curMethodName + ":Exception=" + ex.Message;
                Log.WriteFile(curMsg);
                returnStatus = false;
            }

            return(returnStatus);
        }
        public void navRefresh_Click(object sender, EventArgs e)
        {
            if (mySanctionNum != null && myTourRow != null)
            {
                String curDataType = "best", curPlcmtMethod = "score", curPointsMethod = "";
                String curPlcmtOrg = "", curPlcmtOverallOrg = "";
                //String curPlcmtOrg = "div";

                CalcScoreSummary curCalcSummary = new CalcScoreSummary();

                // Retrieve data from database depending on selection criteria
                String curMsg = "Tournament scores retrieved ";

                if (bestScoreButton.Checked)
                {
                    curDataType       = "best";
                    winStatusMsg.Text = curMsg + "- best scores ";
                }
                else if (totalScoreButton.Checked)
                {
                    curDataType       = "total";
                    winStatusMsg.Text = curMsg + "- total scores";
                }
                else if (finalScoreButton.Checked)
                {
                    curDataType       = "final";
                    winStatusMsg.Text = curMsg + "- final scores";
                }
                else if (firstScoreButton.Checked)
                {
                    curDataType       = "first";
                    winStatusMsg.Text = curMsg + "- first scores";
                }
                myTourProperties.TrickScorebookDataType = curDataType;
                if (nopsPointsButton.Checked)
                {
                    curPointsMethod = "nops";
                }
                else if (plcmtPointsButton.Checked)
                {
                    curPointsMethod = "plcmt";
                }
                else if (kBasePointsButton.Checked)
                {
                    curPointsMethod = "kbase";
                }
                else if (ratioPointsButton.Checked)
                {
                    curPointsMethod = "ratio";
                }
                else
                {
                    curPointsMethod = "nops";
                }
                myTourProperties.TrickScorebookPointsMethod = curPointsMethod;

                if (plcmtDivButton.Checked)
                {
                    curPlcmtOrg        = "div";
                    curPlcmtOverallOrg = "agegroup";
                    EventGroup.Visible = false;
                }
                else if (plcmtDivGrpButton.Checked)
                {
                    curPlcmtOrg        = "divgr";
                    curPlcmtOverallOrg = "agegroupgroup";
                    EventGroup.Visible = true;
                }
                else
                {
                    curPlcmtOrg        = "div";
                    curPlcmtOverallOrg = "agegroup";
                    EventGroup.Visible = false;
                }
                myTourProperties.TrickScorebookPlcmtOrg = curPlcmtOrg;

                Cursor.Current = Cursors.WaitCursor;
                scoreSummaryDataGridView.BeginInvoke((MethodInvoker) delegate() {
                    Application.DoEvents();
                    winStatusMsg.Text = "Tournament entries retrieved";
                });

                String curGroupValue = "";
                try {
                    curGroupValue = EventGroupList.SelectedItem.ToString();
                    if (!(curGroupValue.ToLower().Equals("all")))
                    {
                        if (myTourRules.ToLower().Equals("ncwsa"))
                        {
                            if (curGroupValue.ToUpper().Equals("MEN A"))
                            {
                                curGroupValue = "CM";
                            }
                            else if (curGroupValue.ToUpper().Equals("WOMEN A"))
                            {
                                curGroupValue = "CW";
                            }
                            else if (curGroupValue.ToUpper().Equals("MEN B"))
                            {
                                curGroupValue = "BM";
                            }
                            else if (curGroupValue.ToUpper().Equals("WOMEN B"))
                            {
                                curGroupValue = "BW";
                            }
                            else
                            {
                                curGroupValue = "All";
                            }
                        }
                    }
                } catch {
                    curGroupValue = "All";
                }

                if (curGroupValue.ToLower().Equals("all"))
                {
                    if (myTourRules.ToLower().Equals("iwwf") && curPointsMethod.ToLower().Equals("kbase"))
                    {
                        mySummaryDataTable = curCalcSummary.CalcIwwfEventPlcmts(myTourRow, mySanctionNum, "Scorebook", myTourRules, curDataType, curPlcmtMethod, curPlcmtOrg, curPointsMethod, null, null);
                    }
                    else
                    {
                        myTrickDataTable   = curCalcSummary.getTrickSummary(myTourRow, curDataType, curPlcmtMethod, curPlcmtOrg, curPointsMethod);
                        mySummaryDataTable = curCalcSummary.buildOverallSummary(myTourRow, null, myTrickDataTable, null, curDataType, curPlcmtOverallOrg);

                        myMemberData       = curCalcSummary.getMemberData(mySanctionNum);
                        myTrickDetail      = curCalcSummary.getTrickScoreDetail(myTourRow, curPlcmtMethod, curPlcmtOrg, curPointsMethod, null, null);
                        mySummaryDataTable = curCalcSummary.buildTourScorebook(mySanctionNum, myTourRow, myMemberData, mySummaryDataTable, null, myTrickDetail, null);
                    }
                }
                else
                {
                    if (myTourRules.ToLower().Equals("iwwf") && curPointsMethod.ToLower().Equals("kbase"))
                    {
                        mySummaryDataTable = curCalcSummary.CalcIwwfEventPlcmts(myTourRow, mySanctionNum, "Scorebook", myTourRules, curDataType, curPlcmtMethod, curPlcmtOrg, curPointsMethod, "All", curGroupValue);
                    }
                    else
                    {
                        myTrickDataTable   = curCalcSummary.getTrickSummary(myTourRow, curDataType, curPlcmtMethod, curPlcmtOrg, curPointsMethod, "All", curGroupValue);
                        mySummaryDataTable = curCalcSummary.buildOverallSummary(myTourRow, null, myTrickDataTable, null, curDataType, curPlcmtOverallOrg);

                        myMemberData       = curCalcSummary.getMemberData(mySanctionNum, curGroupValue);
                        myTrickDetail      = curCalcSummary.getTrickScoreDetail(myTourRow, curPlcmtMethod, curPlcmtOrg, curPointsMethod, "All", curGroupValue);
                        mySummaryDataTable = curCalcSummary.buildTourScorebook(mySanctionNum, myTourRow, myMemberData, mySummaryDataTable, null, myTrickDetail, null);
                    }
                }

                loadSummaryDataGrid();
                Cursor.Current = Cursors.Default;
            }
        }
        public void navRefresh_Click(object sender, EventArgs e)
        {
            this.Cursor = Cursors.WaitCursor;

            // Retrieve data from database
            if (mySanctionNum != null && myTourRow != null)
            {
                String           curDataType = "all", curPlcmtMethod = "score";
                String           curPlcmtOrg, curPointsMethod;
                CalcScoreSummary curCalcSummary = new CalcScoreSummary();

                // Retrieve data from database depending on selection criteria
                String curMsg = "Tournament scores retrieved ";

                if (bestScoreButton.Checked)
                {
                    curDataType       = "best";
                    winStatusMsg.Text = curMsg + "- best scores ";
                }
                else if (roundScoreButton.Checked)
                {
                    curDataType       = "round";
                    winStatusMsg.Text = curMsg + "- total scores";
                }
                else if (finalScoreButton.Checked)
                {
                    curDataType       = "final";
                    winStatusMsg.Text = curMsg + "- final scores";
                }
                myTourProperties.MasterSummaryOverallDataType = curDataType;

                if (pointsScoreButton.Checked)
                {
                    curPlcmtMethod = "points";
                }
                else if (handicapScoreButton.Checked)
                {
                    curPlcmtMethod = "hcap";
                }
                else if (ratioScoreButton.Checked)
                {
                    curPlcmtMethod = "ratio";
                }
                else
                {
                    curPlcmtMethod = "points";
                }
                myTourProperties.MasterSummaryOverallPlcmtMethod = curPlcmtMethod;

                EventGroup.Visible = false;
                if (groupPlcmtButton.Checked)
                {
                    curPlcmtOrg        = "group";
                    EventGroup.Visible = true;
                }
                else if (plcmtTourButton.Checked)
                {
                    curPlcmtOrg = "tour";
                }
                else if (plcmtDivButton.Checked)
                {
                    curPlcmtOrg = "div";
                }
                else if (plcmtDivGrpButton.Checked)
                {
                    curPlcmtOrg        = "divgr";
                    EventGroup.Visible = true;
                }
                else
                {
                    curPlcmtOrg = "tour";
                }
                myTourProperties.MasterSummaryOverallPlcmtOrg = curPlcmtOrg;

                if (nopsPointsButton.Checked)
                {
                    curPointsMethod = "nops";
                }
                else if (plcmtPointsButton.Checked)
                {
                    curPointsMethod = "plcmt";
                }
                else if (kBasePointsButton.Checked)
                {
                    curPointsMethod = "kbase";
                }
                else if (ratioPointsButton.Checked)
                {
                    curPointsMethod = "ratio";
                }
                else
                {
                    curPointsMethod = "nops";
                }
                myTourProperties.MasterSummaryOverallPointsMethod = curPointsMethod;

                String curFilterSetting = "All";
                if (showAllButton.Checked)
                {
                    curFilterSetting = "All";
                }
                else if (showQlfyButton.Checked)
                {
                    curFilterSetting = "Qualifed";
                }
                else
                {
                    curFilterSetting = "All";
                }
                myTourProperties.MasterSummaryOverallFilter = curFilterSetting;

                /*
                 * if ( EventGroup.Visible ) {
                 *  SlalomLabel.Location = new Point( 208, SlalomLabel.Location.Y );
                 *  TrickLabel.Location = new Point( 573, SlalomLabel.Location.Y );
                 *  JumpLabel.Location = new Point( 830, SlalomLabel.Location.Y );
                 *  OverallLabel.Location = new Point( 1062, SlalomLabel.Location.Y );
                 * } else {
                 *  SlalomLabel.Location = new Point( 168, SlalomLabel.Location.Y );
                 *  TrickLabel.Location = new Point( 533, SlalomLabel.Location.Y );
                 *  JumpLabel.Location = new Point( 790, SlalomLabel.Location.Y );
                 *  OverallLabel.Location = new Point( 1022, SlalomLabel.Location.Y );
                 * }
                 */

                String curGroupValue = "";
                try {
                    curGroupValue = EventGroupList.SelectedItem.ToString();
                    if (!(curGroupValue.ToLower().Equals("all")))
                    {
                        if (myTourRules.ToLower().Equals("ncwsa"))
                        {
                            if (curGroupValue.ToUpper().Equals("MEN A"))
                            {
                                curGroupValue = "CM";
                            }
                            else if (curGroupValue.ToUpper().Equals("WOMEN A"))
                            {
                                curGroupValue = "CW";
                            }
                            else if (curGroupValue.ToUpper().Equals("MEN B"))
                            {
                                curGroupValue = "BM";
                            }
                            else if (curGroupValue.ToUpper().Equals("WOMEN B"))
                            {
                                curGroupValue = "BW";
                            }
                            else
                            {
                                curGroupValue = "All";
                            }
                        }
                    }
                } catch {
                    curGroupValue = "All";
                }


                if (curGroupValue.ToLower().Equals("all"))
                {
                    if (myTourRules.ToLower().Equals("iwwf") && curPointsMethod.ToLower().Equals("kbase"))
                    {
                        mySummaryDataTable = curCalcSummary.CalcIwwfEventPlcmts(myTourRow, mySanctionNum, "Overall", myTourRules, curDataType, curPlcmtMethod, curPlcmtOrg, curPointsMethod, null, null);
                    }
                    else
                    {
                        mySlalomDataTable  = curCalcSummary.getSlalomSummary(myTourRow, curDataType, curPlcmtMethod, curPlcmtOrg, curPointsMethod);
                        myTrickDataTable   = curCalcSummary.getTrickSummary(myTourRow, curDataType, curPlcmtMethod, curPlcmtOrg, curPointsMethod);
                        myJumpDataTable    = curCalcSummary.getJumpSummary(myTourRow, curDataType, curPlcmtMethod, curPlcmtOrg, curPointsMethod);
                        mySummaryDataTable = curCalcSummary.buildOverallSummary(myTourRow, mySlalomDataTable, myTrickDataTable, myJumpDataTable, curDataType, curPlcmtOrg);
                    }
                }
                else
                {
                    if (myTourRules.ToLower().Equals("iwwf") && curPointsMethod.ToLower().Equals("kbase"))
                    {
                        mySummaryDataTable = curCalcSummary.CalcIwwfEventPlcmts(myTourRow, mySanctionNum, "Overall", myTourRules, curDataType, curPlcmtMethod, curPlcmtOrg, curPointsMethod, "All", curGroupValue);
                    }
                    else
                    {
                        mySlalomDataTable  = curCalcSummary.getSlalomSummary(myTourRow, curDataType, curPlcmtMethod, curPlcmtOrg, curPointsMethod, "All", curGroupValue);
                        myTrickDataTable   = curCalcSummary.getTrickSummary(myTourRow, curDataType, curPlcmtMethod, curPlcmtOrg, curPointsMethod, "All", curGroupValue);
                        myJumpDataTable    = curCalcSummary.getJumpSummary(myTourRow, curDataType, curPlcmtMethod, curPlcmtOrg, curPointsMethod, "All", curGroupValue);
                        mySummaryDataTable = curCalcSummary.buildOverallSummary(myTourRow, mySlalomDataTable, myTrickDataTable, myJumpDataTable, curDataType, curPlcmtOrg);
                    }
                }
                loadSummaryDataGrid();
            }
            this.Cursor = Cursors.Default;
        }