internal Structs.ResultWeaponsClass[] GetResultWeaponClassesWithResults() { string select = "SELECT DISTINCT weapons.class " + "FROM (weapons RIGHT JOIN Competitors ON weapons.WeaponId = Competitors.WeaponId) " + "INNER JOIN CompetitorResults ON Competitors.CompetitorId = CompetitorResults.CompetitorId;"; System.Data.OleDb.OleDbCommand cmd = new System.Data.OleDb.OleDbCommand( select, myInterface.databaseClass.Conn); if (myInterface.databaseClass.Conn.State != ConnectionState.Open) { myInterface.databaseClass.Conn.Open(); } System.Data.OleDb.OleDbDataReader r = cmd.ExecuteReader(); List <Structs.WeaponClass> wclasses = new List <Structs.WeaponClass>(); while (r.Read()) { wclasses.Add((Structs.WeaponClass)r.GetInt32(0)); } r.Dispose(); cmd.Dispose(); List <Structs.ResultWeaponsClass> rwclasses = new List <Structs.ResultWeaponsClass>(); foreach (Structs.WeaponClass wclass in wclasses) { // Check for duplicates Structs.ResultWeaponsClass rwc = CConvert.ConvertWeaponsClassToResultClass( wclass, myInterface.CompetitionCurrent.Type); if (!rwclasses.Contains(rwc)) { rwclasses.Add(rwc); } } // Sort rwclasses.Sort(); return(rwclasses.ToArray()); }
/// <summary> /// Initiate the class /// </summary> public Interface() { databaseClass = new CDatabase(this); convertClass = new CConvert(); patrolClass = new CPatrolManagement(this); resultClass = new CResultCache(this); resultTeamClass = new CResultTeam(this); internetHtmlExportClass = new CInternetHtmlExport(this); internetPdfExportClass = new CInternetPdfExport(this); internetExcelExportClass = new CInternetExcelExport(this); cacheClass = new Cache(); fileImportClass = new CFileImport(this); internetXmlExportClass = new CInternetXmlExport(this); internetTextExportClass = new CInternetTextExport(this); }
private string checkRowWeapon(DataRow row) { if (row.IsNull(viewTableColumnNames.Vapen.ToString())) { return("VapenID saknas i importfilen"); } if ((string)row[viewTableColumnNames.Vapen.ToString()] == "") { return("VapenID saknas i importfilen"); } string weaponId = (string)row[viewTableColumnNames.Vapen.ToString()]; Structs.Weapon thisWeapon; try { thisWeapon = myInterface.GetWeapon(weaponId); if (myInterface.CompetitionCurrent.Type == Structs.CompetitionTypeEnum.MagnumField) { // Check that this is a magnum. try { CConvert.ConvertWeaponsClassToResultClass( thisWeapon.WClass, Structs.CompetitionTypeEnum.MagnumField); } catch (Exception) { return("VapenID är inte ett Magnum-vapen"); } } } catch (CannotFindIdException) { return("VapenID " + weaponId + " saknas i databasen"); } return(""); }
private List <ResultsReturn> markMedals(List <ResultsReturn> results) { int i = 0; Structs.Competition competition = myInterface.CompetitionCurrent; switch (competition.Type) { case Structs.CompetitionTypeEnum.Field: { if (useNorwegianCount) { foreach (ResultsReturn row in results) { i++; if (row.NorwegianPoints >= standardSilverMedal) { row.Medal = Structs.Medal.StandardSilver; } else if (row.NorwegianPoints >= standardBronsMedal) { row.Medal = Structs.Medal.StardardBrons; } else { row.Medal = Structs.Medal.None; } } } else { foreach (ResultsReturn row in results) { i++; if (row.HitsTotal >= standardSilverMedal) { row.Medal = Structs.Medal.StandardSilver; } else if (row.HitsTotal >= standardBronsMedal) { row.Medal = Structs.Medal.StardardBrons; } else { row.Medal = Structs.Medal.None; } } } break; } case Structs.CompetitionTypeEnum.MagnumField: { foreach (ResultsReturn row in results) { i++; if (row.HitsTotal >= standardSilverMedal) { row.Medal = Structs.Medal.StandardSilver; } else if (row.HitsTotal >= standardBronsMedal) { row.Medal = Structs.Medal.StardardBrons; } else { row.Medal = Structs.Medal.None; } } break; } case Structs.CompetitionTypeEnum.Precision: { int series = myInterface.GetStationsCount(); foreach (ResultsReturn row in results) { i++; if (row.HitsTotal >= standardSilverMedal) { row.Medal = Structs.Medal.StandardSilver; } else if (row.HitsTotal >= standardBronsMedal) { row.Medal = Structs.Medal.StardardBrons; } else { row.Medal = Structs.Medal.None; } Structs.Competitor competitor = myInterface.GetCompetitor(row.CompetitorId); Structs.Weapon weapon = myInterface.GetWeapon(competitor.WeaponId); Structs.ResultWeaponsClass wclass = CConvert.ConvertWeaponsClassToResultClass( weapon.WClass, competition.Type); switch (series) { case 6: { switch (wclass) { case Structs.ResultWeaponsClass.A: { if (row.HitsTotal >= 277) { row.Medal = Structs.Medal.StandardSilver; } else if (row.HitsTotal >= 267 & row.Medal != Structs.Medal.StandardSilver) { row.Medal = Structs.Medal.StardardBrons; } break; } case Structs.ResultWeaponsClass.B: { if (row.HitsTotal >= 282) { row.Medal = Structs.Medal.StandardSilver; } else if (row.HitsTotal >= 273 & row.Medal != Structs.Medal.StandardSilver) { row.Medal = Structs.Medal.StardardBrons; } break; } case Structs.ResultWeaponsClass.C: { if (row.HitsTotal >= 283) { row.Medal = Structs.Medal.StandardSilver; } else if (row.HitsTotal >= 276 & row.Medal != Structs.Medal.StandardSilver) { row.Medal = Structs.Medal.StardardBrons; } break; } } break; } case 7: { switch (wclass) { case Structs.ResultWeaponsClass.A: { if (row.HitsTotal >= 323) { row.Medal = Structs.Medal.StandardSilver; } else if (row.HitsTotal >= 312 & row.Medal != Structs.Medal.StandardSilver) { row.Medal = Structs.Medal.StardardBrons; } break; } case Structs.ResultWeaponsClass.B: { if (row.HitsTotal >= 329) { row.Medal = Structs.Medal.StandardSilver; } else if (row.HitsTotal >= 319 & row.Medal != Structs.Medal.StandardSilver) { row.Medal = Structs.Medal.StardardBrons; } break; } case Structs.ResultWeaponsClass.C: { if (row.HitsTotal >= 330) { row.Medal = Structs.Medal.StandardSilver; } else if (row.HitsTotal >= 322 & row.Medal != Structs.Medal.StandardSilver) { row.Medal = Structs.Medal.StardardBrons; } break; } } break; } case 10: { switch (wclass) { case Structs.ResultWeaponsClass.A: { if (row.HitsTotal >= 461) { row.Medal = Structs.Medal.StandardSilver; } else if (row.HitsTotal >= 445 & row.Medal != Structs.Medal.StandardSilver) { row.Medal = Structs.Medal.StardardBrons; } break; } case Structs.ResultWeaponsClass.B: { if (row.HitsTotal >= 470) { row.Medal = Structs.Medal.StandardSilver; } else if (row.HitsTotal >= 455 & row.Medal != Structs.Medal.StandardSilver) { row.Medal = Structs.Medal.StardardBrons; } break; } case Structs.ResultWeaponsClass.C: { if (row.HitsTotal >= 471) { row.Medal = Structs.Medal.StandardSilver; } else if (row.HitsTotal >= 460 & row.Medal != Structs.Medal.StandardSilver) { row.Medal = Structs.Medal.StardardBrons; } break; } } break; } } } break; } default: throw new ApplicationException("Unknown competition type"); } return(results); }