Ejemplo n.º 1
0
        private void btnPromote_Click(object sender, EventArgs e)
        {
            btnPromote.Visible      = false;
            cmboxResult.Enabled     = false;
            cmbPromoTier.DataSource = null;
            lblPromoRank.Text       = "";
            pnlPromo.Visible        = true;
            if (btnPromote.Text == "Demote from Tier")
            {
                using (MCLEntities entities = new MCLEntities())
                {
                    View_AllGames game  = entities.View_AllGames.Where(x => x.PlayerGameId == selectedGame.PlayerGameId).FirstOrDefault();
                    Tier[]        tiers = entities.Tiers.Where(x => x.RankId == game.CurrentRankId && x.TierTypeId != 1).OrderBy(x => x.Index).ToArray();
                    cmbPromoTier.DisplayMember = "Title";
                    cmbPromoTier.DataSource    = tiers;
                    cmbPromoTier.Text          = game.CurrentTier;

                    cmbPromoTier.SelectedIndex = tiers.Length - 1;
                    lblPromoRank.Text          = game.CurrentRank;
                }
            }
            else
            {
                using (MCLEntities entities = new MCLEntities())
                {
                    View_AllGames game     = entities.View_AllGames.Where(x => x.PlayerGameId == selectedGame.PlayerGameId).FirstOrDefault();
                    Rank          nextrank = entities.Ranks.Where(x => x.LeagueId == selectedGame.LeagueId && x.Index > game.CurrentRankIndex).OrderBy(x => x.Index).FirstOrDefault();
                    if (nextrank != null)
                    {
                        Tier[] tiers = entities.Tiers.Where(x => x.RankId == nextrank.RankId && x.TierTypeId != 1).OrderBy(x => x.Index).ToArray();
                        cmbPromoTier.DisplayMember = "Title";
                        cmbPromoTier.DataSource    = tiers;

                        cmbPromoTier.SelectedIndex = 0;
                        lblPromoRank.Text          = nextrank.Title;
                    }
                    else
                    {
                        MessageBox.Show("Alert", "Next Tier is not available", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        void load(int pgid)
        {
            Configuration.KillMediaPlayerProcess();
            tierPoints = new Dictionary <int, int>();
            using (MCLEntities entities = new MCLEntities())
            {
                lblPromo.Visible = false;
                btnPromo.Visible = false;
                selectedGame     = entities.View_AllGames.Where(x => x.PlayerGameId == pgid).FirstOrDefault();
                if ((bool)selectedGame.IsMarked)
                {
                    cmboxResult.Enabled = false;
                }
                else if (selectedGame.GameTierType == "Promo")
                {
                    btnSave.Visible = false;
                }
                lblPlayerName.Text = selectedGame.PlayerName.ToString();
                lblLeague.Text     = selectedGame.League;
                lblStartTime.Text  = selectedGame.GameStartTime.ToString();
                lblEndTime.Text    = selectedGame.GameEndTime.ToString();
                lblGame.Text       = selectedGame.Game;

                Tier[] tiers = entities.Tiers.Where(x => x.RankId == selectedGame.CurrentRankId).OrderBy(x => x.Index).ToArray();
                cmbTier.DisplayMember = "Title";
                cmbTier.DataSource    = tiers;
                cmbTier.Text          = selectedGame.CurrentTier;

                Rank rank  = entities.Ranks.Where(x => x.RankId == selectedGame.CurrentRankId).FirstOrDefault();
                int  point = (int)rank.TierPoints;
                foreach (Tier tier in tiers)
                {
                    tierPoints.Add(tier.TierId, point);
                    point = point + (int)rank.TierPoints;
                }

                Result[] results = entities.Results.ToArray();
                if (selectedGame.GameTier == "Promo")
                {
                    results = results.Where(x => x.ResultId != 3 && x.ResultId != 5).ToArray();
                }
                cmboxResult.DisplayMember = "Title";
                cmboxResult.DataSource    = results;
                cmboxResult.Text          = selectedGame.GameResult;

                if (selectedGame.TotalPoints == null)
                {
                    lblTotalPoints.Text = "0";
                }
                else
                {
                    lblTotalPoints.Text = selectedGame.TotalPoints.ToString();
                }

                lblRank.Text = selectedGame.CurrentRank;


                if (selectedGame.RecordingFileName != null)
                {
                    runMediaPlayerProcess(selectedGame.RecordingFileName);
                }

                if (selectedGame.GameTierType != "Promo")
                {
                    #region Game
                    {
                        if (selectedGame.PromoEnabled)
                        {
                            btnPromo.Text = "Disable";
                            lblPromo.Text = "PROMO ENABLED";
                        }
                        else
                        {
                            btnPromo.Text = "Enable";
                            lblPromo.Text = "PROMO DISABLED";
                        }

                        if ((bool)selectedGame.IsMarked && selectedGame.CurrentTierTypeId == 1)
                        {
                            lblPromo.Visible = true;
                            btnPromo.Visible = true;
                        }
                    }
                    #endregion
                }
                else
                {
                    #region Promo
                    {
                        lblPromo.Visible = false;
                        btnPromo.Visible = false;

                        //        tbPromoTotalPoints.Text = selectedGame.TotalPoints.ToString();


                        //        if (selectedGame.TotalPoints == null) lblTotalPoints.InnerText = "0";
                        //        else lblTotalPoints.InnerText = selectedGame.TotalPoints.ToString();
                    }
                    #endregion
                }
            }
        }