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 ( plcmtAWSATeamButton.Checked ) { bestScoreButton.Checked = true; pointsScoreButton.Checked = true; nopsPointsButton.Checked = true; } 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"; } myTourProperties.TeamSummaryDataType = curDataType; if ( pointsScoreButton.Checked ) { curPlcmtMethod = "points"; } else if ( handicapScoreButton.Checked ) { curPlcmtMethod = "hcap"; } else if ( ratioScoreButton.Checked ) { curPlcmtMethod = "ratio"; } else { curPlcmtMethod = "points"; } myTourProperties.TeamSummaryPlcmtMethod = curPlcmtMethod; if ( divPlcmtButton.Checked ) { curPlcmtOrg = "div"; } else if (groupPlcmtButton.Checked) { curPlcmtOrg = "group"; } else if (plcmtTourButton.Checked) { curPlcmtOrg = "tour"; } else if ( plcmtAWSATeamButton.Checked ) { curPlcmtOrg = "awsa"; } else { curPlcmtOrg = "tour"; } myTourProperties.TeamSummaryPlcmtOrg = 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.TeamSummaryPointsMethod = curPointsMethod; String curGroupValue = ""; try { curGroupValue = EventGroupList.SelectedItem.ToString(); if (!( curGroupValue.ToLower().Equals( "all" ) )) { if (myTourRules.ToLower().Equals( "ncwsa" )) { if (plcmtTourButton.Checked) { curGroupValue = "All"; } else 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 (myTourRules.ToLower().Equals( "iwwf" ) && curPointsMethod.ToLower().Equals( "kbase" )) { mySlalomDataTable = curCalcSummary.CalcIwwfEventPlcmts(myTourRow, mySanctionNum, "Slalom", myTourRules, curDataType, curPlcmtMethod, curPlcmtOrg, curPointsMethod, "Team", curGroupValue); loadSlalomDataGrid(mySlalomDataTable); myTrickDataTable = curCalcSummary.CalcIwwfEventPlcmts(myTourRow, mySanctionNum, "Trick", myTourRules, curDataType, curPlcmtMethod, curPlcmtOrg, curPointsMethod, "Team", curGroupValue); loadTrickDataGrid(myTrickDataTable); myJumpDataTable = curCalcSummary.CalcIwwfEventPlcmts(myTourRow, mySanctionNum, "Jump", myTourRules, curDataType, curPlcmtMethod, curPlcmtOrg, curPointsMethod, "Team", curGroupValue); loadJumpDataGrid(myJumpDataTable); myTeamDataTable = curCalcSummary.getSlalomSummaryTeam(mySlalomDataTable, myTourRow, myNumPerTeam, curDataType, curPlcmtMethod, curPlcmtOrg, curPointsMethod); myTeamDataTable = curCalcSummary.getTrickSummaryTeam(myTeamDataTable, myTrickDataTable, myTourRow, myNumPerTeam, curDataType, curPlcmtMethod, curPlcmtOrg, curPointsMethod); myTeamDataTable = curCalcSummary.getJumpSummaryTeam(myTeamDataTable, myJumpDataTable, myTourRow, myNumPerTeam, curDataType, curPlcmtMethod, curPlcmtOrg, curPointsMethod); if ( plcmtTourButton.Checked ) { myTeamDataTable = curCalcSummary.CalcTeamCombinedSummary(myTourRow, mySlalomDataTable, myTrickDataTable, myJumpDataTable, myNumPerTeam); } } else if (myTourRules.ToLower().Equals( "ncwsa" )) { if (plcmtTourButton.Checked) { curPlcmtOrg = "div"; } mySlalomDataTable = curCalcSummary.getSlalomSummary( myTourRow, curDataType, curPlcmtMethod, curPlcmtOrg, curPointsMethod, "Team", curGroupValue ); loadSlalomDataGrid( mySlalomDataTable ); myTrickDataTable = curCalcSummary.getTrickSummary( myTourRow, curDataType, curPlcmtMethod, curPlcmtOrg, curPointsMethod, "Team", curGroupValue ); loadTrickDataGrid( myTrickDataTable ); myJumpDataTable = curCalcSummary.getJumpSummary( myTourRow, curDataType, curPlcmtMethod, curPlcmtOrg, curPointsMethod, "Team", curGroupValue ); loadJumpDataGrid( myJumpDataTable ); myTeamDataTable = curCalcSummary.getSlalomSummaryTeam( mySlalomDataTable, myTourRow, myNumPerTeam, curDataType, curPlcmtMethod, curPlcmtOrg, curPointsMethod ); myTeamDataTable = curCalcSummary.getTrickSummaryTeam( myTeamDataTable, myTrickDataTable, myTourRow, myNumPerTeam, curDataType, curPlcmtMethod, curPlcmtOrg, curPointsMethod ); myTeamDataTable = curCalcSummary.getJumpSummaryTeam( myTeamDataTable, myJumpDataTable, myTourRow, myNumPerTeam, curDataType, curPlcmtMethod, curPlcmtOrg, curPointsMethod ); if (plcmtTourButton.Checked) { myTeamDataTable = curCalcSummary.CalcTeamEventCombinedNcwsaSummary( myTeamDataTable, mySanctionNum ); } } else { mySlalomDataTable = curCalcSummary.getSlalomSummary( myTourRow, curDataType, curPlcmtMethod, curPlcmtOrg, curPointsMethod, "Team", curGroupValue ); myTrickDataTable = curCalcSummary.getTrickSummary( myTourRow, curDataType, curPlcmtMethod, curPlcmtOrg, curPointsMethod, "Team", curGroupValue ); myJumpDataTable = curCalcSummary.getJumpSummary( myTourRow, curDataType, curPlcmtMethod, curPlcmtOrg, curPointsMethod, "Team", curGroupValue ); myTeamDataTable = curCalcSummary.getSlalomSummaryTeam( mySlalomDataTable, myTourRow, myNumPerTeam, curDataType, curPlcmtMethod, curPlcmtOrg, curPointsMethod ); myTeamDataTable = curCalcSummary.getTrickSummaryTeam( myTeamDataTable, myTrickDataTable, myTourRow, myNumPerTeam, curDataType, curPlcmtMethod, curPlcmtOrg, curPointsMethod ); myTeamDataTable = curCalcSummary.getJumpSummaryTeam( myTeamDataTable, myJumpDataTable, myTourRow, myNumPerTeam, curDataType, curPlcmtMethod, curPlcmtOrg, curPointsMethod ); if (plcmtTourButton.Checked) { myTeamDataTable = curCalcSummary.CalcTeamCombinedSummary( myTourRow, mySlalomDataTable, myTrickDataTable, myJumpDataTable, myNumPerTeam ); } if ( plcmtAWSATeamButton.Checked ) { mySlalomDataTable = curCalcSummary.CalcTeamAwsaEventPoints( mySlalomDataTable, "Slalom" ); myTrickDataTable = curCalcSummary.CalcTeamAwsaEventPoints( myTrickDataTable, "Trick" ); myJumpDataTable = curCalcSummary.CalcTeamAwsaEventPoints( myJumpDataTable, "Jump" ); myTeamDataTable = curCalcSummary.CalcTeamAwsaCombinedSummary( myTourRow, mySlalomDataTable, myTrickDataTable, myJumpDataTable, myNumPerTeam ); } loadSlalomDataGrid( mySlalomDataTable ); loadTrickDataGrid( myTrickDataTable ); loadJumpDataGrid( myJumpDataTable ); } String curSortCmd = ""; if (TeamDiv.Visible) { curSortCmd = "DivOrder ASC, Div ASC, TeamScoreTotal DESC"; } else { curSortCmd = "TeamScoreTotal DESC"; } myTeamDataTable.DefaultView.Sort = curSortCmd; myTeamDataTable = myTeamDataTable.DefaultView.ToTable(); loadTeamDataGrid( myTeamDataTable ); } this.Cursor = Cursors.Default; }
public Boolean exportScoreBookData() { String curMethodName = "exportScoreBookHtml"; Boolean returnStatus = false; StringBuilder outLine = new StringBuilder( "" ); String curMsg = "", curMemberId = "", curAgeGroup = "", prevMemberId = "", prevAgeGroup = "", curReadyToSki = ""; String curFileFilter = "HTML files (*.htm)|*.htm|All files (*.*)|*.*"; Int16 curRound = 0; DataRow prevRow = null; DataRow[] curScoreSlalomRows = null, curScoreTrickRows = null, curScoreJumpRows = null; myTourProperties = TourProperties.Instance; ExportScorebookTypeDialogForm curDialogForm = new ExportScorebookTypeDialogForm(); curDialogForm.ShowDialog(); if ( curDialogForm.DialogResult == DialogResult.OK ) { String curReportFormat = curDialogForm.ReportFormat; if ( curReportFormat.Equals( "Magazine" ) ) { Tools.ExportScorebookPublishFmt myExportDataReport = new ExportScorebookPublishFmt(); myExportDataReport.ExportScorebookPublishFmtData(); returnStatus = true; } else { try { curMsg = "Exporting Scorebook Html"; Log.WriteFile( curMethodName + ":begin: " + curMsg ); mySkierClassList = new ListSkierClass(); mySkierClassList.ListSkierClassLoad(); String curFilename = mySanctionNum.Trim() + "CS.HTM"; StreamWriter outBuffer = getExportFile( curFileFilter, curFilename ); if ( outBuffer == null ) { curMsg = "Output file not available"; } else { String curPlcmtMethod = "score", curPlcmtOverallOrg = "agegroup"; String curDataType = myTourProperties.MasterSummaryDataType; //String curDataType = Properties.Settings.Default.MasterSummaryV2DataType; if ( curDataType.ToLower().Equals( "total" ) || curDataType.ToLower().Equals( "best" ) || curDataType.ToLower().Equals( "final" ) || curDataType.ToLower().Equals( "first" ) ) { } else { curDataType = "best"; } String curPointsMethod = myTourProperties.MasterSummaryPointsMethod; //String curPointsMethod = Properties.Settings.Default.MasterSummaryV2PointsMethod; if (curPointsMethod.ToLower().Equals( "nops" ) || curPointsMethod.ToLower().Equals( "plcmt" ) || curPointsMethod.ToLower().Equals( "kbase" ) || curPointsMethod.ToLower().Equals( "ratio" )) { } else { curPointsMethod = "nops"; } String curPlcmtOrg = myTourProperties.MasterSummaryPlcmtOrg; //String curPlcmtOrg = Properties.Settings.Default.MasterSummaryV2PlcmtOrg; if ( curPlcmtOrg.ToLower().Equals( "div" ) ) { curPlcmtOverallOrg = "agegroup"; } else if ( curPlcmtOrg.ToLower().Equals( "divgr" ) ) { curPlcmtOverallOrg = "agegroupgroup"; } else { curPlcmtOverallOrg = "agegroup"; curPlcmtOrg = "div"; } myProgressInfo = new ProgressWindow(); myProgressInfo.setProgessMsg( "Processing Scorebook HTML" ); 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 myOverallDataTable = curCalcSummary.buildOverallSummary( myTourRow, mySlalomDataTable, myTrickDataTable, myJumpDataTable, curDataType, curPlcmtOverallOrg ); myProgressInfo.setProgressValue( 4 ); myProgressInfo.Refresh(); DataTable myMemberData = curCalcSummary.getMemberData( mySanctionNum ); myProgressInfo.setProgressValue( 5 ); myProgressInfo.Refresh(); DataTable mySlalomDetail = curCalcSummary.getSlalomScoreDetail( myTourRow, curPlcmtMethod, curPlcmtOrg, curPointsMethod, null, null ); myProgressInfo.setProgressValue( 6 ); myProgressInfo.Refresh(); DataTable myTrickDetail = curCalcSummary.getTrickScoreDetail( myTourRow, curPlcmtMethod, curPlcmtOrg, curPointsMethod, null, null ); myProgressInfo.setProgressValue( 7 ); myProgressInfo.Refresh(); DataTable myJumpDetail = curCalcSummary.getJumpScoreDetail( myTourRow, curPlcmtMethod, curPlcmtOrg, curPointsMethod, null, null ); myProgressInfo.setProgressValue( 8 ); myProgressInfo.Refresh(); DataTable mySummaryDataTable = curCalcSummary.buildTourScorebook( mySanctionNum, myTourRow, myMemberData, myOverallDataTable, mySlalomDetail, myTrickDetail, myJumpDetail ); myProgressInfo.setProgressValue( 9 ); myProgressInfo.Refresh(); myProgressInfo.setProgressMax( mySummaryDataTable.Rows.Count ); myProgressInfo.Refresh(); //Build file header line and write to file writeHeader( outBuffer, curPlcmtOrg ); if ( curReportFormat.Equals( "Index" ) ) { //Build index header writeIndexHeader( outBuffer, curPlcmtOrg, mySlalomDataTable, myTrickDataTable, myJumpDataTable, myOverallDataTable ); } //Build master summary header writeMasterSummaryHeader( outBuffer, curPlcmtOrg ); int curRowCount = 0; foreach ( DataRow curRow in mySummaryDataTable.Rows ) { curRowCount++; myProgressInfo.setProgressValue( curRowCount ); myProgressInfo.Refresh(); curMemberId = curRow["MemberId"].ToString(); curAgeGroup = curRow["AgeGroup"].ToString(); curReadyToSki = curRow["ReadyToSki"].ToString(); if ( curMemberId != prevMemberId || curAgeGroup != prevAgeGroup ) { 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 prevMemberId = curMemberId; prevAgeGroup = curAgeGroup; curRound = (Int16)curRow["Round"]; //Initialize output buffer outLine = new StringBuilder( "<tr>" ); //Write skier identification information writeSkierInfo( curRow, curRound, outBuffer ); //Write skier performance summary information writeSkierSlalomScore( curRow, curScoreSlalomRows, curPlcmtOrg, outBuffer ); writeSkierTrickScore( curRow, curScoreTrickRows, curPlcmtOrg, outBuffer ); writeSkierJumpScore( curRow, curScoreJumpRows, curPlcmtOrg, outBuffer ); writeSkierOverallScore( curRow, outBuffer ); //Write output line to file outLine = new StringBuilder( "</tr>" ); outBuffer.WriteLine( outLine.ToString() ); } outLine = new StringBuilder( "</table>" ); outBuffer.WriteLine( outLine.ToString() ); if ( curReportFormat.Equals( "Index" ) ) { outLine = new StringBuilder( "<br/><br/><a href=#PageTop>Return to Index</a><br/></div>" ); outBuffer.WriteLine( outLine.ToString() ); writeIndexSlalomResults( curPlcmtOrg, mySlalomDataTable, outBuffer ); writeIndexTrickResults( curPlcmtOrg, myTrickDataTable, outBuffer ); writeIndexJumpResults( curPlcmtOrg, myJumpDataTable, outBuffer ); writeIndexOverallResults( curPlcmtOrg, myOverallDataTable, outBuffer ); Boolean curTeamsAvailble = isTeamAvailable(); //if ( this.myTourClass.Equals("B") || this.myTourClass.Equals("A") ) { // curTeamsAvailble = false; //} if ( curTeamsAvailble ) { Int16 myNumPerTeam = Convert.ToInt16( myTourProperties.TeamSummary_NumPerTeam); String curTeamPlcmtOrg = myTourProperties.TeamSummaryPlcmtOrg; //String curTeamPlcmtOrg = Properties.Settings.Default.TeamSummaryPlcmtOrg; if (curTeamPlcmtOrg.ToLower().Equals( "tour" ) || curTeamPlcmtOrg.ToLower().Equals( "div" )) { } else { curTeamPlcmtOrg = "tour"; } String curTeamPlcmtMethod = "points"; String curTeamDataType = myTourProperties.TeamSummaryDataType; //String curTeamDataType = Properties.Settings.Default.TeamSummaryDataType; if (curTeamDataType.ToLower().Equals( "total" ) || curTeamDataType.ToLower().Equals( "best" ) || curTeamDataType.ToLower().Equals( "final" ) || curTeamDataType.ToLower().Equals( "first" )) { } else { curTeamDataType = "best"; } String curTeamPointsMethod = myTourProperties.TeamSummaryPointsMethod; //String curTeamPointsMethod = Properties.Settings.Default.MasterSummaryV2PointsMethod; if (curTeamPointsMethod.ToLower().Equals( "nops" ) || curTeamPointsMethod.ToLower().Equals( "plcmt" ) || curTeamPointsMethod.ToLower().Equals( "kbase" ) || curTeamPointsMethod.ToLower().Equals( "ratio" )) { } else { curTeamPointsMethod = "nops"; } if ( this.myTourClass.Equals("B") || this.myTourClass.Equals("A") ) { curTeamPointsMethod = "nops"; curTeamDataType = "best"; curTeamPlcmtOrg = "awsa"; curTeamPlcmtMethod = "points"; myNumPerTeam = 4; } String curGroupValue = "all"; mySlalomDataTable = curCalcSummary.getSlalomSummary(myTourRow, curTeamDataType, curTeamPlcmtMethod, curTeamPlcmtOrg, curTeamPointsMethod, "Team", curGroupValue); myTrickDataTable = curCalcSummary.getTrickSummary(myTourRow, curTeamDataType, curTeamPlcmtMethod, curTeamPlcmtOrg, curTeamPointsMethod, "Team", curGroupValue); myJumpDataTable = curCalcSummary.getJumpSummary(myTourRow, curTeamDataType, curTeamPlcmtMethod, curTeamPlcmtOrg, curTeamPointsMethod, "Team", curGroupValue); DataTable myTeamDataTable = null; myTeamDataTable = curCalcSummary.getSlalomSummaryTeam(mySlalomDataTable, myTourRow, myNumPerTeam, curTeamDataType, curTeamPlcmtMethod, curTeamPlcmtOrg, curTeamPointsMethod); myTeamDataTable = curCalcSummary.getTrickSummaryTeam(myTeamDataTable, myTrickDataTable, myTourRow, myNumPerTeam, curTeamDataType, curTeamPlcmtMethod, curTeamPlcmtOrg, curTeamPointsMethod); myTeamDataTable = curCalcSummary.getJumpSummaryTeam(myTeamDataTable, myJumpDataTable, myTourRow, myNumPerTeam, curTeamDataType, curTeamPlcmtMethod, curTeamPlcmtOrg, curTeamPointsMethod); if ( curTeamPlcmtOrg.ToLower().Equals("tour") ) { myTeamDataTable = curCalcSummary.CalcTeamCombinedSummary(myTourRow, mySlalomDataTable, myTrickDataTable, myJumpDataTable, myNumPerTeam); } if ( myTourClass.Equals("B") || myTourClass.Equals("A") ) { mySlalomDataTable = curCalcSummary.CalcTeamAwsaEventPoints(mySlalomDataTable, "Slalom"); myTrickDataTable = curCalcSummary.CalcTeamAwsaEventPoints(myTrickDataTable, "Trick"); myJumpDataTable = curCalcSummary.CalcTeamAwsaEventPoints(myJumpDataTable, "Jump"); myTeamDataTable = curCalcSummary.CalcTeamAwsaCombinedSummary(myTourRow, mySlalomDataTable, myTrickDataTable, myJumpDataTable, myNumPerTeam); writeIndexTeamResults(myTeamDataTable, myNumPerTeam, curTeamPlcmtOrg, outBuffer); writeIndexTeamDetailResults(mySlalomDataTable, myTrickDataTable, myJumpDataTable, myNumPerTeam, curTeamPlcmtOrg, outBuffer); } else { writeIndexTeamResults(myTeamDataTable, myNumPerTeam, curTeamPlcmtOrg, outBuffer); } } } else { outLine = new StringBuilder( "</div>" ); outBuffer.WriteLine( outLine.ToString() ); } //Build file footer and write to file writeFooter( outBuffer ); 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 + " Error writing scorebook html file\n\nError: " + ex.Message ); curMsg = curMethodName + ":Exception=" + ex.Message; Log.WriteFile( curMsg ); returnStatus = false; } } } else { returnStatus = false; } return returnStatus; }