Пример #1
0
		private void createShooter(int cardnr)
		{
			Structs.Shooter shooter = new Structs.Shooter();
			shooter.CardNr = cardnr.ToString();
			shooter.Class = Structs.ShootersClass.Klass1;
			shooter.ClubId = "01-001";
			shooter.Givenname = cardnr.ToString();
			shooter.Surname = cardnr.ToString();
			intf.NewShooter(shooter);
		}
Пример #2
0
		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();
		}
Пример #3
0
		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;
			}
		}
Пример #4
0
		internal Structs.Shooter GetShooter(string cardNr)
		{
			Trace.WriteLine("CDatabase: Entering getShooter(" +
				cardNr + ")");

			var shooter = new Structs.Shooter();

			foreach(DatabaseDataset.ShootersRow row in Database.Shooters.Select("Cardnr='" + cardNr + "'"))
			{
				if (row.Cardnr != cardNr) 
					continue;

				shooter.Arrived = row.Arrived;
				shooter.ClubId = row.ClubId;
				shooter.CardNr = row.Cardnr;
				shooter.Email = row.Email;
				shooter.Givenname = row.Givenname;
				shooter.Surname = row.Surname;
				shooter.Payed = row.Payed;
				shooter.ToAutomatic = row.ToAutomatic;
				shooter.ShooterId = row.ShooterId;
				shooter.Class = (Structs.ShootersClass)row.Class;
				return shooter;
			}
			throw new CannotFindIdException("Cannot find shooter CardNr " + cardNr.ToString());
		}
Пример #5
0
		internal Structs.Shooter GetShooter(int shooterId)
		{
			Trace.WriteLine("CDatabase: Entering getShooter(" +
				shooterId.ToString() + ") on thread \"" +
				System.Threading.Thread.CurrentThread.Name + "\" ( " +
				System.Threading.Thread.CurrentThread.ManagedThreadId.ToString() + " )");

			Structs.Shooter shooter = new Structs.Shooter();

			foreach(DatabaseDataset.ShootersRow row in 
				Database.Shooters/*.Select("shooterId=" + shooterId.ToString(), 
				"")*/)
			{
				if (row.ShooterId == shooterId)
				{
					shooter.Arrived = row.Arrived;
					shooter.ClubId = row.ClubId;
					shooter.CardNr = row.Cardnr;
					shooter.Email = row.Email;
					shooter.Givenname = row.Givenname;
					shooter.Surname = row.Surname;
					shooter.Payed = row.Payed;
					shooter.ToAutomatic = row.ToAutomatic;
					shooter.Automatic = row.Automatic;
					shooter.ShooterId = row.ShooterId;
					shooter.Class = (Structs.ShootersClass)row.Class;
					return shooter;
				}
			}
			throw new CannotFindIdException("Cannot find shooter id " + shooterId);
		}
Пример #6
0
		internal Structs.Shooter[] GetShooters(Structs.Club club, Structs.ResultWeaponsClass wclass)
		{
			Trace.WriteLine(string.Format("CDatabase: Entering getShooters(\"{0}\", {1})", club.ClubId, wclass));

			var shooters = new ArrayList();
			var shooter = new Structs.Shooter();

			foreach(DatabaseDataset.ShootersRow row in Database.Shooters.Select("ClubId='" + club.ClubId + "'", "givenname, surname"))
			{
				foreach(DatabaseDataset.CompetitorsRow comprow in row.GetChildRows("ShootersCompetitors"))
				{
					var weaponsrow = 
						(DatabaseDataset.WeaponsRow)comprow.GetParentRow("WeaponsCompetitors");
					var weaponclass = (Structs.WeaponClass)weaponsrow.Class;
					if (MyInterface.ConvertWeaponsClassToResultClass(weaponclass) != wclass) 
						continue;

					// Only choose those with the same wclass
					shooter = new Structs.Shooter();
					shooter.Arrived = row.Arrived;
					shooter.ClubId = row.ClubId;
					shooter.CardNr = row.Cardnr;
					shooter.Email = row.Email;
					shooter.Givenname = row.Givenname;
					shooter.Surname = row.Surname;
					shooter.Payed = row.Payed;
					shooter.ToAutomatic = row.ToAutomatic;
					shooter.ShooterId = row.ShooterId;
					shooter.Class = (Structs.ShootersClass)row.Class;
					shooters.Add(shooter);
				}
			}
			return (Structs.Shooter[])shooters.ToArray(shooter.GetType());
		}
Пример #7
0
		internal Structs.Shooter[] GetShooters(Structs.Club club)
		{
			Trace.WriteLine("CDatabase: Entering getShooters(\"" + club.ClubId + "\")");

			var shooters = new ArrayList();
			var shooter = new Structs.Shooter();

			foreach(DatabaseDataset.ShootersRow row in Database.Shooters.Select("ClubId='" + club.ClubId + "'", "givenname, surname"))
			{
				shooter = new Structs.Shooter();
				shooter.Arrived = row.Arrived;
				shooter.ClubId = row.ClubId;
				shooter.CardNr = row.Cardnr;
				shooter.Email = row.Email;
				shooter.Givenname = row.Givenname;
				shooter.Surname = row.Surname;
				shooter.Payed = row.Payed;
				shooter.ToAutomatic = row.ToAutomatic;
				shooter.ShooterId = row.ShooterId;
				shooter.Class = (Structs.ShootersClass)row.Class;
				shooters.Add(shooter);
			}
			return (Structs.Shooter[])shooters.ToArray(shooter.GetType());
		}
Пример #8
0
		internal Structs.Shooter[] GetShooters(string sorting)
		{
			Trace.WriteLine("CDatabase: Entering getShooters()");

			var shooters = new ArrayList();
			var shooter = new Structs.Shooter();

			foreach(DatabaseDataset.ShootersRow row in Database.Shooters.Select("", sorting))
			{
				// Safety first...
				if (row.IsArrivedNull())
					row.Arrived = false;

				shooter = new Structs.Shooter();
				shooter.Arrived = row.Arrived;
				shooter.ClubId = row.ClubId;
				shooter.CardNr = row.Cardnr;
				shooter.Email = row.Email;
				shooter.Givenname = row.Givenname;
				shooter.Surname = row.Surname;
				shooter.Payed = row.Payed;
				shooter.ToAutomatic = row.ToAutomatic;
				shooter.ShooterId = row.ShooterId;
				shooter.Class = (Structs.ShootersClass)row.Class;
				shooters.Add(shooter);
			}
			return (Structs.Shooter[])shooters.ToArray(shooter.GetType());
		}
Пример #9
0
		private void btnDelete_Click(object sender, System.EventArgs e)
		{
			Trace.WriteLine("FCompetitors: btnDelete_Click started on thread \"" +
				Thread.CurrentThread.Name + "\" ( " +
				Thread.CurrentThread.ManagedThreadId.ToString() +
				" )");

			Structs.Shooter shooter = new Structs.Shooter();
			DialogResult res =
				MessageBox.Show("Är du säker på att du vill radera både " +
				"resultat och skytt?", 
				"Felmeddelande", 
				MessageBoxButtons.YesNo, 
				MessageBoxIcon.Question);
			if (res == DialogResult.Yes)
			{
				try
				{
					if ((string)this.ddShooters.SelectedValue != NewShooterValue)
					{
						shooter = 
							CommonCode.GetShooter(int.Parse((string)this.ddShooters.SelectedValue));

						foreach (Structs.Competitor comp in 
							CommonCode.GetCompetitors(shooter.ShooterId))
						{
							foreach (Structs.CompetitorResult result in 
								CommonCode.GetCompetitorResults(comp.CompetitorId))
							{
								CommonCode.DelCompetitorResult(result);
							}
							CommonCode.DelCompetitor(comp);
						}
						CommonCode.DelShooter(shooter);
						clearEverything();
					}
				}
				catch(Exception exc)
				{
					Trace.WriteLine(exc.ToString());
					throw;
				}
			}
		}
Пример #10
0
		private void txtCardNr_CursorLeave(object sender, System.EventArgs e)
		{
			// Check if its a current shooter
			if ((string)ddShooters.SelectedValue != NewShooterValue)
			{
				if ((string)this.ddShooters.SelectedValue == null)
					return;

				int selectedShooterId = int.Parse((string)this.ddShooters.SelectedValue);
				Structs.Shooter selectedShooter = new Structs.Shooter();
				try
				{
					selectedShooter = CommonCode.GetShooter(selectedShooterId);
				}
				catch (CannotFindIdException)
				{	return;
				}

				// Current Shooter
				if (selectedShooter.CardNr == this.txtCardNr.Text)
				{
					// Ok, nothings changed.
					return;
				}
				DialogResult res = MessageBox.Show("Vill du ändra " +
					"pistolkortet för denna skytt? \r\n\r\n(" +
					"Om du svarar nej så kommer du att försöka öppna en annan " +
					"skytt med detta nummer)", 
					"Fråga", 
					MessageBoxButtons.YesNo, 
					MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);
				if (res == DialogResult.No |
					res == DialogResult.Cancel)
				{
					// Ok, retrieve shooter
					try
					{
						selectedShooter = CommonCode.GetShooter(this.txtCardNr.Text);
						this.ddShooters.SelectedValue = selectedShooter.ShooterId;
					}
					catch (CannotFindIdException)
					{
						// Shooter didn't exist in current db
						string cardnr = this.txtCardNr.Text;
						this.ddShooters.SelectedIndex = 0;
						try
						{
							selectedShooter = CommonCode.GetShooterFromCache(cardnr);
							this.txtSurName.Text = selectedShooter.Surname;
							this.txtGivenName.Text = selectedShooter.Givenname;
							this.txtEmail.Text = selectedShooter.Email;
							this.ddShooterClass.SelectedValue = (int)selectedShooter.Class;
							this.ddClubs.SelectedValue = selectedShooter.ClubId;
						}
						catch (CannotFindIdException)
						{
							// Person didn't exit in cache
						}
					}

				}
			}
			else
			{
				// New Shooter
				try
				{
					// Check if shooter already exist in db
					Structs.Shooter shooter = CommonCode.GetShooter(this.txtCardNr.Text);
					// Ok, person exists, select it and retreive other values
					ddShooters.SelectedValue = shooter.ShooterId;
					ddShooters_SelectedIndexChanged();
					return;
				}
				catch (CannotFindIdException)
				{
					// We get an CannotFindIdException if person does not exist
					// in db. This is OK.
				}

				// Ok, person does not exist in Db. How about embedded resources?
				try
				{
					Structs.Shooter shooter =
						CommonCode.GetShooterFromCache(txtCardNr.Text);

					// Ok, we've got a shooter since no exception. View him
					txtSurName.Text = shooter.Surname;
					txtGivenName.Text = shooter.Givenname;
					txtEmail.Text = shooter.Email;
					ddShooterClass.SelectedValue = (int)shooter.Class;
					ddClubs.SelectedValue = shooter.ClubId;
				}
				catch (CannotFindIdException)
				{
					// Shooter didn't exist in Cache
					return;
				}
			}
		}
Пример #11
0
		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
		}
		//Override the OnPrintPage to provide the printing logic for the document
		protected override void OnPrintPage(PrintPageEventArgs ev) 
		{
			Trace.WriteLine("CPrintPatrollistByUser: OnPrintPage started" +
				" on thread \"" + Thread.CurrentThread.Name + "\" ( " +
				Thread.CurrentThread.ManagedThreadId.ToString() + " )");

			base.OnPrintPage(ev) ;

			//Work out the number of lines per page 
			//Use the MarginBounds on the event to do this 
			//lpp = ev.MarginBounds.Height  / printFont.GetHeight(ev.Graphics) ;
			float topMargin = ev.MarginBounds.Top;
			topMargin = 25;
			float yPos = topMargin;

			//Now print what we want to print
			Structs.Shooter shooter = new Structs.Shooter();
			if (ShooterIdToPrint != -1)
			{
				shooter = CommonCode.GetShooter(ShooterIdToPrint);
			}
			else
			{
				string temp = null;
				while(temp == null & CommonCode.GetShooterHighestId() >= currentShooter)
				{
					try
					{
						shooter = CommonCode.GetShooter(this.currentShooter);
						temp = "found shooter";
					}
					catch(Common.CannotFindIdException exc)
					{
						Trace.WriteLine("CPrintPatrollistByUser: OnPrintPage Exception " + 
							exc.ToString());
						temp = null;
						currentShooter++;
					}
				}
			}
			printHeader(ev, shooter, ref yPos);
			printShooter(ev, shooter, ref yPos);

			//If we have more patrols then print another page
			if (this.shooterIdToPrint == -1)
			{
				if (CommonCode.GetShooterHighestId() >= this.currentShooter)
					ev.HasMorePages = true;
				else
					ev.HasMorePages = false;
			}
			else
			{
				ev.HasMorePages = false;
			}
		}
Пример #13
0
		private Structs.Shooter GetShooterFromEmbeddedFile(string cardNr)
		{
			var rows =
				(DSStartupResources.ShootersRow[])
				_startup.Shooters.Select(
					"CardNr='" + cardNr + "'");
			if (rows.Length <= 0)
				throw new CannotFindIdException("Could not find shooter");

			var shooter = new Structs.Shooter
			              	{
			              		CardNr = rows[0].Cardnr,
			              		ClubId = rows[0].ClubId,
			              		Email = rows[0].Email,
			              		Givenname = rows[0].Givenname,
			              		Surname = rows[0].Surname,
			              		Automatic = true,
			              		Class = (Structs.ShootersClass) rows[0].Class,
			              		LastUpdate = rows[0].LastUpdate
			              	};

			return shooter;
		}