private void button1_Click(object sender, EventArgs e) { lblStatus.Text = ""; string username = txtUsername.Text; string password = txtPassword.Text; if (username.Length == 0 || password.Length == 0) { lblStatus.Text = "Unesite pristupne podatke."; } else { lblStatus.Text = "Povezivanje..."; try { using (var db = new MatchReporterEntities()) { User creditials = (User)db.User .Where(u => u.Username == username) .Where(u => u.Password == password) .FirstOrDefault(); if (creditials == null) { lblStatus.Text = "Krivo uneseni korisnički podaci."; } else { lblStatus.Text = ""; this.Hide(); FrmMatchReporter matchReporter = new FrmMatchReporter(); matchReporter.ShowDialog(); this.Close(); } } } catch { lblStatus.Text = "Problem s internet vezom."; } } //this.Hide(); //FrmMatchReporter matchReporter = new FrmMatchReporter(); //matchReporter.ShowDialog(); //this.Close(); }
public FrmAddTeam(int? homeTeamId, int? guestTeamId) { InitializeComponent(); this.TeamsSelected = false; this.TeamSelectionChanged = false; this.LastHomeTeamId = homeTeamId; this.LastGuestTeamId = guestTeamId; BindingList<Club> homeTeams; BindingList<Club> guestTeams; using (var db = new MatchReporterEntities()) { homeTeams = new BindingList<Club>(db.Club.ToList()); guestTeams = new BindingList<Club>(db.Club.ToList()); } cbxHomeTeam.DataSource = homeTeams; cbxGuestTeam.DataSource = guestTeams; if(homeTeamId != 0 && guestTeamId != 0) { foreach (object row in cbxHomeTeam.Items) { Club data = (Club)row; if (data.ClubId == homeTeamId) { cbxHomeTeam.SelectedItem = row; break; } } foreach (object row in cbxGuestTeam.Items) { Club data = (Club)row; if (data.ClubId == guestTeamId) { cbxGuestTeam.SelectedItem = row; break; } } } }
public FrmAddPlayers(int homeTeamId, int guestTeamId, BindingList<Player> homePlayers, BindingList<Player> guestPlayers) { InitializeComponent(); this.HomeTeamId = homeTeamId; this.GuestTeamId = guestTeamId; string homeTeamName; string guestTeamName; this.PlayersAddSuccess = false; using (var db = new MatchReporterEntities()) { this.HomePlayersAll = new BindingList<Player>(db.Player .Where(p => p.ClubId == homeTeamId).ToList<Player>()); this.GuestPlayersAll = new BindingList<Player>(db.Player .Where(p => p.ClubId == guestTeamId).ToList<Player>()); homeTeamName = (db.Club .Where(c => c.ClubId == homeTeamId).FirstOrDefault().Name).ToString(); guestTeamName = (db.Club .Where(c => c.ClubId == guestTeamId).FirstOrDefault().Name).ToString(); } lblHomeTeamName.Text = homeTeamName; lblGuestTeamName.Text = guestTeamName; this.HomePlayersPlay = new BindingList<Player>(); this.GuestPlayersPlay = new BindingList<Player>(); foreach(Player player in HomePlayersAll) { foreach(Player homePlayer in homePlayers) { if(player.PlayerId == homePlayer.PlayerId) { this.HomePlayersPlay.Add(player); break; } } } foreach (Player player in GuestPlayersAll) { foreach (Player guestPlayer in guestPlayers) { if (player.PlayerId == guestPlayer.PlayerId) { this.GuestPlayersPlay.Add(player); break; } } } this.HomePlayersAddedCount = HomePlayersPlay.Count; this.GuestPlayersAddedCount = GuestPlayersPlay.Count; lblHomeCurrentPlayerNumber.Text = this.HomePlayersAddedCount.ToString() + "/16"; lblGuestCurrentPlayerNumber.Text = this.GuestPlayersAddedCount.ToString() + "/16"; for (int i = 0; i < HomePlayersAll.Count; i++ ) { Player player = HomePlayersAll[i]; for(int j = 0; j < HomePlayersPlay.Count; j++) { if(player.PlayerId == HomePlayersPlay[j].PlayerId) { HomePlayersAll.Remove(player); i--; break; } } } for (int i = 0; i < GuestPlayersAll.Count; i++) { Player player = this.GuestPlayersAll[i]; for (int j = 0; j < this.GuestPlayersPlay.Count; j++) { if (player.PlayerId == this.GuestPlayersPlay[j].PlayerId) { this.GuestPlayersAll.Remove(player); i--; break; } } } dgvHomePlayersAll.DataSource = this.HomePlayersAll; dgvHomePlayersPlay.DataSource = this.HomePlayersPlay; dgvGuestPlayersAll.DataSource = this.GuestPlayersAll; dgvGuestPlayersPlay.DataSource = this.GuestPlayersPlay; }
private void dataTeamsToolStripMenuItem_Click(object sender, EventArgs e) { if(this.Match.MatchId != 0) { FrmAddTeam dataAddTeam = new FrmAddTeam(this.HomeClub.ClubId, this.GuestClub.ClubId); dataAddTeam.ShowDialog(); if (dataAddTeam.TeamsSelected) { Thread loadingThread = new Thread(new ThreadStart(showLoadingForm)); loadingThread.Start(); this.HomeClub = dataAddTeam.HomeTeam; this.GuestClub = dataAddTeam.GuestTeam; this.HomeTeam = new Team(this.Match.MatchId, this.HomeClub.ClubId); this.GuestTeam = new Team(this.Match.MatchId, this.GuestClub.ClubId); this.HomeTeam.JerseyColor = this.HomeClub.JerseyColorHome; this.GuestTeam.JerseyColor = this.GuestClub.JerseyColorGuest; this.lblTeamA.Text = HomeClub.Name; this.lblTeamB.Text = GuestClub.Name; if (dataAddTeam.TeamSelectionChanged) { this.HomePlayers = new BindingList<Player>(); this.GuestPlayers = new BindingList<Player>(); this.HomeTeamPlayers = new BindingList<TeamPlayer>(); this.GuestTeamPlayers = new BindingList<TeamPlayer>(); dgvHomeTeam.DataSource = HomeTeamPlayers; dgvHomeTeam.Refresh(); dgvGuestTeam.DataSource = GuestTeamPlayers; dgvGuestTeam.Refresh(); this.HomePlays = new BindingList<Play>(); this.GuestPlays = new BindingList<Play>(); this.HomeClubOfficials = new BindingList<ClubOfficial>(); this.GuestClubOfficials = new BindingList<ClubOfficial>(); this.HomeTeamOfficials = new BindingList<TeamOfficial>(); this.GuestTeamOfficials = new BindingList<TeamOfficial>(); dgvHomeOfficials.DataSource = this.HomeTeamOfficials; dgvHomeOfficials.Refresh(); dgvGuestOfficials.DataSource = this.GuestTeamOfficials; dgvGuestOfficials.Refresh(); this.HomeManages = new BindingList<Manage>(); this.GuestManages = new BindingList<Manage>(); using (var db = new MatchReporterEntities()) { List<Team> previousTeams = new List<Team>(db.Team.Where<Team>(t => t.MatchId == this.Match.MatchId).ToList<Team>()); foreach (Team team in previousTeams) { db.Team.Remove(team); } db.SaveChanges(); } } using (var db = new MatchReporterEntities()) { db.Entry(this.HomeTeam).State = dataAddTeam.TeamSelectionChanged == true ? EntityState.Added : EntityState.Modified; db.Entry(this.GuestTeam).State = dataAddTeam.TeamSelectionChanged == true ? EntityState.Added : EntityState.Modified; db.SaveChanges(); this.SavedTeams = true; } btnTeamATTO1.Enabled = true; btnTeamATTO2.Enabled = true; btnTeamATTO3.Enabled = true; btnTeamBTTO1.Enabled = true; btnTeamBTTO2.Enabled = true; btnTeamBTTO3.Enabled = true; loadingThread.Abort(); } //dataAddTeam.Dispose(); } else { MessageBox.Show(this, "Da biste dodali momčadi, prvo je potrebno unijeti podatke o utakmici.", "Greška", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private void dataPlayersToolStripMenuItem_Click(object sender, EventArgs e) { if(this.HomeClub.ClubId != 0 && this.GuestClub.ClubId != 0) { FrmAddPlayers dataAddPlayers = new FrmAddPlayers(this.HomeClub.ClubId, this.GuestClub.ClubId, this.HomePlayers, this.GuestPlayers); dataAddPlayers.ShowDialog(); if (dataAddPlayers.PlayersAddSuccess) { Thread loadingThread = new Thread(new ThreadStart(showLoadingForm)); loadingThread.Start(); this.HomePlays = new BindingList<Play>(); this.GuestPlays = new BindingList<Play>(); this.HomePlayers = dataAddPlayers.HomePlayersPlay; this.GuestPlayers = dataAddPlayers.GuestPlayersPlay; this.HomeTeamPlayers.Clear(); this.GuestTeamPlayers.Clear(); using (var db = new MatchReporterEntities()) { List<Play> previousPlays = new List<Play>(db.Play.Where<Play>(p => p.MatchId == this.Match.MatchId).ToList<Play>()); foreach(Play play in previousPlays) { db.Play.Remove(play); } db.SaveChanges(); } foreach (Player player in this.HomePlayers) { TeamPlayer teamPlayer = new TeamPlayer(player.PlayerId, player.FirstName, player.LastName, player.Number); this.HomeTeamPlayers.Add(teamPlayer); Play play = new Play(this.Match.MatchId, player.PlayerId); this.HomePlays.Add(play); } foreach (Player player in this.GuestPlayers) { TeamPlayer teamPlayer = new TeamPlayer(player.PlayerId, player.FirstName, player.LastName, player.Number); this.GuestTeamPlayers.Add(teamPlayer); Play play = new Play(this.Match.MatchId, player.PlayerId); this.GuestPlays.Add(play); } using (var db = new MatchReporterEntities()) { foreach(Play play in this.HomePlays) { db.Play.Add(play); } foreach(Play play in this.GuestPlays) { db.Play.Add(play); } db.SaveChanges(); this.SavedPlays = true; } dgvHomeTeam.DataSource = this.HomeTeamPlayers; dgvGuestTeam.DataSource = this.GuestTeamPlayers; dgvHomeTeam.Refresh(); dgvGuestTeam.Refresh(); btnHomeGoal.Enabled = true; btnGuestGoal.Enabled = true; btnHome7m.Enabled = true; btnGuest7m.Enabled = true; btnHomeWarning.Enabled = true; btnGuestWarning.Enabled = true; btnHomeSuspension.Enabled = true; btnGuestSuspension.Enabled = true; btnHomeDisqualification.Enabled = true; btnGuestDisqualification.Enabled = true; btnHomeDisqualificationReport.Enabled = true; btnGuestDisqualificationReport.Enabled = true; btnHomeUndo.Enabled = true; btnGuestUndo.Enabled = true; loadingThread.Abort(); } //dataAddPlayers.Dispose(); } else { MessageBox.Show(this, "Da biste dodali igrače, prvo je potrebno dodati momčadi.", "Greška", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private void dataOfficialsToolStripMenuItem_Click(object sender, EventArgs e) { if(this.HomeClub.ClubId != 0 && this.GuestClub.ClubId != 0) { FrmAddOfficials dataAddOfficials = new FrmAddOfficials(this.HomeClub.ClubId, this.GuestClub.ClubId, this.HomeClubOfficials, this.GuestClubOfficials); dataAddOfficials.ShowDialog(); if (dataAddOfficials.OfficialsAddSuccess) { Thread loadingThread = new Thread(new ThreadStart(showLoadingForm)); loadingThread.Start(); this.HomeManages = new BindingList<Manage>(); this.GuestManages = new BindingList<Manage>(); this.HomeClubOfficials = dataAddOfficials.HomeOfficialsManage; this.GuestClubOfficials = dataAddOfficials.GuestOfficialsManage; this.HomeTeamOfficials.Clear(); this.GuestTeamOfficials.Clear(); using (var db = new MatchReporterEntities()) { List<Manage> previousManages = new List<Manage>(db.Manage.Where<Manage>(m => m.MatchId == this.Match.MatchId).ToList<Manage>()); foreach (Manage manage in previousManages) { db.Manage.Remove(manage); } db.SaveChanges(); } foreach (ClubOfficial official in this.HomeClubOfficials) { TeamOfficial teamOfficial = new TeamOfficial(official.ClubOfficialId, official.FirstName, official.LastName); this.HomeTeamOfficials.Add(teamOfficial); Manage manage = new Manage(this.Match.MatchId, official.ClubOfficialId); this.HomeManages.Add(manage); } foreach (ClubOfficial official in this.GuestClubOfficials) { TeamOfficial teamOfficial = new TeamOfficial(official.ClubOfficialId, official.FirstName, official.LastName); this.GuestTeamOfficials.Add(teamOfficial); Manage manage = new Manage(this.Match.MatchId, official.ClubOfficialId); this.GuestManages.Add(manage); } using (var db = new MatchReporterEntities()) { foreach (Manage manage in this.HomeManages) { db.Manage.Add(manage); } foreach (Manage manage in this.GuestManages) { db.Manage.Add(manage); } db.SaveChanges(); this.SavedManages = true; } dgvHomeOfficials.DataSource = this.HomeTeamOfficials; dgvGuestOfficials.DataSource = this.GuestTeamOfficials; dgvHomeOfficials.Refresh(); dgvGuestOfficials.Refresh(); btnHomeOfficialWarning.Enabled = true; btnGuestOfficialWarning.Enabled = true; btnHomeOfficialSuspension.Enabled = true; btnGuestOfficialSuspension.Enabled = true; btnHomeOfficialDisqualification.Enabled = true; btnGuestOfficialDisqualification.Enabled = true; btnHomeOfficialUndo.Enabled = true; btnGuestOfficialUndo.Enabled = true; loadingThread.Abort(); } //dataAddOfficials.Dispose(); } else { MessageBox.Show(this, "Da biste dodali službene osobe, prvo je potrebno dodati momčadi.", "Greška", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private void dataMatchDetailsToolStripMenuItem_Click(object sender, EventArgs e) { FrmAddMatchDetails dataAddMatchDetails = new FrmAddMatchDetails(this.Match); dataAddMatchDetails.ShowDialog(); if (dataAddMatchDetails.MatchDetailsAddSuccess) { this.Match.LeagueId = dataAddMatchDetails.LeagueId; this.Match.Round = dataAddMatchDetails.Round; this.Match.Date = dataAddMatchDetails.Date; this.Match.Time = dataAddMatchDetails.Time; this.Match.HallId = dataAddMatchDetails.HallId; this.Match.Spectators = dataAddMatchDetails.Spectators; this.Match.RefereePairId = dataAddMatchDetails.RefereePairId; this.Match.DelegateId = dataAddMatchDetails.DelegateId; this.Match.TimeKeeper = dataAddMatchDetails.TimeKeeper; this.Match.Scorer = dataAddMatchDetails.Scorer; this.RefereePairName = dataAddMatchDetails.RefereePairName; using (var db = new MatchReporterEntities()) { db.Entry(this.Match).State = this.Match.MatchId == 0 ? EntityState.Added : EntityState.Modified; db.SaveChanges(); } } //dataAddMatchDetails.Dispose(); }
private void matchSaveToolStripMenuItem_Click(object sender, EventArgs e) { Thread savingDataThread = new Thread(new ThreadStart(showSavingForm)); savingDataThread.Start(); try { // HomeTeamPlayers > HomePlays, GuestTeamPlayers > GuestPlays foreach(TeamPlayer teamPlayer in HomeTeamPlayers) { Play play = HomePlays .Where(p => p.MatchId == this.Match.MatchId) .Where(p => p.PlayerId == teamPlayer.TeamPlayerId) .FirstOrDefault(); if(play != null) { play.Goals = teamPlayer.Goals; play.Goals7m = teamPlayer.Goals7m; play.Warning = teamPlayer.Warning; play.SuspensionFirst = teamPlayer.Suspension1st; play.SuspensionSecond = teamPlayer.Suspension2nd; play.SuspensionThird = teamPlayer.Suspension3rd; play.Disqualification = teamPlayer.Disqualification; play.DisqualificationAdnReport = teamPlayer.DisqualificationReport; } } foreach (TeamPlayer teamPlayer in GuestTeamPlayers) { Play play = GuestPlays .Where(p => p.MatchId == this.Match.MatchId) .Where(p => p.PlayerId == teamPlayer.TeamPlayerId) .FirstOrDefault(); if (play != null) { play.Goals = teamPlayer.Goals; play.Goals7m = teamPlayer.Goals7m; play.Warning = teamPlayer.Warning; play.SuspensionFirst = teamPlayer.Suspension1st; play.SuspensionSecond = teamPlayer.Suspension2nd; play.SuspensionThird = teamPlayer.Suspension3rd; play.Disqualification = teamPlayer.Disqualification; play.DisqualificationAdnReport = teamPlayer.DisqualificationReport; } } // HomeTeamOfficials > HomeManages, GuestTeamOfficials > GuestManages foreach(TeamOfficial teamOfficial in HomeTeamOfficials) { Manage manage = HomeManages .Where(m => m.MatchId == this.Match.MatchId) .Where(m => m.ClubOfficialId == teamOfficial.TeamOfficialId) .FirstOrDefault(); if(manage != null) { manage.Warning = teamOfficial.Warning; manage.Suspension = teamOfficial.Suspension; manage.Disqualification = teamOfficial.Disqualification; } } foreach (TeamOfficial teamOfficial in GuestTeamOfficials) { Manage manage = GuestManages .Where(m => m.MatchId == this.Match.MatchId) .Where(m => m.ClubOfficialId == teamOfficial.TeamOfficialId) .FirstOrDefault(); if (manage != null) { manage.Warning = teamOfficial.Warning; manage.Suspension = teamOfficial.Suspension; manage.Disqualification = teamOfficial.Disqualification; } } // Saving data using (var db = new MatchReporterEntities()) { db.Entry(this.Match).State = this.Match.MatchId == 0 ? EntityState.Added : EntityState.Modified; db.Entry(this.HomeTeam).State = this.SavedTeams == false ? EntityState.Added : EntityState.Modified; db.Entry(this.GuestTeam).State = this.SavedTeams == false ? EntityState.Added : EntityState.Modified; this.SavedTeams = true; foreach (Play play in HomePlays) { db.Entry(play).State = this.SavedPlays == false ? EntityState.Added : EntityState.Modified; } foreach (Play play in GuestPlays) { db.Entry(play).State = this.SavedPlays == false ? EntityState.Added : EntityState.Modified; } this.SavedPlays = true; foreach (Manage manage in HomeManages) { db.Entry(manage).State = this.SavedManages == false ? EntityState.Added : EntityState.Modified; } foreach (Manage manage in GuestManages) { db.Entry(manage).State = this.SavedManages == false ? EntityState.Added : EntityState.Modified; } this.SavedManages = true; db.SaveChanges(); } savingDataThread.Abort(); MessageBox.Show(this, "Podaci su uspješno spremljeni.", "Spremanje podataka", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch { savingDataThread.Abort(); MessageBox.Show(this, "Došlo je do pogreške.\nPodaci nisu spremljeni.", "Spremanje podataka", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void matchConcludeToolStripMenuItem_Click(object sender, EventArgs e) { if(int.Parse(lblTimeMinutes.Text) == 60) { if (MessageBox.Show(this, "Jeste li sigurni da želite zaključiti utakmicu? \nViše neće biti moguće mijenjati podatke o utakmici.", "Zaključi utakmicu", MessageBoxButtons.YesNo, MessageBoxIcon.Question).Equals(DialogResult.Yes)) { try { this.Match.Concluded = 1; panelMain.Enabled = false; this.dataMatchDetailsToolStripMenuItem.Enabled = false; this.dataTeamsToolStripMenuItem.Enabled = false; this.dataPlayersToolStripMenuItem.Enabled = false; this.dataOfficialsToolStripMenuItem.Enabled = false; this.matchSaveToolStripMenuItem.Enabled = false; this.matchConcludeToolStripMenuItem.Enabled = false; using (var db = new MatchReporterEntities()) { db.Entry(this.Match).State = this.Match.MatchId == 0 ? EntityState.Added : EntityState.Modified; db.SaveChanges(); } } catch { MessageBox.Show(this, "Došlo je do greške. \nUtakmica nije zaključena.", "Greška", MessageBoxButtons.YesNo, MessageBoxIcon.Error); } } } else { MessageBox.Show(this, "Ne možete zaključiti utakmicu jer \nutakmica nije završena.", "Greška", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } }
private void FrmMatchReport_Load(object sender, EventArgs e) { string leagueName; string hallName; int hallCapacity; string city; string spectators; string date; string time; string supervizor; string scorer; string timeKeeper; using(var db = new MatchReporterEntities()) { leagueName = db.Match.Where(m => m.MatchId == this.Match.MatchId).FirstOrDefault().League.Name; hallName = db.Match.Where(m => m.MatchId == this.Match.MatchId).FirstOrDefault().Hall.Name; hallCapacity = db.Match.Where(m => m.MatchId == this.Match.MatchId).FirstOrDefault().Hall.Capacity; city = db.Hall.Where(h => h.Name == hallName).FirstOrDefault().City.Name; Delegate supervizorObject = db.Delegate.Where(d => d.DelegateId == this.Match.DelegateId).FirstOrDefault(); supervizor = supervizorObject.FirstName + " " + supervizorObject.LastName; } spectators = this.Match.Spectators.ToString() + "/" + hallCapacity.ToString(); date = this.Match.Date.ToShortDateString(); string hours = this.Match.Time.Hours.ToString(); string minutes = this.Match.Time.Minutes.ToString(); if(this.Match.Time.Hours < 10) { hours = "0" + this.Match.Time.Hours.ToString(); } if(this.Match.Time.Minutes < 10) { minutes = "0" + this.Match.Time.Minutes.ToString(); } time = hours + ":" + minutes; scorer = this.Match.Scorer; timeKeeper = this.Match.TimeKeeper; this.HomeTeamPlayerBindingSource.DataSource = this.HomeTeamPlayers; this.GuestTeamPlayerBindingSource.DataSource = this.GuestTeamPlayers; this.HomeTeamOfficialBindingSource.DataSource = this.HomeTeamOfficials; this.GuestTeamOfficialBindingSource.DataSource = this.GuestTeamOfficials; ReportParameterCollection parameters = new ReportParameterCollection(); parameters.Add(new ReportParameter("MatchId", this.Match.MatchId.ToString())); parameters.Add(new ReportParameter("Round", this.Match.Round.ToString())); parameters.Add(new ReportParameter("LeagueName", leagueName)); parameters.Add(new ReportParameter("HallName", hallName + ", " + city)); parameters.Add(new ReportParameter("Spectators", spectators)); parameters.Add(new ReportParameter("Date", date)); parameters.Add(new ReportParameter("Time", time)); parameters.Add(new ReportParameter("HomeTeamName", this.HomeClub.Name)); parameters.Add(new ReportParameter("GuestTeamName", this.GuestClub.Name)); parameters.Add(new ReportParameter("HomeTeamGoals", this.HomeTeam.Goals.ToString())); parameters.Add(new ReportParameter("GuestTeamGoals", this.GuestTeam.Goals.ToString())); parameters.Add(new ReportParameter("HomeTeamTTO1", this.HomeTeam.TTO1 != null ? this.HomeTeam.TTO1 : " /")); parameters.Add(new ReportParameter("HomeTeamTTO2", this.HomeTeam.TTO2 != null ? this.HomeTeam.TTO2 : " /")); parameters.Add(new ReportParameter("HomeTeamTTO3", this.HomeTeam.TTO3 != null ? this.HomeTeam.TTO3 : " /")); parameters.Add(new ReportParameter("GuestTeamTTO1", this.GuestTeam.TTO1 != null ? this.GuestTeam.TTO1 : " /")); parameters.Add(new ReportParameter("GuestTeamTTO2", this.GuestTeam.TTO2 != null ? this.GuestTeam.TTO2 : " /")); parameters.Add(new ReportParameter("GuestTeamTTO3", this.GuestTeam.TTO3 != null ? this.GuestTeam.TTO3 : " /")); parameters.Add(new ReportParameter("RefereePair", refereePairName)); parameters.Add(new ReportParameter("Delegate", supervizor)); parameters.Add(new ReportParameter("Scorer", scorer)); parameters.Add(new ReportParameter("TimeKeeper", timeKeeper)); parameters.Add(new ReportParameter("HomeTeam7m", this.HomeTeam.Goals7m.ToString() + "/" + this.HomeTeam.Attempts7m.ToString())); parameters.Add(new ReportParameter("GuestTeam7m", this.GuestTeam.Goals7m.ToString() + "/" + this.GuestTeam.Attempts7m.ToString())); this.matchReport.LocalReport.SetParameters(parameters); this.matchReport.RefreshReport(); }
public FrmAddOfficials(int homeTeamId, int guestTeamId, BindingList<ClubOfficial> homeOfficials, BindingList<ClubOfficial> guestOfficials) { InitializeComponent(); this.HomeTeamId = homeTeamId; this.GuestTeamId = guestTeamId; this.HomeOfficialsAddedCount = homeOfficials.Count; this.GuestOfficialsAddedCount = guestOfficials.Count; lblHomeOfficialsCount.Text = this.HomeOfficialsAddedCount.ToString() + "/4"; lblGuestOfficialsCount.Text = this.GuestOfficialsAddedCount.ToString() + "/4"; string homeTeamName; string guestTeamName; this.OfficialsAddSuccess = false; using (var db = new MatchReporterEntities()) { this.HomeOfficialsAll = new BindingList<ClubOfficial>(db.ClubOfficial .Where(p => p.ClubId == homeTeamId).ToList<ClubOfficial>()); this.GuestOfficialsAll = new BindingList<ClubOfficial>(db.ClubOfficial .Where(p => p.ClubId == guestTeamId).ToList<ClubOfficial>()); homeTeamName = (db.Club .Where(c => c.ClubId == homeTeamId).FirstOrDefault().Name).ToString(); guestTeamName = (db.Club .Where(c => c.ClubId == guestTeamId).FirstOrDefault().Name).ToString(); } lblHomeTeamName.Text = homeTeamName; lblGuestTeamName.Text = guestTeamName; this.HomeOfficialsManage = new BindingList<ClubOfficial>(); this.GuestOfficialsManage = new BindingList<ClubOfficial>(); foreach(ClubOfficial official in this.HomeOfficialsAll) { foreach(ClubOfficial homeOfficial in homeOfficials) { if(official.ClubOfficialId == homeOfficial.ClubOfficialId) { this.HomeOfficialsManage.Add(official); break; } } } foreach (ClubOfficial official in this.GuestOfficialsAll) { foreach (ClubOfficial guestOfficial in guestOfficials) { if (official.ClubOfficialId == guestOfficial.ClubOfficialId) { this.GuestOfficialsManage.Add(official); break; } } } for (int i = 0; i < this.HomeOfficialsAll.Count; i++) { ClubOfficial official = this.HomeOfficialsAll[i]; for (int j = 0; j < this.HomeOfficialsManage.Count; j++) { if (official.ClubOfficialId == this.HomeOfficialsManage[j].ClubOfficialId) { this.HomeOfficialsAll.Remove(official); i--; break; } } } for (int i = 0; i < this.GuestOfficialsAll.Count; i++) { ClubOfficial official = this.GuestOfficialsAll[i]; for (int j = 0; j < this.GuestOfficialsManage.Count; j++) { if (official.ClubOfficialId == this.GuestOfficialsManage[j].ClubOfficialId) { this.GuestOfficialsAll.Remove(official); i--; break; } } } dgvHomeOfficialsAll.DataSource = this.HomeOfficialsAll; dgvHomeOfficialsManage.DataSource = this.HomeOfficialsManage; dgvGuestOfficialsAll.DataSource = this.GuestOfficialsAll; dgvGuestOfficialsManage.DataSource = this.GuestOfficialsManage; }