public void navRefresh_Click( object sender, EventArgs e ) { // Retrieve data from database 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.SlalomScorebookDataType = 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.SlalomScorebookPointsMethod = 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.SlalomScorebookPlcmtOrg = 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 { mySummaryDataTable = curCalcSummary.getSlalomSummary( myTourRow, curDataType, curPlcmtMethod, curPlcmtOrg, curPointsMethod ); myMemberData = curCalcSummary.getMemberData( mySanctionNum ); mySlalomDetail = curCalcSummary.getSlalomScoreDetail( myTourRow, curPlcmtMethod, curPlcmtOrg, curPointsMethod, null, null ); mySummaryDataTable = curCalcSummary.buildTourScorebook( mySanctionNum, myTourRow, myMemberData, mySummaryDataTable, mySlalomDetail, null, 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 { mySummaryDataTable = curCalcSummary.getSlalomSummary( myTourRow, curDataType, curPlcmtMethod, curPlcmtOrg, curPointsMethod, "All", curGroupValue ); myMemberData = curCalcSummary.getMemberData( mySanctionNum, curGroupValue ); mySlalomDetail = curCalcSummary.getSlalomScoreDetail( myTourRow, curPlcmtMethod, curPlcmtOrg, curPointsMethod, "All", curGroupValue ); mySummaryDataTable = curCalcSummary.buildTourScorebook( mySanctionNum, myTourRow, myMemberData, mySummaryDataTable, mySlalomDetail, null, null ); } } loadSummaryDataGrid(); Cursor.Current = Cursors.Default; } }
public Boolean exportTourPerfData( String inSanctionId ) { Boolean returnStatus = false; String curMemberId = "", curReadyToSki = "", curAgeGroup = ""; StringBuilder outLine = new StringBuilder( "" ); StreamWriter outBuffer = null; String curFilename = "", curRules = ""; myTourProperties = TourProperties.Instance; DataTable curTourDataTable = getTourData( inSanctionId ); if ( curTourDataTable != null ) { if ( curTourDataTable.Rows.Count > 0 ) { myTourRow = curTourDataTable.Rows[0]; curRules = (String)myTourRow["Rules"]; curFilename = inSanctionId.Trim() + myTourRow["Class"].ToString().Trim() + ".wsp"; outBuffer = getExportFile( curFilename ); if ( outBuffer != null ) { Log.WriteFile( "Export performance data file begin: " + curFilename ); //Build file header line and write to file outLine.Append( writeHeader( inSanctionId ) ); outBuffer.WriteLine( outLine.ToString() ); //Initialize output buffer outLine = new StringBuilder( "" ); } } } if ( outBuffer != null ) { myProgressInfo = new ProgressWindow(); myProgressInfo.setProgessMsg( "Processing Skier Performance Data File" ); myProgressInfo.Show(); myProgressInfo.Refresh(); myProgressInfo.setProgressMax( 10 ); DataTable curMemberDataTable = getMemberData( inSanctionId ); if ( curMemberDataTable != null ) { DataRow[] curScoreRows, curScoreSlalomRows, curScoreTrickRows, curScoreJumpRows; 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"; } CalcScoreSummary curCalcSummary = new CalcScoreSummary(); DataTable mySummaryDataTable = null; DataTable myMemberData = curCalcSummary.getMemberData( inSanctionId ); myProgressInfo.setProgressValue( 1 ); myProgressInfo.Refresh(); if (curRules.ToLower().Equals( "iwwf" ) && curPointsMethod.ToLower().Equals( "kbase" )) { mySummaryDataTable = curCalcSummary.CalcIwwfEventPlcmts( myTourRow, inSanctionId, "Scorebook", curRules, curDataType, curPlcmtMethod, curPlcmtOrg, curPointsMethod, null, null ); 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 newSummaryDataTable = curCalcSummary.buildTourScorebook( inSanctionId, myTourRow, myMemberData, mySummaryDataTable, mySlalomDetail, myTrickDetail, myJumpDetail ); mySummaryDataTable = newSummaryDataTable; myProgressInfo.setProgressValue( 9 ); myProgressInfo.Refresh(); } else { DataTable mySlalomDataTable = curCalcSummary.getSlalomSummary( myTourRow, curDataType, curPlcmtMethod, curPlcmtOrg, curPointsMethod ); myProgressInfo.setProgressValue( 2 ); myProgressInfo.Refresh(); DataTable myTrickDataTable = curCalcSummary.getTrickSummary( myTourRow, curDataType, curPlcmtMethod, curPlcmtOrg, curPointsMethod ); myProgressInfo.setProgressValue( 3 ); myProgressInfo.Refresh(); DataTable myJumpDataTable = curCalcSummary.getJumpSummary( myTourRow, curDataType, curPlcmtMethod, curPlcmtOrg, curPointsMethod ); myProgressInfo.setProgressValue( 4 ); myProgressInfo.Refresh(); mySummaryDataTable = curCalcSummary.buildOverallSummary( myTourRow, mySlalomDataTable, myTrickDataTable, myJumpDataTable, curDataType, curPlcmtOverallOrg ); 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 newSummaryDataTable = curCalcSummary.buildTourScorebook( inSanctionId, myTourRow, myMemberData, mySummaryDataTable, mySlalomDetail, myTrickDetail, myJumpDetail ); mySummaryDataTable = newSummaryDataTable; myProgressInfo.setProgressValue( 9 ); myProgressInfo.Refresh(); } mySkierClassList = new ListSkierClass(); mySkierClassList.ListSkierClassLoad(); int curRowCount = 0; myProgressInfo.setProgressMax( curMemberDataTable.Rows.Count ); foreach ( DataRow curMemberRow in curMemberDataTable.Rows ) { curRowCount++; myProgressInfo.setProgressValue( curRowCount ); myProgressInfo.Refresh(); curMemberId = curMemberRow["MemberId"].ToString(); curAgeGroup = curMemberRow["AgeGroup"].ToString(); curReadyToSki = curMemberRow["ReadyToSki"].ToString(); curScoreRows = mySummaryDataTable.Select( "MemberId = '" + curMemberId + "' AND AgeGroup = '" + 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 + "'" ); if ( curReadyToSki.Equals( "Y" ) ) { if ( curScoreRows.Length > 0 ) { //Write skier identification information outLine.Append( writeSkierInfo( curMemberRow, inSanctionId, curRules, curAgeGroup ) ); //Write skier performance summary information //outLine.Append( writeSkierPerfSmry( curMemberId, curAgeGroup, curDataType, curMemberRow, curScoreRows, curScoreSlalomRows, curScoreTrickRows, curScoreJumpRows ) ); outLine.Append( writeSkierPerfSmry( curMemberId, curAgeGroup, curDataType, curMemberRow, curScoreRows, curScoreRows, curScoreRows, curScoreRows ) ); //Write skier performance summary information outLine.Append( writeSkierPerfData( curMemberId, curAgeGroup, curRules, curMemberRow, curScoreRows ) ); //Write output line to file outBuffer.WriteLine( outLine.ToString() ); } } //Initialize output buffer outLine = new StringBuilder( "" ); } returnStatus = true; outBuffer.Close(); myProgressInfo.Close(); if ( curMemberDataTable.Rows.Count > 0 ) { MessageBox.Show( curMemberDataTable.Rows.Count + " rows found and written" ); } else { MessageBox.Show( "No rows found" ); } Log.WriteFile( "Export performance data file complete: " + curFilename ); } } return returnStatus; }
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; }
public Boolean exportScoreBookData() { String curMethodName = "exportScoreBookData"; Boolean returnStatus = false; StringBuilder outLine = new StringBuilder( "" ); String curMsg = "", curMemberId = "", curAgeGroup = "", prevMemberId = "", prevAgeGroup = "", curReadyToSki = ""; String curFileFilter = "SBK files (*.sbk)|*.sbk|All files (*.*)|*.*"; Int16 curRound = 0; DataRow prevRow = null; DataRow[] curScoreRows = null; myTourProperties = TourProperties.Instance; try { curMsg = "Exporting Scorebook"; Log.WriteFile( curMethodName + ":begin: " + curMsg ); String curFilename = mySanctionNum.Trim() + myTourClass + ".sbk"; 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" ); myProgressInfo.Show(); myProgressInfo.Refresh(); myProgressInfo.setProgressMax( 10 ); CalcScoreSummary curCalcSummary = new CalcScoreSummary(); mySummaryDataTable = null; DataTable myMemberData = curCalcSummary.getMemberData( mySanctionNum ); myProgressInfo.setProgressValue( 1 ); myProgressInfo.Refresh(); if (myTourRules.ToLower().Equals( "iwwf" )) { mySummaryDataTable = curCalcSummary.CalcIwwfEventPlcmts( myTourRow, mySanctionNum, "Scorebook", myTourRules, curDataType, curPlcmtMethod, curPlcmtOrg, curPointsMethod, null, null ); myProgressInfo.setProgressValue( 2 ); 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 newSummaryDataTable = curCalcSummary.buildTourScorebook( mySanctionNum, myTourRow, myMemberData, mySummaryDataTable, mySlalomDetail, myTrickDetail, myJumpDetail ); mySummaryDataTable = newSummaryDataTable; myProgressInfo.setProgressValue( 9 ); myProgressInfo.Refresh(); } else { 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(); mySummaryDataTable = curCalcSummary.buildOverallSummary( myTourRow, mySlalomDataTable, myTrickDataTable, myJumpDataTable, curDataType, curPlcmtOverallOrg ); myProgressInfo.setProgressValue( 4 ); 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(); mySummaryDataTable = curCalcSummary.buildTourScorebook( mySanctionNum, myTourRow, myMemberData, mySummaryDataTable, 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 ); 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 ) { outLine = new StringBuilder( "" ); outBuffer.WriteLine( outLine.ToString() ); curScoreRows = mySummaryDataTable.Select( "MemberId = '" + curMemberId + "' AND AgeGroup = '" + curAgeGroup + "'" ); } //Initialize control fields prevMemberId = curMemberId; prevAgeGroup = curAgeGroup; curRound = (Int16)curRow["RoundOverall"]; //Initialize output buffer outLine = new StringBuilder( "" ); //Write skier identification information outLine.Append( writeSkierInfo( curRow, curRound ) ); //Write skier performance summary information outLine.Append( writeSkierSlalomScore( curRow, curScoreRows ) ); outLine.Append( writeSkierTrickScore( curRow, curScoreRows ) ); outLine.Append( writeSkierJumpScore( curRow, curScoreRows ) ); outLine.Append( writeSkierOverallScore( curRow ) ); //Write output line to file outBuffer.WriteLine( outLine.ToString() ); } //Build file footer and write to file outLine = new StringBuilder( "" ); outBuffer.WriteLine( outLine.ToString() ); outLine.Append( writeFooter() ); 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 + ":complete: " + curMsg ); } catch ( Exception ex ) { MessageBox.Show( "Error:" + curMethodName + " Could not write file from DataGridView\n\nError: " + ex.Message ); curMsg = curMethodName + ":Exception=" + ex.Message; Log.WriteFile( curMsg ); returnStatus = false; } return returnStatus; }
public Boolean exportScoreBookData() { String curMethodName = "ExportScoreBookHtmlIwwf"; 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; myTourProperties = TourProperties.Instance; ExportScorebookTypeDialogForm curDialogForm = new ExportScorebookTypeDialogForm(); curDialogForm.ShowDialog(); if (curDialogForm.DialogResult == DialogResult.OK) { String curReportFormat = curDialogForm.ReportFormat; if (curReportFormat.Equals( "Magazine" )) { MessageBox.Show( "This feature is not currently supported for IWWF tournaments" ); } else { try { curMsg = "Exporting Scorebook Html"; Log.WriteFile( curMethodName + ":begin: " + curMsg ); String curFilename = mySanctionNum.Trim() + "CS.HTM"; StreamWriter outBuffer = getExportFile( curFileFilter, curFilename ); if (outBuffer == null) { curMsg = "Output file not available"; } else { String curPlcmtMethod = "score", curPlcmtOrg = "div", curPointsMethod = "kbase"; 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"; } myProgressInfo = new ProgressWindow(); myProgressInfo.setProgessMsg( "Processing Scorebook HTML" ); myProgressInfo.Show(); myProgressInfo.Refresh(); myProgressInfo.setProgressMax( 10 ); CalcScoreSummary curCalcSummary = new CalcScoreSummary(); DataTable myMemberData = curCalcSummary.getMemberData( mySanctionNum ); myProgressInfo.setProgressValue( 4 ); myProgressInfo.Refresh(); DataTable mySummaryDataTable = curCalcSummary.CalcIwwfEventPlcmts( myTourRow, mySanctionNum, "Scorebook", myTourRules, curDataType, curPlcmtMethod, curPlcmtOrg, curPointsMethod, null, null ); 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 newSummaryDataTable = curCalcSummary.buildTourScorebook( mySanctionNum, myTourRow, myMemberData, mySummaryDataTable, mySlalomDetail, myTrickDetail, myJumpDetail ); mySummaryDataTable = newSummaryDataTable; 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, mySummaryDataTable ); } //Build master summary header writeMasterSummaryHeader( outBuffer, curPlcmtOrg, curReportFormat ); 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(); //Initialize control fields prevMemberId = curMemberId; prevAgeGroup = curAgeGroup; curRound = (Int16)curRow["RoundOverall"]; //Initialize output buffer outLine = new StringBuilder( "<tr>" ); //Write skier identification information writeSkierInfo( curRow, curRound, outBuffer ); //Write skier performance summary information writeSkierSlalomScore( curRow, curPlcmtOrg, outBuffer ); writeSkierTrickScore( curRow, curPlcmtOrg, outBuffer ); writeSkierJumpScore( curRow, curPlcmtOrg, outBuffer ); writeSkierOverallScore( curRow, curReportFormat, 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() ); DataTable mySlalomDataTable = curCalcSummary.CalcIwwfEventPlcmts( myTourRow, mySanctionNum, "Slalom", myTourRules, curDataType, curPlcmtMethod, curPlcmtOrg, curPointsMethod, null, null ); writeIndexSlalomResults( curPlcmtOrg, mySlalomDataTable, outBuffer ); DataTable myTrickDataTable = curCalcSummary.CalcIwwfEventPlcmts( myTourRow, mySanctionNum, "Trick", myTourRules, curDataType, curPlcmtMethod, curPlcmtOrg, curPointsMethod, null, null ); writeIndexTrickResults( curPlcmtOrg, myTrickDataTable, outBuffer ); DataTable myJumpDataTable = curCalcSummary.CalcIwwfEventPlcmts( myTourRow, mySanctionNum, "Jump", myTourRules, curDataType, curPlcmtMethod, curPlcmtOrg, curPointsMethod, null, null ); writeIndexJumpResults( curPlcmtOrg, myJumpDataTable, outBuffer ); DataTable myOverallDataTable = curCalcSummary.CalcIwwfEventPlcmts( myTourRow, mySanctionNum, "Overall", myTourRules, "best", curPlcmtMethod, curPlcmtOrg, curPointsMethod, null, null ); writeIndexOverallResults( curPlcmtOrg, myOverallDataTable, outBuffer ); if (isTeamAvailable()) { //Write team summary Int16 myNumPerTeam = Convert.ToInt16( myTourProperties.TeamSummary_NumPerTeam); String curTeamPlcmtOrg = myTourProperties.TeamSummaryPlcmtOrg; //Int16 myNumPerTeam = Properties.Settings.Default.TeamSummary_NumPerTeam; //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"; } String curSortCmd = ""; if (curTeamPlcmtOrg.ToLower().Equals( "div" )) { curSortCmd = "AgeGroup ASC, PointsSlalom DESC, SkierName ASC"; } else { curSortCmd = "PointsSlalom DESC, SkierName ASC"; } mySlalomDataTable.DefaultView.Sort = curSortCmd; mySlalomDataTable = mySlalomDataTable.DefaultView.ToTable(); DataTable myTeamDataTable = curCalcSummary.getSlalomSummaryTeam( mySlalomDataTable, myTourRow, myNumPerTeam, curTeamDataType, curTeamPlcmtMethod, curTeamPlcmtOrg, curTeamPointsMethod ); if (curTeamPlcmtOrg.ToLower().Equals( "div" )) { curSortCmd = "AgeGroup ASC, PointsTrick DESC, SkierName ASC"; } else { curSortCmd = "PointsTrick DESC, SkierName ASC"; } myTrickDataTable.DefaultView.Sort = curSortCmd; myTrickDataTable = myTrickDataTable.DefaultView.ToTable(); myTeamDataTable = curCalcSummary.getTrickSummaryTeam( myTeamDataTable, myTrickDataTable, myTourRow, myNumPerTeam, curTeamDataType, curTeamPlcmtMethod, curTeamPlcmtOrg, curTeamPointsMethod ); if (curTeamPlcmtOrg.ToLower().Equals( "div" )) { curSortCmd = "AgeGroup ASC, PointsJump DESC, SkierName ASC"; } else { curSortCmd = "PointsJump DESC, SkierName ASC"; } myJumpDataTable.DefaultView.Sort = curSortCmd; myJumpDataTable = myJumpDataTable.DefaultView.ToTable(); myTeamDataTable = curCalcSummary.getJumpSummaryTeam( myTeamDataTable, myJumpDataTable, myTourRow, myNumPerTeam, curTeamDataType, curTeamPlcmtMethod, curTeamPlcmtOrg, curTeamPointsMethod ); 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; }