コード例 #1
0
        public FrmMatch7m(TeamPlayer player, Team team)
        {
            InitializeComponent();

            this.Player = player;
            this.Team = team;

            lblPlayerName.Text = this.Player.Name;
        }
コード例 #2
0
        public FrmPlayersUndo(TeamPlayer player, Team team)
        {
            InitializeComponent();

            this.Player = player;
            this.Team = team;

            lblPlayerName.Text = this.Player.Name;
            txtGoals.Value = this.Player.Goals - this.Player.Goals7m;
            txtGoals7m.Value = this.Player.Goals7m;
            txtWarning.Text = this.Player.Warning.ToString();
            txtSuspension1st.Text = this.Player.Suspension1st.ToString();
            txtSuspension2nd.Text = this.Player.Suspension2nd.ToString();
            txtSuspension3rd.Text = this.Player.Suspension3rd.ToString();
            txtDisqualification.Text = this.Player.Disqualification.ToString();
            txtDisqualificationReport.Text = this.Player.DisqualificationReport.ToString();
        }
コード例 #3
0
        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);
            }
        }