private void timerAddResults()
		{
			try
			{
				lock(timerAddResultsRunningLock)
				{
					if (timerAddResultsRunning)
						return;
					timerAddResultsRunning = true;
				}
				Trace.WriteLine("timerAddResults_Tick on Thread \"" + 
					Thread.CurrentThread.Name + "\" " +
					Thread.CurrentThread.ManagedThreadId.ToString());

				bool retry = true;
				Structs.Competitor comp = new Structs.Competitor();
				while (retry)
				{
					Structs.Competitor[] comps = CommonCode.GetCompetitors();
					if (comps.Length == 0)
						return;
					comp = comps[rnd.Next(comps.Length)];
					Structs.CompetitorResult[] results;
					try
					{
						results = CommonCode.GetCompetitorResults(comp.CompetitorId);
						if (results.Length < 2)
							retry = false;
					}
					catch(Exception exc)
					{
						Trace.WriteLine(exc.ToString());
						retry = false;
					}
				}
				Structs.Station[] stations = CommonCode.GetStations();
				foreach(Structs.Station station in stations)
				{
					Structs.CompetitorResult res = new Structs.CompetitorResult();
					res.CompetitorId = comp.CompetitorId;
					res.FigureHits = rnd.Next(station.Figures);
					res.Hits = rnd.Next(station.Shoots);
					res.Points = 0;
					res.Station = station.StationId;
					res.StationFigureHits = res.Hits.ToString() + ";";
					CommonCode.NewCompetitorResult(res);
				}
			}
			finally
			{
				timerAddResultsRunning = false;
			}
		}
		private void ImportDatasetThread()
		{
			Trace.WriteLine("CFileImport: ImportDatasetThread started " +
				"on thread \"" + Thread.CurrentThread.Name + "\" ( " +
				System.Threading.Thread.CurrentThread.ManagedThreadId.ToString() + " )");

			int i = -1;
			foreach(DataRow row in this.ViewDatatable.Rows)
			{
				i++;
				string classString = null;

				Trace.WriteLine("CFileImport: ImportDatasetThread calling " +
					"updatedFileImportCount(" + i.ToString() + ", " +
					ViewDatatable.Rows.Count.ToString() + ")");
				myInterface.updatedFileImportCount(
					i,ViewDatatable.Rows.Count);

				// Get shooter
				string shooterCard = (string)row[viewTableColumnNames.Skyttekort.ToString().Trim()];

				// Get shooter from DB
				Structs.Shooter shooter;
				try
				{
					shooter = myInterface.GetShooter(shooterCard);

					classString = (string)row[viewTableColumnNames.Klass.ToString()];
					if (classString.IndexOf("1") >= 0)
						shooter.Class = Structs.ShootersClass.Klass1;
					if (classString.IndexOf("2") >= 0)
						shooter.Class = Structs.ShootersClass.Klass2;
					if (classString.IndexOf("3") >= 0)
						shooter.Class = Structs.ShootersClass.Klass3;

					myInterface.UpdateShooter(shooter);
				}
				catch (CannotFindIdException)
				{
					// Add user to DB with values from file.
					shooter = new Structs.Shooter();
					// What class?
					classString = (string)row[viewTableColumnNames.Klass.ToString()];
					Structs.ShootersClass sclass = Structs.ShootersClass.Klass1;
					if (classString.IndexOf("1") >= 0)
						sclass = Structs.ShootersClass.Klass1;
					if (classString.IndexOf("2") >= 0)
						sclass = Structs.ShootersClass.Klass2;
					if (classString.IndexOf("3") >= 0)
						sclass = Structs.ShootersClass.Klass3;

					if (shooterCard == "")
					{
						try
						{
							Random rnd = new Random();
							while (true)
							{
								shooterCard = (-rnd.Next(100000)).ToString();
								myInterface.GetShooter(shooterCard);
							}
						}
						catch (CannotFindIdException)
						{
						}
					}
					// Create shooter and insert into database
					shooter.Automatic = false;
					shooter.CardNr = shooterCard.ToString();
					shooter.Class = sclass;
					shooter.ClubId = ((string)row[viewTableColumnNames.Klubb.ToString()]).Trim();
					shooter.Email = ((string)row[viewTableColumnNames.Epost.ToString()]).Trim();
					shooter.Givenname = ((string)row[viewTableColumnNames.Efternamn.ToString()]).Trim();
					shooter.Surname = ((string)row[viewTableColumnNames.Fornamn.ToString()]).Trim();
					shooter.Payed = 0;
					shooter.ToAutomatic = false;

					shooter.ShooterId = myInterface.NewShooter(shooter, false);
					if (shooter.ShooterId < 0)
						throw new ApplicationException("ShooterId is " + shooter.ShooterId);
				}

				// Ok, shooter is done. Create competitor
				classString = (string)row[viewTableColumnNames.Klass.ToString().ToUpper()];
				Structs.ShootersClass cclass = shooter.Class;
				if (classString.IndexOf("D")>=0)
				{
					cclass = (Structs.ShootersClass)(
						(int)Structs.ShootersClass.Damklass1 - 1 +
						(int)cclass);
				}
				if (classString.IndexOf("J")>=0)
				{
					cclass = Structs.ShootersClass.Juniorklass;
				}
				if (classString.IndexOf("VY")>=0)
				{
					cclass = Structs.ShootersClass.VeteranklassYngre;
				}
				if (classString.IndexOf("VÄ")>=0)
				{
					cclass = Structs.ShootersClass.VeteranklassÄldre;
				}
				if (classString.IndexOf("Ö")>=0)
				{
					cclass = Structs.ShootersClass.Öppen;
				}

				// Phu, class is done. Continue with competitor
				Structs.Competitor competitor = new Structs.Competitor();
				competitor.CompetitionId = myInterface.GetCompetitions()[0].CompetitionId;
				competitor.ShooterId = shooter.ShooterId;
				competitor.WeaponId = (string)row[viewTableColumnNames.Vapen.ToString()];
				competitor.PatrolId = -1;
				competitor.Lane = -1;
				competitor.ShooterClass = cclass;

				if (!row.IsNull(viewTableColumnNames.Patrull.ToString()) &&
					((string)row[viewTableColumnNames.Patrull.ToString()]).Trim() != "")
				{
					try
					{
						// Patrol defined in importfile
						string patrolString = (string)row[viewTableColumnNames.Patrull.ToString()];
						int patrolId = -1;
						patrolId = int.Parse(patrolString);
						while (patrolId > myInterface.GetPatrolsCount())
						{
							myInterface.PatrolAddEmpty(false);
						}
						competitor.PatrolId = patrolId;
						string laneString = null;
						if (!row.IsNull(viewTableColumnNames.Bana.ToString()))
							laneString = (string)row[viewTableColumnNames.Bana.ToString()];

						if (laneString != null &&
							laneString.Trim() != "")
						{
							competitor.Lane = int.Parse(laneString);
						}
						else
						{
							competitor.Lane = myInterface.PatrolGetNextLane(patrolId);
						}
					}
					catch (System.FormatException)
					{
						// If this occurres, just ignore. It really shouldn't, since
						// it has already been checked
					}
				}

				myInterface.NewCompetitor(competitor, false);
			}

			myInterface.updatedFileImportCount(
				ViewDatatable.Rows.Count,
				ViewDatatable.Rows.Count);
			myInterface.updatedShooter(new Structs.Shooter());
			myInterface.updatedCompetitor(new Structs.Competitor());
			myInterface.updatedPatrol();
		}
		internal Structs.Competitor getCompetitor(int competitorId)
		{
			Trace.WriteLine("CDatabase: Entering getCompetitor(" + 
				competitorId.ToString() + ") on thread \"" +
				System.Threading.Thread.CurrentThread.Name + "\" ( " +
				System.Threading.Thread.CurrentThread.ManagedThreadId.ToString() + " )");

			Structs.Competitor competitor = new Structs.Competitor();

			foreach(DatabaseDataset.CompetitorsRow row in 
				Database.Competitors.Select("CompetitorId=" + competitorId.ToString()))
			{
				if (row.CompetitorId == competitorId)
				{
					competitor.CompetitionId = row.CompetitionId;
					competitor.CompetitorId = row.CompetitorId;
					competitor.ShooterClass = (Structs.ShootersClass)row.ShooterClass;
					if (row.IsPatrolIdNull())
						competitor.PatrolId = -1;
					else
						competitor.PatrolId = row.PatrolId;
					competitor.ShooterId = row.ShooterId;
					competitor.WeaponId = row.WeaponId;
					if (row.IsLaneNull())
						competitor.Lane = -1;
					else
						competitor.Lane = row.Lane;
					competitor.FinalShootingPlace = row.FinalShootingPlace;
					return competitor;
				}
			}
			throw new CannotFindIdException("Could not find competitor with id " + competitorId.ToString());
		}
		private void timerAddShooters()
		{
			try
			{
				lock (timerAddShootersRunningLock)
				{
					if (timerAddShootersRunning)
						return;
					timerAddShootersRunning = true;
				}
				Trace.WriteLine("timerAddShooters_Tick on Thread \" " + 
					Thread.CurrentThread.Name + "\"" +
					Thread.CurrentThread.ManagedThreadId.ToString());

				Structs.Shooter shooter = new Structs.Shooter();
				shooter.Automatic = false;
				shooter.CardNr = rnd.Next(100000).ToString();
				int shooterClassInt = -1;
				while(((Structs.ShootersClass)shooterClassInt).ToString() ==
					shooterClassInt.ToString())
				{
					shooterClassInt = rnd.Next(2)+1;
				}
				shooter.Class = (Structs.ShootersClass)shooterClassInt;
				shooter.ClubId = "01-417";
				shooter.Email = "*****@*****.**";
				shooter.Givenname = shooter.CardNr;
				shooter.Payed = 0;
				shooter.Surname = shooter.CardNr;
				shooter.ToAutomatic = false;
				int shooterId = CommonCode.NewShooter(shooter);

				int nrOfCompetitors = 1 + rnd.Next(3);
				for(int i=0; i<nrOfCompetitors; i++)
				{
					Structs.Competitor comp = new Structs.Competitor();
					comp.CompetitionId = CommonCode.GetCompetitions()[0].CompetitionId;
					while(comp.Lane == 0)
					{
						try
						{
							comp.PatrolId = 1+rnd.Next(80);
							bool retry = true;
							while (retry)
							{
								try
								{
									CommonCode.GetPatrol(comp.PatrolId);
									retry = false;
								}
								catch (Allberg.Shooter.Common.CannotFindIdException)
								{
									CommonCode.PatrolAddEmpty();
								}
							}
							comp.Lane = CommonCode.PatrolGetNextLane(comp.PatrolId);
						}
						catch(Exception)
						{
						}
					}
					comp.ShooterClass = shooter.Class;
					comp.ShooterId = shooterId;
					comp.WeaponId = "G9-A1";
					CommonCode.NewCompetitor(comp);
				}
			}
			catch(Exception exc)
			{
				Trace.WriteLine("Exception while adding competitor:" + exc.ToString());
			}
			finally
			{
				timerAddShootersRunning = false;
			}
		}
		internal Structs.Competitor[] GetCompetitors(Structs.Club ClubToFetch, 
			Structs.ResultWeaponsClass wclass, string sorting)
		{
			Trace.WriteLine("CDatabase: Entering getCompetitors(" + 
				ClubToFetch.ToString() + ", " + wclass + ")");

			Structs.CompetitionTypeEnum compType = getCompetitions()[0].Type;

			ArrayList competitors = new ArrayList();
			Structs.Competitor competitor = new Structs.Competitor();

			foreach(DatabaseDataset.ShootersRow shooter in 
				Database.Shooters.Select("ClubId='" + ClubToFetch.ClubId + "'", sorting))
			{
				DatabaseDataset.CompetitorsRow[] compRows = shooter.GetCompetitorsRows();
				foreach(DatabaseDataset.CompetitorsRow compRow in compRows)
				{
					Structs.Weapon weapon = 
						MyInterface.GetWeapon(compRow.WeaponId);

					if (CConvert.ConvertWeaponsClassToResultClass(weapon.WClass, compType) == wclass)
					{
						Structs.Competitor comp = MyInterface.GetCompetitor(compRow.CompetitorId);
						competitors.Add(comp);
					}
				}
			}
			return (Structs.Competitor[])competitors.ToArray(competitor.GetType());
		}
		internal Structs.Competitor[] getCompetitors(int shooterId, string sorting)
		{
			Trace.WriteLine("CDatabase: Entering getCompetitors(" + 
				shooterId.ToString() + ")");

			ArrayList competitors = new ArrayList();
			Structs.Competitor competitor = new Structs.Competitor();

			foreach(DatabaseDataset.CompetitorsRow row in 
				Database.Competitors.Select("ShooterId=" + shooterId.ToString(), sorting))
			{
				if (row.ShooterId == shooterId)
				{
					competitor = new Structs.Competitor();
					competitor.CompetitionId = row.CompetitionId;
					competitor.CompetitorId = row.CompetitorId;
					competitor.ShooterClass = (Structs.ShootersClass)row.ShooterClass;
					if (row.IsPatrolIdNull())
						competitor.PatrolId = -1;
					else
						competitor.PatrolId = row.PatrolId;
					competitor.ShooterId = row.ShooterId;
					competitor.WeaponId = row.WeaponId;
					if (row.IsLaneNull())
						competitor.Lane = -1;
					else
						competitor.Lane = row.Lane;
					competitor.FinalShootingPlace = row.FinalShootingPlace;
					competitors.Add(competitor);
				}
			}
			return (Structs.Competitor[])competitors.ToArray(competitor.GetType());
		}
		internal Structs.Competitor[] GetCompetitorsWithNoPatrol(
			Structs.PatrolClass thisClass)
		{
			Trace.WriteLine("CDatabase: Entering GetCompetitorsWithNoPatrol(" + 
				thisClass.ToString() + ")");

			ArrayList competitors = new ArrayList();
			Structs.Competitor competitor = new Structs.Competitor();

			foreach(DatabaseDataset.CompetitorsRow row in Database.Competitors.Select("PatrolId is null"))
			{
				if (thisClass == Structs.PatrolClass.Okänd |
					MyInterface.ConvertWeaponsClassToPatrolClass( 
					MyInterface.GetWeapon( row.WeaponId )
					.WClass) == thisClass)
				{
					competitor = new Structs.Competitor();
					competitor.CompetitionId = row.CompetitionId;
					competitor.CompetitorId = row.CompetitorId;
					competitor.ShooterClass = (Structs.ShootersClass)row.ShooterClass;
					if (row.IsPatrolIdNull())
						competitor.PatrolId = -1;
					else
						competitor.PatrolId = row.PatrolId;
					competitor.ShooterId = row.ShooterId;
					competitor.WeaponId = row.WeaponId;
					if (row.IsLaneNull())
						competitor.Lane = -1;
					else
						competitor.Lane = row.Lane;
					competitor.FinalShootingPlace = row.FinalShootingPlace;
					competitors.Add(competitor);
				}
			}
			return (Structs.Competitor[])competitors.ToArray(competitor.GetType());
		}
		private void btnSave_ClickEditShooter(string cardnr)
		{
			#region Edit Shooter
			//edit shooter
			int shooterId = int.Parse((string)this.ddShooters.SelectedValue);

			Structs.Shooter shooter = CommonCode.GetShooter(shooterId);
			if (cardnr != "")
				shooter.CardNr = cardnr;
			shooter.ClubId = (string)this.ddClubs.SelectedValue;
			shooter.Email = this.txtEmail.Text;
			shooter.Givenname = this.txtGivenName.Text;
			shooter.Payed = int.Parse(this.txtPayed.Text);
			shooter.Surname = this.txtSurName.Text;
			shooter.Arrived = chkArrived.Checked;

			int iClass = int.Parse((string)ddShooterClass.SelectedValue);
			shooter.Class = (Structs.ShootersClass)iClass;

			ArrayList updatedCompetitors = new ArrayList();

			// Fixup competitor 1
			if (this.chkCompetitor1.Checked)
			{
				Structs.Competitor comp;
				if (this.competitorIds[0] > -1)
					comp =
						CommonCode.GetCompetitor(this.competitorIds[0]);
				else
				{
					comp = new Structs.Competitor();
					comp.PatrolId = -1;
					comp.Lane = -1;
					comp.CompetitorId = -1;
				}

				comp.WeaponId = (string)this.ddWeapon1.SelectedValue;
				comp.ShooterClass = calculateShootersClass(ref this.ddShooterClass, ref this.ddShooterClass1);
				if (this.ddPatrol1.SelectedIndex == -1)
					comp.PatrolId = -1;
				else
				{
					int newPatrol1 = (int)this.ddPatrol1.SelectedValue;
					if (comp.PatrolId != newPatrol1)
					{
						comp.Lane =
							CommonCode.PatrolGetNextLane(newPatrol1);
						comp.PatrolId = newPatrol1;
					}
				}
				updatedCompetitors.Add(comp);
			}
			else
			{
				// Remove
				if (this.competitorIds[0] > -1)
				{
					removeCompetitor(this.competitorIds[0]);
				}
			}

			// Fixup competitor 2
			if (this.chkCompetitor2.Checked)
			{
				// Add or update
				Structs.Competitor comp;
				if (this.competitorIds[1] > -1)
					comp =
						CommonCode.GetCompetitor(this.competitorIds[1]);
				else
				{
					comp = new Structs.Competitor();
					comp.PatrolId = -1;
					comp.Lane = -1;
					comp.CompetitorId = -1;
				}

				comp.WeaponId = (string)this.ddWeapon2.SelectedValue;
				comp.ShooterClass = calculateShootersClass(ref this.ddShooterClass, ref this.ddShooterClass2);
				if (this.ddPatrol2.SelectedIndex == -1)
					comp.PatrolId = -1;
				else
				{
					int newPatrol2 = (int)this.ddPatrol2.SelectedValue;
					if (comp.PatrolId != newPatrol2)
					{
						comp.Lane =
							CommonCode.PatrolGetNextLane(newPatrol2);
						comp.PatrolId = newPatrol2;
					}
				}
				updatedCompetitors.Add(comp);
			}
			else
			{
				// Remove
				if (this.competitorIds[1] > -1)
				{
					removeCompetitor(this.competitorIds[1]);
				}
			}

			// Fixup competitor 3
			if (this.chkCompetitor3.Checked)
			{
				Structs.Competitor comp;
				if (this.competitorIds[2] > -1)
					comp =
						CommonCode.GetCompetitor(this.competitorIds[2]);
				else
				{
					comp = new Structs.Competitor();
					comp.PatrolId = -1;
					comp.Lane = -1;
					comp.CompetitorId = -1;
				}

				comp.WeaponId = (string)this.ddWeapon3.SelectedValue;
				comp.ShooterClass = calculateShootersClass(ref this.ddShooterClass, ref this.ddShooterClass3);
				if (this.ddPatrol3.SelectedIndex == -1)
					comp.PatrolId = -1;
				else
				{
					int newPatrol3 = (int)this.ddPatrol3.SelectedValue;
					if (comp.PatrolId != newPatrol3)
					{
						comp.Lane =
							CommonCode.PatrolGetNextLane(newPatrol3);
						comp.PatrolId = newPatrol3;
					}
				}
				updatedCompetitors.Add(comp);
			}
			else
			{
				// Remove
				if (this.competitorIds[2] > -1)
				{
					removeCompetitor(this.competitorIds[2]);
				}
			}

			// Fixup competitor 4
			if (this.chkCompetitor4.Checked)
			{
				Structs.Competitor comp;
				if (this.competitorIds[3] > -1)
					comp =
						CommonCode.GetCompetitor(this.competitorIds[3]);
				else
				{
					comp = new Structs.Competitor();
					comp.PatrolId = -1;
					comp.Lane = -1;
					comp.CompetitorId = -1;
				}

				comp.WeaponId = (string)ddWeapon4.SelectedValue;
				comp.ShooterClass = calculateShootersClass(ref this.ddShooterClass, ref this.ddShooterClass4);
				if (this.ddPatrol4.SelectedIndex == -1)
					comp.PatrolId = -1;
				else
				{
					int newPatrol4 = (int)this.ddPatrol4.SelectedValue;
					if (comp.PatrolId != newPatrol4)
					{
						comp.Lane =
							CommonCode.PatrolGetNextLane(newPatrol4);
						comp.PatrolId = newPatrol4;
					}
				}
				updatedCompetitors.Add(comp);
			}
			else
			{
				// Remove
				if (this.competitorIds[3] > -1)
				{
					removeCompetitor(this.competitorIds[3]);
				}
			}

			// UpdateEverything
			Trace.WriteLine("FCompetitors: btnSave_Click saving.");
			CommonCode.UpdateShooter(shooter);
			Structs.Competitor[] compsArray =
				(Structs.Competitor[])updatedCompetitors.ToArray(
				(new Structs.Competitor()).GetType());
			for (int i = 0; i < compsArray.Length; i++)
			{
				Structs.Competitor thisComp = compsArray[i];
				try
				{
					try
					{
						Trace.WriteLine("FCompetitors:btnSave_Click: " +
							"Updating competitor " +
							(i + 1).ToString() + ".");
						CommonCode.UpdateCompetitor(thisComp);
					}
					catch (CannotFindIdException)
					{
						Trace.WriteLine("FCompetitors:btnSave_Click: " +
							"Updating competitor failed for competitor " +
							(i + 1).ToString() + " with " +
							"CannotFindIdException. Saving as " +
							"new competitor.");
						thisComp.CompetitionId =
							CommonCode.GetCompetitions()[0].CompetitionId;
						thisComp.ShooterId = shooterId;
						CommonCode.NewCompetitor(thisComp);
					}
				}
				catch (PatrolAndLaneAlreadyTakenException exc)
				{
					Trace.WriteLine("FCompetitors:btnSave_Click: " +
						"PatrolAndLaneAlreadyTakenException:" +
						exc.ToString());
					MessageBox.Show("Misslyckades med att spara eftersom" +
						"det redan finns en tävlande på denna plats");
				}
			}
			Trace.WriteLine("FCompetitors: btnSave_Click saving done.");
			#endregion
		}
		private void btnSave_ClickNewShooter(string cardnr)
		{
			#region New Shooter
			Trace.WriteLine("FCompetitors: btnSave_Click saving new shooter.");

			// New Shooter
			Structs.Shooter shooter =
				new Structs.Shooter();
			shooter.ClubId = (string)this.ddClubs.SelectedValue;
			shooter.CardNr = cardnr;
			shooter.Email = this.txtEmail.Text;
			shooter.Givenname = this.txtGivenName.Text;
			try
			{
				shooter.Payed = int.Parse(this.txtPayed.Text);
			}
			catch (System.FormatException exc)
			{
				throw new FormatException("Could not parse \"Payed\" as an integer. Value=\"" + 
					this.txtPayed.Text + "\"", exc);
			}
			shooter.ShooterId = -1;
			shooter.Surname = this.txtSurName.Text;
			shooter.ToAutomatic = false;
			shooter.Automatic = false;
			shooter.Arrived = chkArrived.Checked;
			int iClass;
			try
			{
				iClass = int.Parse((string)ddShooterClass.SelectedValue);
			}
			catch (FormatException exc)
			{
				throw new FormatException("Could not parse ddShooterClass for Shooter class. Value=\"" +
					(string)ddShooterClass.SelectedValue, exc);
			}
			shooter.Class = (Structs.ShootersClass)iClass;

			if (CommonCode.EnableInternetConnections & int.Parse(cardnr) > 0)
			{
				DialogResult res =
					MessageBox.Show("Fråga skytten om han vill läggas till " +
					"i Internet-databasen. Vill han/hon det?",
					"Internet-databasen",
					MessageBoxButtons.YesNo,
					MessageBoxIcon.Question);
				if (res == DialogResult.Yes)
					shooter.ToAutomatic = true;
			}

			ArrayList competitors = new ArrayList();

			// Competitor part
			Structs.Competitor comp = new Structs.Competitor();
			if (this.chkCompetitor1.Checked)
			{
				Trace.WriteLine("FCompetitors: btnSave_Click Competitor 1");
				comp = new Structs.Competitor();
				comp.CompetitionId = CommonCode.GetCompetitions()
					[0].CompetitionId;
				//comp.CompetitorId = -1;
				//comp.ShooterId = shooterId;
				comp.WeaponId = (string)ddWeapon1.SelectedValue;
				comp.PatrolId = (int)ddPatrol1.SelectedValue;
				comp.Lane = CommonCode.PatrolGetNextLane(comp.PatrolId);
				comp.ShooterClass = calculateShootersClass(ref this.ddShooterClass, ref this.ddShooterClass1);
				//CommonCode.NewCompetitor(comp);
				//Trace.WriteLine("FCompetitors: btnSave_Click competitor 1 saved");
				competitors.Add(comp);
			}

			if (this.chkCompetitor2.Checked)
			{
				Trace.WriteLine("FCompetitors: btnSave_Click competitor 2");
				comp = new Structs.Competitor();
				comp.CompetitionId = CommonCode.GetCompetitions()
					[0].CompetitionId;
				//comp.CompetitorId = -1;
				//comp.ShooterId = shooterId;
				comp.WeaponId = (string)ddWeapon2.SelectedValue;
				comp.PatrolId = (int)ddPatrol2.SelectedValue;
				comp.Lane = CommonCode.PatrolGetNextLane(comp.PatrolId);
				comp.ShooterClass = calculateShootersClass(ref this.ddShooterClass, ref this.ddShooterClass2);

				//CommonCode.NewCompetitor(comp);
				//Trace.WriteLine("FCompetitors: btnSave_Click competitor 2 saved");
				competitors.Add(comp);
			}

			if (this.chkCompetitor3.Checked)
			{
				Trace.WriteLine("FCompetitors: btnSave_Click competitor 3");
				comp = new Structs.Competitor();
				comp.CompetitionId = CommonCode.GetCompetitions()
					[0].CompetitionId;
				//comp.CompetitorId = -1;
				//comp.ShooterId = shooterId;
				comp.WeaponId = (string)ddWeapon3.SelectedValue;
				comp.PatrolId = (int)ddPatrol3.SelectedValue;
				comp.Lane = CommonCode.PatrolGetNextLane(comp.PatrolId);
				comp.ShooterClass = calculateShootersClass(ref this.ddShooterClass, ref this.ddShooterClass3);

				//CommonCode.NewCompetitor(comp);
				//Trace.WriteLine("FCompetitors: btnSave_Click competotor 3 saved");
				competitors.Add(comp);
			}

			if (this.chkCompetitor4.Checked)
			{
				Trace.WriteLine("FCompetitors: btnSave_Click competitor 4");
				comp = new Structs.Competitor();
				comp.CompetitionId = CommonCode.GetCompetitions()
					[0].CompetitionId;
				//comp.CompetitorId = -1;
				//comp.ShooterId = shooterId;
				comp.WeaponId = (string)ddWeapon4.SelectedValue;
				comp.PatrolId = (int)ddPatrol4.SelectedValue;
				comp.Lane = CommonCode.PatrolGetNextLane(comp.PatrolId);
				comp.ShooterClass = calculateShootersClass(ref this.ddShooterClass, ref this.ddShooterClass4);
				//CommonCode.NewCompetitor(comp);
				competitors.Add(comp);
			}

			// Do actual saving
			Trace.WriteLine("FCompetitors: btnSave_Click Saving shooter...");

			int shooterId = CommonCode.NewShooter(shooter);
			if (shooterId < 1)
			{
				// Oopss...
				Trace.WriteLine("FCompetitors: btnSave_Click " +
					"Failed to save shooter. Returned id was " +
					shooterId);
				MessageBox.Show("Misslyckades med att spara.",
					"Felmeddelande", MessageBoxButtons.OK,
					MessageBoxIcon.Error);
				return;
			}
			Trace.WriteLine("FCompetitors: btnSave_Click New ShooterId is " +
				shooterId.ToString());

			//int i = 0;
			Structs.Competitor[] competitorArray =
				(Structs.Competitor[])competitors.ToArray(comp.GetType());
			for (int i = 0; i < competitorArray.Length; i++)
			{
				Structs.Competitor compsaving = competitorArray[i];
				compsaving.ShooterId = shooterId;
				CommonCode.NewCompetitor(compsaving);
				Trace.WriteLine("FCompetitors: btnSave_Click competitor " + i.ToString() + " saved");
			}

			clearEverything();
			Trace.WriteLine("FCompetitors: btnSave_Click ended");
			#endregion
		}