Ejemplo n.º 1
0
        private void DoPageLoad()
        {
            Stopwatch lcStopWatch = new Stopwatch(); lcStopWatch.Reset(); lcStopWatch.Start();
            tcGridViewType lcGridViewType = new tcGridViewType(teGridViewType.eeCoursePage, teSubPageType.eeSubPageNone);
            
            string lpanCheck = Request.QueryString["cp"];

            int lnCourseId = GetCourseId();
            
            //Set map and course labels
            tcMySqlCommand lcMySqlCommand = new tcMySqlCommand(@"SELECT M.name,C.name FROM kzs_courses AS C, kzs_maps AS M WHERE C.id = " + lnCourseId + @" AND M.id = (SELECT map FROM kzs_courses WHERE id =  " + lnCourseId + @" LIMIT 1)");
            MySqlDataReader lcMySqlReader = lcMySqlCommand.mcMySqlCommand.ExecuteReader();
            lcMySqlReader.Read();

            if (lcMySqlReader.HasRows)
            {
                gcMapLink.Text = lcMySqlReader.GetString(0);
                gcMapLink.NavigateUrl = "~/map.aspx?id=" + gcMapLink.Text + "&cp=" + lpanCheck;
                gcMapLink.Style.Value = "text-decoration:none"; //Remove underline

                gcCourseName.Text = lcMySqlReader.GetString(1);
            }

            lcMySqlCommand.Close();

            string lpanQuery = GetQueryFromDropDownState(lnCourseId);
            lcGridViewType.meSub = GetGridTypeFromDropDownState();

            //Set gridview data
            tcMySqlDataSource lcMySqlDataSource = new tcMySqlDataSource(lpanQuery);

            DataTable lcDataTable = lcMySqlDataSource.GetDataTable();

            //If the course has records
            if (lcDataTable != null)
            {
                tcGridView lcGridView = GridViewFactory.Create(lcDataTable, lcGridViewType);

                Panel4.Controls.AddAt(0, lcGridView);
            }

            tcLinkPanel.AddLinkPanel(this);
            Page.DataBind();
            lcStopWatch.Stop(); gcPageLoad.Text = lcStopWatch.ElapsedMilliseconds.ToString();
        }
Ejemplo n.º 2
0
        public void InitializeServerListFromSqlDatabase()
        {
            mcServerList.Clear();

            tcMySqlCommand lcMySqlCommand = new tcMySqlCommand(@"SELECT auth_key,ip,dynamic_ip FROM kzs_servers;");

            MySqlDataReader lcMySqlReader = lcMySqlCommand.mcMySqlCommand.ExecuteReader();

            while (lcMySqlReader.HasRows && !lcMySqlReader.IsClosed && lcMySqlReader.Read())
            {
                string lpanAuthKey = lcMySqlReader.GetString(0);
                string lpanIp      = lcMySqlReader.GetString(1);
                int    lnDynamicIp = lcMySqlReader.GetInt32(2);

                AddServer(lpanAuthKey, lpanIp, lnDynamicIp);
            }

            lcMySqlReader.Close();
        }
Ejemplo n.º 3
0
        public void InitializeServerListFromSqlDatabase()
        {
            mcServerList.Clear();

            tcMySqlCommand lcMySqlCommand = new tcMySqlCommand(@"SELECT auth_key,ip,dynamic_ip FROM kzs_servers;");

            MySqlDataReader lcMySqlReader = lcMySqlCommand.mcMySqlCommand.ExecuteReader();

            while(lcMySqlReader.HasRows && !lcMySqlReader.IsClosed && lcMySqlReader.Read())
            {
                string lpanAuthKey = lcMySqlReader.GetString(0);
                string lpanIp = lcMySqlReader.GetString(1);
                int lnDynamicIp = lcMySqlReader.GetInt32(2);

                AddServer(lpanAuthKey, lpanIp, lnDynamicIp);
            }

            lcMySqlReader.Close();

        }
Ejemplo n.º 4
0
        private void GetNumCourses(out int anNumCourses)
        {
            anNumCourses = 0;

            tcMySqlCommand lcMySqlCommand = new tcMySqlCommand(@"SELECT COUNT(*) AS NumCourses FROM kzs_courses");
            MySqlDataReader lcMySqlReader = lcMySqlCommand.mcMySqlCommand.ExecuteReader();
            lcMySqlReader.Read();

            if (lcMySqlReader.HasRows)
            {
                anNumCourses = lcMySqlReader.GetInt32(0);
            }

            lcMySqlCommand.Close();
        }
Ejemplo n.º 5
0
        private void GetChecksAndTeles(out int anUniqueCpRecord, out int anNumChecks, out int anNumTeles)
        {
            anNumChecks = 0;
            anNumTeles = 0;
            anUniqueCpRecord = 0;

            tcMySqlCommand lcMySqlCommand = new tcMySqlCommand(@"SELECT COUNT(DISTINCT(Rcp.id)) AS Count, SUM(Rcp.cp) AS Cp, SUM(Rcp.tele) AS Tele FROM kzs_recordscp AS Rcp");
            MySqlDataReader lcMySqlReader = lcMySqlCommand.mcMySqlCommand.ExecuteReader();
            lcMySqlReader.Read();

            if (lcMySqlReader.HasRows)
            {
                anUniqueCpRecord = lcMySqlReader.GetInt32(0);
                anNumChecks = lcMySqlReader.GetInt32(1);
                anNumTeles = lcMySqlReader.GetInt32(2);
            }

            lcMySqlCommand.Close();
        }
Ejemplo n.º 6
0
        private void GetUniqueNocheckCount(out int anUniqueNocheckRecord)
        {
            anUniqueNocheckRecord = 0;

            tcMySqlCommand lcMySqlCommand = new tcMySqlCommand(@"SELECT COUNT(DISTINCT(R.id)) FROM kzs_records AS R");
            MySqlDataReader lcMySqlReader = lcMySqlCommand.mcMySqlCommand.ExecuteReader();
            lcMySqlReader.Read();

            if (lcMySqlReader.HasRows)
            {
                anUniqueNocheckRecord = lcMySqlReader.GetInt32(0);
            }

            lcMySqlCommand.Close();
        }
Ejemplo n.º 7
0
        private void DoPageLoad()
        {
            Stopwatch lcStopWatch = new Stopwatch(); lcStopWatch.Reset(); lcStopWatch.Start();
            tcGridViewType lcGridViewType = new tcGridViewType(teGridViewType.eeMapPage,teSubPageType.eeSubPageNone);
            HyperLink lcCourseName;

            string lpanMapName = Request.QueryString["id"];
            lpanMapName = StaticMethods.CheckSqlReqValidity(lpanMapName, "kz_bhop_ocean");
            gcLabelMapName.Text = lpanMapName;

            tcMySqlCommand lcMySqlCommand = new tcMySqlCommand(@"SELECT id,name FROM kzs_courses WHERE map = (SELECT id FROM kzs_maps WHERE name = ?map LIMIT 1) ORDER BY id ASC;");
            lcMySqlCommand.mcMySqlCommand.Parameters.Add("?map", lpanMapName);

            MySqlDataReader lcMySqlReader = lcMySqlCommand.mcMySqlCommand.ExecuteReader();
            
            int lnIndex = 0;
            int lnCourseId = 0;

            //Loop over courses to add labels and records
            while (lcMySqlReader.HasRows && !lcMySqlReader.IsClosed && lcMySqlReader.Read())
            {
                Debug.WriteLine(lcMySqlReader.GetString(0) + " " + lcMySqlReader.GetString(1));
                lnCourseId = lcMySqlReader.GetInt32(0);

                if (lnCourseId < 1)
                {
                    lnCourseId = 1;
                }

                //Set properties for the hyperlink to the course page
                lcCourseName = GetCourseHyperLink(lcMySqlReader.GetString(1), "~/course.aspx?id=" + lnCourseId);

                //Indent course hyperlink and add to the panel
                Panel4.Controls.AddAt(lnIndex++, new LiteralControl("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"));
                Panel4.Controls.AddAt(lnIndex++, lcCourseName);
                
                Panel4.Controls.AddAt(lnIndex++, new LiteralControl("&nbsp;"));
                Label lcWr = GetWrLabel(lnCourseId);
                Panel4.Controls.AddAt(lnIndex++, lcWr);

                string lpanCp = Request.QueryString["cp"];

                //Handle requests for checkpoints that are not postbacks from dropdown state change
                if (Page.IsPostBack == false && lpanCp != null && lpanCp.Equals("1"))
                {
                    gcDropDown.SelectedValue = "cp";
                }

                string lpanQuery = GetQueryFromDropDownState(lnCourseId);
                lcGridViewType.meSub = GetGridTypeFromDropDownState();

                tcMySqlDataSource lcMySqlDataSource = new tcMySqlDataSource(lpanQuery);

                DataTable lcDataTable = lcMySqlDataSource.GetDataTable();

                //If the course has records
                if (lcDataTable != null && lcDataTable.Rows.Count > 0)
                {
                    tcGridView lcGridView = GridViewFactory.Create(lcDataTable, lcGridViewType);
                    
                    Panel4.Controls.AddAt(lnIndex++, new LiteralControl("<br>"));
                    Panel4.Controls.AddAt(lnIndex++, lcGridView);
                    Panel4.Controls.AddAt(lnIndex++, new LiteralControl("<br>"));
                }
                else //Else the course has no records
                {
                    Label lcNoRecords = new Label();
                    lcNoRecords.Text = " - No records!";

                    Panel4.Controls.AddAt(lnIndex++, lcNoRecords);
                    Panel4.Controls.AddAt(lnIndex++, new LiteralControl("<br><br>"));
                }
            }

            lcMySqlCommand.Close();

            tcLinkPanel.AddLinkPanel(this);

            //Refresh all the gridviews with data contents
            Page.DataBind();
            Page.MaintainScrollPositionOnPostBack = true;

            lcStopWatch.Stop(); gcPageLoad.Text = lcStopWatch.ElapsedMilliseconds.ToString();
        }
Ejemplo n.º 8
0
        private void SetRewardLabels(string apanSteamId)
        {
            try 
            {
                //Set medals labels
                tcMySqlCommand lcMySqlCommand = new tcMySqlCommand("SELECT timebomb,painkillers,soccerball,stats_readout,moonboots,strange_mojo,slowmo,burningfeet,cloak,fastmo,custom_title,psychic_anti_gravity,boots_of_height FROM kzs_medals WHERE player = (SELECT id FROM kzs_players WHERE auth = ?steamid);");
                lcMySqlCommand.mcMySqlCommand.Parameters.Add("?steamid", apanSteamId);
                MySqlDataReader lcMySqlReader = lcMySqlCommand.mcMySqlCommand.ExecuteReader();
                lcMySqlReader.Read();

                Panel4.Controls.Add(new LiteralControl("<br><br>"));
                tcLabel lcHeading = new tcLabel();
                lcHeading.Text = "Rewards purchased";
                lcHeading.ForeColor = teColors.eeRedText;
                lcHeading.Font.Bold = true;
                Panel4.Controls.Add(lcHeading);
                Panel4.Controls.Add(new LiteralControl("<br><div style=\"line-height:56px;\"><table>"));

                for (int lnRewardIndex = 0; lnRewardIndex < (int)teRewards.eeMax; lnRewardIndex++)
                {
                    System.Web.UI.WebControls.Image lcImage = new System.Web.UI.WebControls.Image();
                    lcImage.ImageAlign = ImageAlign.Middle;
                    lcImage.Height = lcImage.Width = 48;
                    lcImage.ToolTip = ((teRewards)lnRewardIndex).ToString().Substring(2);

                    tcLabel lcRewardName = new tcLabel();

                    switch ((teRewards)lnRewardIndex)
                    {
                        case teRewards.eeTimeBomb:
                            lcImage.ImageUrl = "~/img/rewards/timebomb.png";
                            lcRewardName.Text = "Timebomb";
                            break;
                        case teRewards.eePainKillers:
                            lcImage.ImageUrl = "~/img/rewards/painkillers.png";
                            lcRewardName.Text = "Painkillers";
                            break;
                        case teRewards.eeSoccerBall:
                            lcImage.ImageUrl = "~/img/rewards/soccerball.png";
                            lcRewardName.Text = "Soccer ball";
                            break;
                        case teRewards.eeStatsReadout:
                            lcImage.ImageUrl = "~/img/rewards/stats_readout.png";
                            lcRewardName.Text = "Stats readout";
                            break;
                        case teRewards.eeMoonBoots:
                            lcImage.ImageUrl = "~/img/rewards/moonboots.png";
                            lcRewardName.Text = "Moon boots";
                            break;
                        case teRewards.eeStrangeMojo:
                            lcImage.ImageUrl = "~/img/rewards/strange_mojo.png";
                            lcRewardName.Text = "Strange mojo";
                            break;
                        case teRewards.eeSlowmo:
                            lcImage.ImageUrl = "~/img/rewards/slomo.png";
                            lcRewardName.Text = "Slow-mo";
                            break;
                        case teRewards.eeBurningFeet:
                            lcImage.ImageUrl = "~/img/rewards/burningfeet.png";
                            lcRewardName.Text = "Burning feet";
                            break;
                        case teRewards.eeCloak:
                            lcImage.ImageUrl = "~/img/rewards/cloak.png";
                            lcRewardName.Text = "Cloak";
                            break;
                        case teRewards.eeFastmo:
                            lcImage.ImageUrl = "~/img/rewards/boots_of_speed.png";
                            lcRewardName.Text = "Boots of speed";
                            break;
                        case teRewards.eeCustomTitle:
                            lcImage.ImageUrl = "~/img/rewards/custom_message.png";
                            lcRewardName.Text = "Custom title";
                            break;
                        case teRewards.eePsychicAntiGravity:
                            lcImage.ImageUrl = "~/img/rewards/psychic_anti_gravity.png";
                            lcRewardName.Text = "Psychic anti-gravity";
                            break;
                        case teRewards.eeBootsOfHeight:
                            lcImage.ImageUrl = "~/img/rewards/boots_of_height.png";
                            lcRewardName.Text = "Boots of height";
                            break;
                    }

                    tcLabel lcNumRewards = new tcLabel();
                    lcNumRewards.Text = "&nbsp;" + lcMySqlReader.GetInt32(lnRewardIndex).ToString() + "&nbsp;&nbsp;&nbsp;&nbsp;";

                    if (lnRewardIndex % 2 == 0)
                    {
                        if (lnRewardIndex == 0)
                        {
                            Panel4.Controls.Add(new LiteralControl("<tr>"));
                        }
                        else
                        {
                            Panel4.Controls.Add(new LiteralControl("</tr>"));
                        }
                    }

                    Panel4.Controls.Add(new LiteralControl("<td>"));
                    Panel4.Controls.Add(lcImage);
                    Panel4.Controls.Add(new LiteralControl("</td><td>"));
                    Panel4.Controls.Add(lcRewardName);
                    Panel4.Controls.Add(new LiteralControl("</td><td>"));
                    Panel4.Controls.Add(lcNumRewards);
                    Panel4.Controls.Add(new LiteralControl("</td>"));
                }

                Panel4.Controls.Add(new LiteralControl("</tr></table></div>"));
                lcMySqlCommand.Close();
            }
            catch (Exception e)
            {
                Debug.WriteLine("SetRewardLabels: " + e.Message);
            }
        }
Ejemplo n.º 9
0
        private int GetServerIdFromKey(string apanKey)
        {
            int lnServerId = -1;

            tcMySqlCommand lcMySqlCommand = new tcMySqlCommand(@"SELECT id FROM kzs_servers WHERE auth_key = ?key LIMIT 1;");
            lcMySqlCommand.mcMySqlCommand.Parameters.Add("?key", apanKey);

            MySqlDataReader lcMySqlReader = lcMySqlCommand.mcMySqlCommand.ExecuteReader();
            lcMySqlReader.Read();

            if (lcMySqlReader.HasRows)
            {
                lnServerId = lcMySqlReader.GetInt32(0);
            }

            lcMySqlReader.Close();

            return lnServerId;
        }
Ejemplo n.º 10
0
        private void GetPlayersAndCountries(out int anTotalPlayers, out int anTotalCountries)
        {
            anTotalPlayers = 0;
            anTotalCountries = 0;

            tcMySqlCommand lcMySqlCommand = new tcMySqlCommand(@"SELECT COUNT(DISTINCT(P.id)) AS NumPlayers, COUNT(DISTINCT(P.country)) AS NumCountries FROM kzs_players AS P");
            MySqlDataReader lcMySqlReader = lcMySqlCommand.mcMySqlCommand.ExecuteReader();
            lcMySqlReader.Read();

            if (lcMySqlReader.HasRows)
            {
                anTotalPlayers = lcMySqlReader.GetInt32(0);
                anTotalCountries = lcMySqlReader.GetInt32(1);
            }

            lcMySqlCommand.Close();
        }
Ejemplo n.º 11
0
        private int GetMapIdFromName(string apanMapName)
        {
            int lnMapId = -1;

            tcMySqlCommand lcMySqlCommand = new tcMySqlCommand(@"SELECT id FROM kzs_maps WHERE name = ?map LIMIT 1;");
            lcMySqlCommand.mcMySqlCommand.Parameters.Add("?map", apanMapName);

            MySqlDataReader lcMySqlReader = lcMySqlCommand.mcMySqlCommand.ExecuteReader();
            lcMySqlReader.Read();

            if (lcMySqlReader.HasRows)
            {
                lnMapId = lcMySqlReader.GetInt32(0);
            }

            lcMySqlReader.Close();

            return lnMapId;
        }
Ejemplo n.º 12
0
        private int GetPlayerIdFromAuth(string apanSteamId)
        {
            int lnPlayerId = -1;

            tcMySqlCommand lcMySqlCommand = new tcMySqlCommand(@"SELECT id FROM kzs_players WHERE auth = ?auth LIMIT 1;");
            lcMySqlCommand.mcMySqlCommand.Parameters.Add("?auth", apanSteamId);

            MySqlDataReader lcMySqlReader = lcMySqlCommand.mcMySqlCommand.ExecuteReader();
            lcMySqlReader.Read();

            if (lcMySqlReader.HasRows)
            {
                lnPlayerId = lcMySqlReader.GetInt32(0);
            }

            lcMySqlReader.Close();

            return lnPlayerId;
        }
Ejemplo n.º 13
0
 //TODO: This function should probably be deprecated in favor of prepared statements
 private void MySqlRunNonQuery(string apanQuery)
 {
     try
     {
         tcMySqlCommand lcMySqlCommand = new tcMySqlCommand(apanQuery);
         lcMySqlCommand.mcMySqlCommand.ExecuteNonQuery();
         lcMySqlCommand.Close();
     }
     catch (Exception e)
     {
         Debug.WriteLine("MySqlRunNonQuery error: " + e.Message + ", Query: " + apanQuery);
     }
 }
Ejemplo n.º 14
0
        //Evaluate player's name usage and see if main name in players table should be updated
        private void EvaluatePlayerNameFrequency(int anPlayerId)
        {
            tcMySqlCommand lcMySqlCommand = new tcMySqlCommand(@"SELECT name FROM kzs_names WHERE player = " + anPlayerId + " ORDER BY count DESC LIMIT 1;");

            MySqlDataReader lcMySqlReader = lcMySqlCommand.mcMySqlCommand.ExecuteReader();
            lcMySqlReader.Read();

            if (lcMySqlReader.HasRows)
            {
                string lpanMostFrequentName = lcMySqlReader.GetString(0);
                MySqlRunNonQuery("UPDATE kzs_players SET name='" + lpanMostFrequentName + "' WHERE id=" + anPlayerId + ";");
            }

            lcMySqlReader.Close();
        }
Ejemplo n.º 15
0
        private void SqlAddRecord(string apanKey)
        {
            string lpanSteamId = GetRequestString("auth");
            string lpanMapName = GetRequestString("map");
            string lpanCourseName = GetRequestString("course");
            int lnTeles = GetRequestInt("tele");
            int lnCheckpoints = GetRequestInt("cp");
            int lnJumps = GetRequestInt("jumps");
            int lnFlags = GetRequestInt("flags");
            double lrTime = GetRequestDouble("time");
            int lnTeamCheck = GetRequestInt("teamcheck");
                        
            //Get the course ID and invert state
            int lnPlayerId = GetPlayerIdFromAuth(lpanSteamId);
            int lnMapId = GetMapIdFromName(lpanMapName);
            int lnServerId = GetServerIdFromKey(apanKey);

            //Ensure that the course exists in the database
            MySqlRunNonQuery("INSERT IGNORE INTO kzs_courses (map,name) VALUES(" + lnMapId + ",'" + lpanCourseName + "');");

            //Get course information and then add record and update run counts
            tcMySqlCommand lcMySqlCommand = new tcMySqlCommand(@"SELECT id, invert FROM kzs_courses WHERE name = '"+lpanCourseName+"' AND map = "+lnMapId+";");

            MySqlDataReader lcMySqlReader = lcMySqlCommand.mcMySqlCommand.ExecuteReader();
            lcMySqlReader.Read();

            if (lcMySqlReader.HasRows && lnPlayerId != -1 && lrTime > 0.0)
            {
                int lnCourseId = lcMySqlReader.GetInt32(0);
                int lnInvert = lcMySqlReader.GetInt32(1);

                //Add record if it does not exist, increment run counts
                if (lnTeles == 0 && lnTeamCheck == 0)
                {
                    MySqlRunNonQuery("INSERT IGNORE INTO kzs_records (player,map,course,time,jumps,flags,server,date) VALUES(" + lnPlayerId + "," + lnMapId + "," + lnCourseId + "," + lrTime + "," + lnJumps + "," + lnFlags + "," + lnServerId + ",CURDATE());");

                    MySqlRunNonQuery("UPDATE kzs_courses SET fin = fin + 1 WHERE id = " + lnCourseId + ";");

                    MySqlRunNonQuery("INSERT INTO kzs_runcounts (player,map,course,nocheck,cp) VALUES(" + lnPlayerId + "," + lnMapId + "," + lnCourseId + ",1,0) ON DUPLICATE KEY UPDATE nocheck = nocheck + 1;");
                }
                else
                {
                    MySqlRunNonQuery("INSERT IGNORE INTO kzs_recordscp (player,map,course,time,jumps,cp,tele,flags,server,date) VALUES(" + lnPlayerId + "," + lnMapId + "," + lnCourseId + "," + lrTime + "," + lnJumps + ","+lnCheckpoints+","+lnTeles+"," + lnFlags + "," + lnServerId + ",CURDATE());");

                    MySqlRunNonQuery("UPDATE kzs_courses SET fincp = fincp + 1 WHERE id = " + lnCourseId + ";");

                    MySqlRunNonQuery("INSERT INTO kzs_runcounts (player,map,course,nocheck,cp) VALUES(" + lnPlayerId + "," + lnMapId + "," + lnCourseId + ",0,1) ON DUPLICATE KEY UPDATE cp = cp + 1;");
                }

                //Update record if record already existed
                string lpanQuery = null;
                
                if(lnTeles == 0)
                {
                    lpanQuery = @"INSERT INTO kzs_records (SELECT * FROM kzs_records WHERE player = " + lnPlayerId + " AND course = " + lnCourseId + " AND server = " + lnServerId +
                        " AND time > " + lrTime + " AND flags = " + lnFlags + ") ON DUPLICATE KEY UPDATE time = " + lrTime + ", jumps = " + lnJumps + ", date = CURDATE();";
                }
                else
                {
                    lpanQuery = @"INSERT INTO kzs_recordscp (SELECT * FROM kzs_recordscp WHERE player = " + lnPlayerId + " AND course = " + lnCourseId +
                        " AND server = " + lnServerId + " AND time > " + lrTime + " AND flags = " + lnFlags + ") ON DUPLICATE KEY UPDATE time = " + lrTime + ", jumps = " + lnJumps + ", cp = " + lnCheckpoints + ", tele = " + lnTeles + ", date = CURDATE();";
                }

                if (lnInvert == 1)
                {
                    lpanQuery = lpanQuery.Replace("time >", "time <");
                }

                MySqlRunNonQuery(lpanQuery);
            }

            lcMySqlReader.Close();
        }
Ejemplo n.º 16
0
        private void GetNumMapsAndRuns(out int anNumMaps, out int anNumMapRuns)
        {
            anNumMaps = 0;
            anNumMapRuns = 0;

            tcMySqlCommand lcMySqlCommand = new tcMySqlCommand(@"SELECT COUNT(DISTINCT(M.id)) AS NumMaps, SUM(M.runs) AS SumMapRuns FROM kzs_maps AS M");
            MySqlDataReader lcMySqlReader = lcMySqlCommand.mcMySqlCommand.ExecuteReader();
            lcMySqlReader.Read();

            if (lcMySqlReader.HasRows)
            {
                anNumMaps = lcMySqlReader.GetInt32(0);
                anNumMapRuns = lcMySqlReader.GetInt32(1);
            }

            lcMySqlCommand.Close();
        }
Ejemplo n.º 17
0
        private void SetMiscInfo(string apanSteamId)
        {
            tcMySqlCommand lcMySqlCommand = new tcMySqlCommand(@"SELECT  DATE_FORMAT(date,'%Y-%m-%d') AS Date,IFNULL(country,0), IFNULL(full,'Unknown') AS CountryFull, IFNULL(cp,0) AS RecordsCp, IFNULL(nocheck,0) AS Records, IFNULL(totalwr,0) AS WrTotal, IFNULL(curwr,0) AS WrCurrent FROM

                                                                (SELECT id,date,country FROM kzs_players WHERE auth = ?auth) AS P

                                                                LEFT JOIN (SELECT code,full FROM kzs_countries) AS CNT
                                                                ON CNT.code = P.country

                                                                LEFT JOIN (SELECT player,COUNT(DISTINCT(course))AS nocheck FROM kzs_records GROUP BY player) AS R
                                                                ON R.player = P.id

                                                                LEFT JOIN (SELECT player,COUNT(DISTINCT(course)) AS cp FROM kzs_recordscp GROUP BY player) AS RCP
                                                                ON RCP.player = P.id

                                                                LEFT JOIN (SELECT player, COUNT(*)  AS totalwr FROM kzs_wrs GROUP BY player) AS WRT
                                                                ON WRT.player = P.id

                                                                LEFT JOIN (SELECT player,COUNT(*) AS curwr FROM

                                                                            (SELECT * FROM

                                                                            (SELECT W.player,W.course,W.time,W.date,P.auth, C.invert FROM

                                                                            ((SELECT player, course, time, date FROM kzs_wrs) AS W

                                                                            LEFT JOIN(SELECT id,auth FROM kzs_players) AS P
                                                                            ON P.id = W.player

                                                                            LEFT JOIN (SELECT invert,id FROM kzs_courses) AS C
                                                                            ON C.id = W.course)

                                                                            ORDER BY course, date, CASE 1 WHEN C.invert THEN Time ELSE -Time END DESC) AS F

                                                                            GROUP BY course) AS FF WHERE auth = ?auth) AS WRCUR
                                                                ON WRCUR.player = P.id");

            lcMySqlCommand.mcMySqlCommand.Parameters.Add("?auth", apanSteamId);
            
            MySqlDataReader lcReader = lcMySqlCommand.mcMySqlCommand.ExecuteReader();
            lcReader.Read();
            
            string lpanStartDate = lcReader.GetString(0);
            string lpanCountryCode = lcReader.GetString(1);
            string lpanCountryFull = lcReader.GetString(2);
            int lnRecCp = lcReader.GetInt32(3);
            int lnRec = lcReader.GetInt32(4);
            int lnWrTotal = lcReader.GetInt32(5);
            int lnWrcur = lcReader.GetInt32(6);
            
            lcReader.Close(); lcMySqlCommand.Close();

            tcLabel lcDate = new tcLabel();
            tcLabel lcCountry = new tcLabel();
            tcLabel lcRecords = new tcLabel();
            tcLabel lcWr = new tcLabel();

            tcLabel lcHeading = new tcLabel();
            lcHeading.Text = "General information";
            lcHeading.ForeColor = teColors.eeRedText;
            lcHeading.Font.Bold = true;
            Panel4.Controls.Add(lcHeading);
            Panel4.Controls.Add(new LiteralControl("<br>"));

            lcDate.Text = "Playing since " + lpanStartDate + " from ";
            Panel4.Controls.Add(lcDate);
            System.Web.UI.WebControls.Image lcImage = new System.Web.UI.WebControls.Image();
            lcImage.ImageUrl = "~/img/flags/" + lpanCountryCode + ".gif";
            Panel4.Controls.Add(lcImage);
            lcCountry.Text = " " + lpanCountryFull;
            Panel4.Controls.Add(lcCountry);

            Panel4.Controls.Add(new LiteralControl("<br>"));
            lcRecords.Text = "Nochecked " + lnRec + " courses, finished " + lnRecCp + " courses with checkpoints";
            Panel4.Controls.Add(lcRecords);

            Panel4.Controls.Add(new LiteralControl("<br>"));
            lcWr.Text = "Held " + lnWrTotal + " total world records (" + lnWrcur + " current)";
            Panel4.Controls.Add(lcWr);
        }
Ejemplo n.º 18
0
        private void GetCourseFinishes(out int anFinCourseNocheck, out int anFindCourseCheck)
        {
            anFinCourseNocheck = 0;
            anFindCourseCheck = 0;

            tcMySqlCommand lcMySqlCommand = new tcMySqlCommand(@"SELECT SUM(C.fin) AS SumFin, SUM(C.fincp) AS SumFinCp FROM kzs_courses AS C");
            MySqlDataReader lcMySqlReader = lcMySqlCommand.mcMySqlCommand.ExecuteReader();
            lcMySqlReader.Read();

            if (lcMySqlReader.HasRows)
            {
                anFinCourseNocheck = lcMySqlReader.GetInt32(0);
                anFindCourseCheck = lcMySqlReader.GetInt32(1);
            }

            lcMySqlCommand.Close();
        }
Ejemplo n.º 19
0
        private void SetUpDropDown(string apanSteamId)
        {
            string lpanNumNocheck = "";
            string lpanNumCheck = "";
            string lpanNumWr = "";
            string lpanNumUnfinNocheck = "";
            string lpanNumUnfinCp = "";
            int lnNumWr = 0;

            tcMySqlCommand lcMySqlCommand = new tcMySqlCommand(@"SELECT IFNULL(R.nocheck,0),IFNULL(RCP.cp,0),IFNULL(WR.wr,0),IFNULL(C.total,0) FROM

                                                                (SELECT id FROM kzs_players WHERE auth = ?steamid) AS P

                                                                LEFT JOIN (SELECT player,COUNT(DISTINCT(course))AS nocheck FROM kzs_records GROUP BY player) AS R
                                                                ON R.player = P.id

                                                                LEFT JOIN (SELECT player,COUNT(DISTINCT(course)) AS cp FROM kzs_recordscp GROUP BY player) AS RCP
                                                                ON RCP.player = P.id

                                                                LEFT JOIN (SELECT player, COUNT(*)  AS wr FROM kzs_wrs GROUP BY player) AS WR
                                                                ON WR.player = P.id

                                                                LEFT JOIN (SELECT COUNT(DISTINCT(id)) AS total FROM kzs_courses) AS C
                                                                ON C.total");

            lcMySqlCommand.mcMySqlCommand.Parameters.Add("?steamid", apanSteamId);
                
            MySqlDataReader lcReader = lcMySqlCommand.mcMySqlCommand.ExecuteReader();
            lcReader.Read();

            if (lcReader.HasRows == true)
            {
                lpanNumNocheck = " (" + lcReader.GetInt32(0) + ")";
                lpanNumCheck = " (" + lcReader.GetInt32(1) + ")";

                lnNumWr = lcReader.GetInt32(2);
                lpanNumWr = " (" + lnNumWr + ")";
                lpanNumUnfinNocheck = " (" + (lcReader.GetInt32(3) - lcReader.GetInt32(0)) + ")";
                lpanNumUnfinCp = " (" + (lcReader.GetInt32(3) - lcReader.GetInt32(1)) + ")";
            }

            lcMySqlCommand.Close();

            gcDropDown.AutoPostBack = true;
            gcDropDown.SelectedIndexChanged += new EventHandler(cb_DropDownTextChange);

            /*
            gcDropDown.Items.Add(new ListItem("Nocheck records" + lpanNumNocheck, "nocheck"));
            gcDropDown.Items.Add(new ListItem("Checkpoint records" + lpanNumCheck, "cp"));

            if (lnNumWr > 0)
            {
                gcDropDown.Items.Add(new ListItem("World records" + lpanNumWr, "wr"));
            }

            gcDropDown.Items.Add(new ListItem("Tag stats", "tag"));
            gcDropDown.Items.Add(new ListItem("Player stats", "stats"));
            gcDropDown.Items.Add(new ListItem("Unfinished nocheck" + lpanNumUnfinNocheck, "unfinnocheck"));
            gcDropDown.Items.Add(new ListItem("Unfinished checkpoint" + lpanNumUnfinCp, "unfincp"));
            */

            //TODO: add links for ie
            List<string> lcTextList = new List<string>();
            List<string> lcKeywordList = new List<string>();

            lcTextList.Add("Nocheck records" + lpanNumNocheck); lcKeywordList.Add("nocheck");
            lcTextList.Add("Checkpoint records" + lpanNumCheck); lcKeywordList.Add("cp");
            if (lnNumWr > 0)
            {
                lcTextList.Add("World records" + lpanNumWr); lcKeywordList.Add("wr");
            }
            lcTextList.Add("Tag stats"); lcKeywordList.Add("tag");
            lcTextList.Add("Player stats"); lcKeywordList.Add("stats");
            lcTextList.Add("Unfinished nocheck" + lpanNumUnfinNocheck); lcKeywordList.Add("unfinnocheck");
            lcTextList.Add("Unfinished checkpoint" + lpanNumUnfinCp); lcKeywordList.Add("unfincp");

            string[] lacText = lcTextList.ToArray();
            string[] lacKeyword = lcKeywordList.ToArray();

            //Add options to dropdown
            for (int i = 0; i < lacText.Length; i++)
            {
                gcDropDown.Items.Add(new ListItem(lacText[i], lacKeyword[i]));
            }

            string lpanSel = Request.QueryString["sel"];

            if (HttpContext.Current.Request.UserAgent.Contains("Chrome") == false && HttpContext.Current.Request.UserAgent.Contains("Firefox") == false)
            {
                gcDropDown.Visible = false;

                Panel3.Height = 425;
                Panel3.ScrollBars = ScrollBars.Vertical;

                if (lpanSel == null)
                {
                    lpanSel = lacKeyword[0];
                }
            }

            if (lpanSel != null)
            {
                gcDropDown.SelectedValue = lpanSel;

                Panel3.Controls.Remove(gcDropDown);

                for (int i = 0; i < lacText.Length; i++)
                {
                    HyperLink lcLink = new HyperLink();
                    lcLink.Text = lacText[i];
                    lcLink.NavigateUrl = "~/player.aspx?id=" + apanSteamId + "&sel=" + lacKeyword[i];
                    lcLink.Font.Name = "Arial";
                    lcLink.Font.Size = 11;
                    lcLink.Font.Bold = true;
                    lcLink.ForeColor = teColors.eeLink;
                    gcLinks.Controls.Add(lcLink);

                    if (i + 1 < lacText.Length && i != 3)
                    {
                        gcLinks.Controls.Add(new LiteralControl("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"));
                    }
                    else if(i == 3)
                    {
                        gcLinks.Controls.Add(new LiteralControl("<br>"));
                    }
                    else
                    {
                        gcLinks.Controls.Add(new LiteralControl("<br><br>"));
                    }
                }
            }
        }
Ejemplo n.º 20
0
        private void ProcessTagPage(string apanSteamId)
        {
            int lnTags = 0;
            int lnTagsNinja = 0;
            int lnTagged = 0;
            int lnRoudWins = 0;
            int lnRoundsPlayed = 0;
            int lnMatchWins = 0;
            int lnTotalUntaggedTime = 0;
            int lnRoundMostUntagged = 0;
            int lnRoundLeastUntagged = 0;
            int lnRoundMostPowerups = 0;
            int lnRoundLeastPowerups = 0;
            float lrAvgRoundPowerup = 0f;
            float lrAvgRoundTag = 0f;
            float lrAvgRoundTagged = 0f;

            tcMySqlCommand lcMySqlCommand = new tcMySqlCommand(@"SELECT tags, ninja, tagged, round_wins, rounds_played, match_wins, total_untagged_time, round_most_untagged, round_least_untagged, round_most_powerup, round_least_powerup, avg_powerup_per_round, avg_tags_per_round, avg_tagged_per_round FROM
                                                                (SELECT id FROM kzs_players WHERE auth = ?auth) AS P
                                                                LEFT JOIN (SELECT * FROM kzs_tag) AS T
                                                                ON P.id = T.player");

            lcMySqlCommand.mcMySqlCommand.Parameters.Add("?auth", apanSteamId);

            MySqlDataReader lcMySqlReader = lcMySqlCommand.mcMySqlCommand.ExecuteReader();
            lcMySqlReader.Read();

            if (lcMySqlReader.HasRows)
            {
                lnTags = lcMySqlReader.GetInt32(0);
                lnTagsNinja = lcMySqlReader.GetInt32(1);
                lnTagged = lcMySqlReader.GetInt32(2);
                lnRoudWins = lcMySqlReader.GetInt32(3);
                lnRoundsPlayed = lcMySqlReader.GetInt32(4);
                lnMatchWins = lcMySqlReader.GetInt32(5);
                lnTotalUntaggedTime = lcMySqlReader.GetInt32(6);
                lnRoundMostUntagged = lcMySqlReader.GetInt32(7);
                lnRoundLeastUntagged = lcMySqlReader.GetInt32(8);
                lnRoundMostPowerups = lcMySqlReader.GetInt32(9);
                lnRoundLeastPowerups = lcMySqlReader.GetInt32(10);
                lrAvgRoundPowerup = lcMySqlReader.GetFloat(11);
                lrAvgRoundTag = lcMySqlReader.GetFloat(12);
                lrAvgRoundTagged = lcMySqlReader.GetFloat(13);
            }

            float lrWinPercentage = 0f;
            String lpanLeastPowerups = "~";
            String lpanLeastUntagged = "~";

            if (lnRoundsPlayed > 0)
            {
                lrWinPercentage = (lnRoudWins / (float)lnRoundsPlayed) * 100f;
            }
            if (lnRoundLeastUntagged < 9000)
            {
                lpanLeastUntagged = lnRoundLeastUntagged.ToString();
            }
            if (lnRoundLeastPowerups < 9000)
            {
                lpanLeastPowerups = lnRoundLeastPowerups.ToString();
            }

            tcLabel lcHeading = new tcLabel();
            tcLabel lcText = new tcLabel();
            lcHeading.ForeColor = teColors.eeRedText;
            lcHeading.Font.Bold = true;

            lcHeading.Text = "<br>General stats<br>";
            lcText.Text = @"Tags: " + lnTags + " (" + lnTagsNinja + " Ninja)" + ", Tagged: " + lnTagged +
                            "<br>Rounds played: " + lnRoundsPlayed + ", round wins: " + lnRoudWins + " (" + String.Format("{0:0.##}", lrWinPercentage) + "%)" +
                            "<br>Match wins: " + lnMatchWins +
                            "<br>Total untagged time: " + lnTotalUntaggedTime + "<br><br>";

            Panel4.Controls.Add(lcHeading);
            Panel4.Controls.Add(lcText);

            tcLabel lcRoundHeading = new tcLabel();
            tcLabel lcRoundText = new tcLabel();
            lcRoundHeading.ForeColor = teColors.eeRedText;
            lcRoundHeading.Font.Bold = true;

            lcRoundHeading.Text = "Round records<br>";
            lcRoundText.Text = @"Most untagged time: " + lnRoundMostUntagged + 
                            "<br>Least untagged time: " + lpanLeastUntagged + 
                            "<br>Most powerups: " + lnRoundMostPowerups +
                            "<br>Fewest powerups: " + lpanLeastPowerups + "<br><br>";

            Panel4.Controls.Add(lcRoundHeading);
            Panel4.Controls.Add(lcRoundText);

            tcLabel lcAvgHeading = new tcLabel();
            tcLabel lcAvgText = new tcLabel();
            lcAvgHeading.ForeColor = teColors.eeRedText;
            lcAvgHeading.Font.Bold = true;
            lcAvgHeading.Text = "Round averages<br>";

            lcAvgText.Text = "Tags: " + String.Format("{0:0.##}", lrAvgRoundTag) +
                            "<br>Tagged: " + String.Format("{0:0.##}", lrAvgRoundTagged) +
                            "<br>Powerups: " + String.Format("{0:0.##}", lrAvgRoundPowerup);

            Panel4.Controls.Add(lcAvgHeading);
            Panel4.Controls.Add(lcAvgText);

            lcMySqlCommand.Close();
        }
Ejemplo n.º 21
0
        private Label GetWrLabel(int anCourseId)
        {
            Label lcReturn = new Label();

            string lpanPlayer = "";
            string lpanTime = "";
            string lpanDate = "";

            tcMySqlCommand lcMySqlCommand = new tcMySqlCommand(@"SELECT WR.time,P.name,DATE_FORMAT(WR.date,'%Y-%m-%d') AS Date FROM

                                                                (SELECT player,course,time,date FROM kzs_wrs WHERE course = ?courseid) AS WR

                                                                LEFT JOIN (SELECT name,id FROM kzs_players) AS P
                                                                ON P.id = WR.player

                                                                LEFT JOIN (SELECT id,invert FROM kzs_courses) AS C
                                                                ON C.id = WR.course

                                                                ORDER BY Date DESC, CASE 1 WHEN C.invert THEN Time ELSE -Time END  DESC LIMIT 1");

            lcMySqlCommand.mcMySqlCommand.Parameters.Add("?courseid", anCourseId.ToString());

            MySqlDataReader lcMySqlReader = lcMySqlCommand.mcMySqlCommand.ExecuteReader();
            lcMySqlReader.Read();

            if(lcMySqlReader.HasRows)
            {
                lpanTime = StaticMethods.TimeToString(lcMySqlReader.GetFloat(0));
                lpanPlayer = lcMySqlReader.GetString(1);
                lpanDate = lcMySqlReader.GetString(2);
            }

            lcMySqlCommand.Close();

            lcReturn.Font.Name = "Arial";
            lcReturn.Font.Bold = true;
            lcReturn.ForeColor = teColors.eeText;
            lcReturn.Font.Size = 11;

            if (lpanDate != "" && lpanPlayer != "" && lpanTime != "")
            {
                if (lpanPlayer.Length > 18)
                {
                    lcReturn.ToolTip = lpanPlayer;
                    lpanPlayer = lpanPlayer.Substring(0, 17);
                }

                lcReturn.Text = "(World record " + lpanTime + " by " + lpanPlayer + " on " + lpanDate + ")";
            }

            return lcReturn;
        }
Ejemplo n.º 22
0
        private void SetAliases(string apanSteamId)
        {
            int lnCount = 0;
            tcLabel lcAliasesLabel = new tcLabel();
            lcAliasesLabel.Text = "Aliases: ";

            tcMySqlCommand lcMySqlCommand = new tcMySqlCommand(@"SELECT name FROM kzs_names WHERE player = (SELECT id FROM kzs_players WHERE auth = ?auth LIMIT 1) ORDER BY count DESC LIMIT 5");

            lcMySqlCommand.mcMySqlCommand.Parameters.Add("?auth", apanSteamId);
                
            MySqlDataReader lcReader = lcMySqlCommand.mcMySqlCommand.ExecuteReader();

            while (lnCount < 5 && lcReader.HasRows && !lcReader.IsClosed && lcReader.Read())
            {
                lcAliasesLabel.Text = lcAliasesLabel.Text + lcReader.GetString(0) + ", ";

                lnCount++;
            }

            lcAliasesLabel.Text = lcAliasesLabel.Text.Substring(0, lcAliasesLabel.Text.Length - 2);

            Panel4.Controls.Add(new LiteralControl("<br>"));
            Panel4.Controls.Add(lcAliasesLabel);

            lcReader.Close();
            lcMySqlCommand.Close();
        }
Ejemplo n.º 23
0
        private void GetTagStatRollup(out int anTags, out int anNinjaTags, out int anTagged, out int anRoundsPlayed, out int anRoundWins, out int anTotalUntaggedTimeSec)
        {
            anTags = 0; anNinjaTags = 0; anTagged = 0; anRoundsPlayed = 0; anRoundWins = 0; anTotalUntaggedTimeSec = 0;
            tcMySqlCommand lcMySqlCommand = new tcMySqlCommand(@"SELECT SUM(tags), SUM(ninja), SUM(tagged), SUM(rounds_played), SUM(round_wins), SUM(total_untagged_time) FROM kzs_tag");
            MySqlDataReader lcMySqlReader = lcMySqlCommand.mcMySqlCommand.ExecuteReader();
            lcMySqlReader.Read();

            if (lcMySqlReader.HasRows)
            {
                anTags = lcMySqlReader.GetInt32(0);
                anNinjaTags = lcMySqlReader.GetInt32(1);
                anTagged = lcMySqlReader.GetInt32(2);
                anRoundsPlayed = lcMySqlReader.GetInt32(3);
                anRoundWins = lcMySqlReader.GetInt32(4);
                anTotalUntaggedTimeSec = lcMySqlReader.GetInt32(5);
            }

            lcMySqlCommand.Close();
        }
Ejemplo n.º 24
0
        private void SetNameLabel(string apanSteamId)
        {
            try
            {
                //Set name label
                tcMySqlCommand lcMySqlCommand = new tcMySqlCommand("SELECT name FROM kzs_players WHERE auth = ?steamid LIMIT 1;");
                lcMySqlCommand.mcMySqlCommand.Parameters.Add("?steamid", apanSteamId);

                MySqlDataReader lcMySqlReader = lcMySqlCommand.mcMySqlCommand.ExecuteReader();
                lcMySqlReader.Read();
                gcLabelName.Text = lcMySqlReader.GetString(0);

                lcMySqlCommand.Close();
            }
            catch (Exception e)
            {
                Debug.WriteLine("SetPageLabels: " + e.Message);
            }
        }
Ejemplo n.º 25
0
        private void GetRewards(out int anTimebomb, out int anPainkillers, out int anSoccerball, out int anStatsReadout, out int anMoonboots, out int anStrangeMojo, out int anSlomo, out int anBurningFeet, out int anCloack, out int anFastmo, out int anTitle, out int anAntiGrav, out int anBootsOfHeight)
        {
            anTimebomb = 0; anPainkillers = 0; anSoccerball = 0; anStatsReadout = 0; anMoonboots = 0; anStrangeMojo = 0; anSlomo = 0; anBurningFeet = 0; anCloack = 0; anFastmo = 0; anTitle = 0; anAntiGrav = 0; anBootsOfHeight = 0;

            tcMySqlCommand lcMySqlCommand = new tcMySqlCommand(@"SELECT SUM(timebomb) AS Timebomb, SUM(painkillers) AS Painkillers, SUM(soccerball) AS Soccerball, SUM(stats_readout) AS StatsReadout, SUM(moonboots) AS Moonboots,  SUM(strange_mojo) AS StrangeMojo, SUM(slowmo) AS Slomo,  SUM(burningfeet) AS Burningfeet, SUM(cloak) AS Cloak, SUM(fastmo) AS Fastmo, SUM(custom_title) AS Title, SUM(psychic_anti_gravity) AS AntiGrav, SUM(boots_of_height) AS BootsOfHeight FROM kzs_medals");
            MySqlDataReader lcMySqlReader = lcMySqlCommand.mcMySqlCommand.ExecuteReader();
            lcMySqlReader.Read();

            if (lcMySqlReader.HasRows)
            {
                anTimebomb      = lcMySqlReader.GetInt32(0);
                anPainkillers   = lcMySqlReader.GetInt32(1); 
                anSoccerball    = lcMySqlReader.GetInt32(2);
                anStatsReadout  = lcMySqlReader.GetInt32(3); 
                anMoonboots     = lcMySqlReader.GetInt32(4);
                anStrangeMojo   = lcMySqlReader.GetInt32(5);
                anSlomo         = lcMySqlReader.GetInt32(6);
                anBurningFeet   = lcMySqlReader.GetInt32(7);
                anCloack        = lcMySqlReader.GetInt32(8);
                anFastmo        = lcMySqlReader.GetInt32(9);
                anTitle         = lcMySqlReader.GetInt32(10);
                anAntiGrav      = lcMySqlReader.GetInt32(11);
                anBootsOfHeight = lcMySqlReader.GetInt32(12); 
            }

            lcMySqlCommand.Close();
        }
Ejemplo n.º 26
0
        private void SetMedalLabels(string apanSteamId)
        {
            try 
            {
                //Set medals labels
                tcMySqlCommand lcMySqlCommand = new tcMySqlCommand("SELECT bronze,silver,gold,platinum FROM kzs_medals WHERE player = (SELECT id FROM kzs_players WHERE auth = ?steamid);");
                lcMySqlCommand.mcMySqlCommand.Parameters.Add("?steamid", apanSteamId);
                MySqlDataReader lcMySqlReader = lcMySqlCommand.mcMySqlCommand.ExecuteReader();
                lcMySqlReader.Read();

                Panel4.Controls.Add(new LiteralControl("<br>"));
                tcLabel lcHeading = new tcLabel();
                lcHeading.Text = "Medals earned";
                lcHeading.ForeColor = teColors.eeRedText;
                lcHeading.Font.Bold = true;
                Panel4.Controls.Add(lcHeading);
                Panel4.Controls.Add(new LiteralControl("<br>"));

                for (int lnMedalIndex = 0; lnMedalIndex < (int)teMedals.eeMax; lnMedalIndex++)
                {
                    System.Web.UI.WebControls.Image lcImage = new System.Web.UI.WebControls.Image();
                    lcImage.ImageAlign = ImageAlign.TextTop;
                    lcImage.Height = lcImage.Width = 16;
                    lcImage.ToolTip = ((teMedals)lnMedalIndex).ToString().Substring(2);

                    switch ((teMedals)lnMedalIndex)
                    {
                        case teMedals.eeBronze:
                            lcImage.ImageUrl = "~/img/medals/bronze.png";
                            break;
                        case teMedals.eeSilver:
                            lcImage.ImageUrl = "~/img/medals/silver.png";
                            break;
                        case teMedals.eeGold:
                            lcImage.ImageUrl = "~/img/medals/gold.png";
                            break;
                        case teMedals.eePlatinum:
                            lcImage.ImageUrl = "~/img/medals/platinum.png";
                            break;
                    }

                    Label lcNumMedals = new Label();
                    lcNumMedals.Text = "&nbsp;" + lcMySqlReader.GetInt32(lnMedalIndex).ToString() + "&nbsp;&nbsp;&nbsp;&nbsp;";
                    lcNumMedals.Font.Size = 12;
                    lcNumMedals.Font.Name = "Arial";
                    lcNumMedals.ForeColor = teColors.eeText;
                    
                    Panel4.Controls.Add(lcImage);
                    Panel4.Controls.Add(lcNumMedals);
                }

                lcMySqlCommand.Close();
            }
            catch (Exception e)
            {
                Debug.WriteLine("SetMedalLabels: " + e.Message);
            }
        }
Ejemplo n.º 27
0
        private void GetMedalCounts(out int anBronzeCount, out int anSilverCount, out int anGoldCount, out int anPlatCount)
        {
            anBronzeCount = 0;
            anSilverCount = 0;
            anGoldCount = 0;
            anPlatCount = 0;

            tcMySqlCommand lcMySqlCommand = new tcMySqlCommand(@"SELECT SUM(bronze) AS Bronze, SUM(silver) AS Silver, SUM(gold) AS Gold, SUM(platinum) AS Plat FROM kzs_medals");
            MySqlDataReader lcMySqlReader = lcMySqlCommand.mcMySqlCommand.ExecuteReader();
            lcMySqlReader.Read();

            if (lcMySqlReader.HasRows)
            {
                anBronzeCount = lcMySqlReader.GetInt32(0);
                anSilverCount = lcMySqlReader.GetInt32(1);
                anGoldCount = lcMySqlReader.GetInt32(2);
                anPlatCount = lcMySqlReader.GetInt32(3);
            }

            lcMySqlCommand.Close();
        }