示例#1
0
 private void btnLogin_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrWhiteSpace(txtUserID.Text) || string.IsNullOrWhiteSpace(txtPassword.Text))
     {
         MessageBox.Show("Please ensure all fields are filled!");
     }
     else
     {
         using (var context = new Session5Entities())
         {
             var findUser = (from x in context.Users
                             where x.userId == txtUserID.Text
                             select x).FirstOrDefault();
             if (findUser == null)
             {
                 MessageBox.Show("User not found!");
             }
             else if (findUser.passwd != txtPassword.Text)
             {
                 MessageBox.Show("Password wrong!");
             }
             else
             {
                 MessageBox.Show("Welcome!");
                 Hide();
                 (new AdminMainMenu()).ShowDialog();
                 Close();
             }
         }
     }
 }
示例#2
0
        private void btnConfirm_Click(object sender, EventArgs e)
        {
            using (var context = new Session5Entities())
            {
                var getSkill = (from x in context.Skills
                                where x.skillName == cbSkill.SelectedItem.ToString()
                                select x).FirstOrDefault();
                foreach (DataGridViewRow row in dataGridView1.Rows)
                {
                    foreach (DataGridViewColumn cell in dataGridView1.Columns)
                    {
                        if (dataGridView1[cell.Index, row.Index].Style.BackColor == Color.Blue)
                        {
                            var seat          = int.Parse(dataGridView1[cell.Index, row.Index].Value.ToString().Split('\n')[0]);
                            var competitorID  = dataGridView1[cell.Index, row.Index].Value.ToString().Split('\n')[1];
                            var getCompetitor = (from x in context.Competitors
                                                 where x.skillIdFK == getSkill.skillId && x.competitorId == competitorID
                                                 select x).FirstOrDefault();
                            getCompetitor.assignedSeat = seat;
                        }
                    }
                }

                foreach (var item in lbUnassigned.Items)
                {
                    var getCompetitor = (from x in context.Competitors
                                         where x.skillIdFK == getSkill.skillId && item.ToString().Contains(x.competitorName + ", " + x.competitorCountry)
                                         select x).FirstOrDefault();
                    getCompetitor.assignedSeat = 0;
                }
                context.SaveChanges();
                MessageBox.Show("Completed seat assignment!");
            }
        }
示例#3
0
 private void LoadSkills()
 {
     cbSkill.Items.Clear();
     using (var context = new Session5Entities())
     {
         var getSkills = (from x in context.Skills
                          select x.skillName).ToArray();
         cbSkill.Items.AddRange(getSkills);
     }
 }
示例#4
0
 private void cbSkill_SelectedIndexChanged(object sender, EventArgs e)
 {
     cbCompetitors.Items.Clear();
     using (var context = new Session5Entities())
     {
         var getSkillID = (from x in context.Skills
                           where x.skillName == cbSkill.SelectedItem.ToString()
                           select x.skillId).FirstOrDefault();
         var getCompetitors = (from x in context.Competitors
                               where x.skillIdFK == getSkillID
                               select x.competitorName).ToArray();
         cbCompetitors.Items.AddRange(getCompetitors);
     }
 }
示例#5
0
 private void LoadSkills()
 {
     cbSkill.Items.Clear();
     cbSession.Items.Clear();
     cbCompetitors.Items.Clear();
     dataGridView1.Rows.Clear();
     lblTotalMarks.Text = 0.ToString();
     using (var context = new Session5Entities())
     {
         var getSkills = (from x in context.Skills
                          select x.skillName).ToArray();
         cbSkill.Items.AddRange(getSkills);
     }
 }
示例#6
0
 private void LoadData()
 {
     dataGridView1.Rows.Clear();
     using (var context = new Session5Entities())
     {
         var getSkillID = (from x in context.Skills
                           where x.skillName == cbSkill.SelectedItem.ToString()
                           select x.skillId).FirstOrDefault();
         var getSession = (from x in context.Competitions
                           where x.sessionNo.ToString() == cbSession.SelectedItem.ToString() && x.skillIdFK == getSkillID
                           select x).FirstOrDefault();
         if (getSession.q1MaxMarks != 0)
         {
             var newRow = new List <string>()
             {
                 "Question 1", "", getSession.q1MaxMarks.ToString(), "0"
             };
             dataGridView1.Rows.Add(newRow.ToArray());
         }
         if (getSession.q2MaxMarks != 0)
         {
             var newRow = new List <string>()
             {
                 "Question 2", "", getSession.q2MaxMarks.ToString(), "0"
             };
             dataGridView1.Rows.Add(newRow.ToArray());
         }
         if (getSession.q3MaxMarks != 0)
         {
             var newRow = new List <string>()
             {
                 "Question 3", "", getSession.q3MaxMarks.ToString(), "0"
             };
             dataGridView1.Rows.Add(newRow.ToArray());
         }
         if (getSession.q4MaxMarks != 0)
         {
             var newRow = new List <string>()
             {
                 "Question 4", "", getSession.q4MaxMarks.ToString(), "0"
             };
             dataGridView1.Rows.Add(newRow.ToArray());
         }
     }
 }
示例#7
0
 private void cbSkill_SelectedIndexChanged(object sender, EventArgs e)
 {
     dataGridView1.Rows.Clear();
     cbSession.Items.Clear();
     cbCompetitors.Items.Clear();
     lblTotalMarks.Text = 0.ToString();
     using (var context = new Session5Entities())
     {
         var getSkillID = (from x in context.Skills
                           where x.skillName == cbSkill.SelectedItem.ToString()
                           select x.skillId).FirstOrDefault();
         var getSessions = (from x in context.Competitions
                            where x.skillIdFK == getSkillID
                            select x.sessionNo);
         foreach (var item in getSessions)
         {
             cbSession.Items.Add(item);
         }
     }
 }
示例#8
0
 private void dataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
 {
     using (var context = new Session5Entities())
     {
         if (dataGridView1[e.ColumnIndex, e.RowIndex].Style.BackColor == Color.Blue)
         {
             var getSkill = (from x in context.Skills
                             where x.skillName == cbSkill.SelectedItem.ToString()
                             select x).FirstOrDefault();
             var ID    = dataGridView1[e.ColumnIndex, e.RowIndex].Value.ToString().Split('\n')[1];
             var getID = (from x in context.Competitors
                          where x.skillIdFK == getSkill.skillId && x.competitorId == ID
                          select x).FirstOrDefault();
             if (getID != null)
             {
                 dataGridView1[e.ColumnIndex, e.RowIndex].ToolTipText = $"{getID.competitorName}, {getID.competitorCountry}";
             }
         }
     }
 }
示例#9
0
        private void LoadData()
        {
            dataGridView1.Rows.Clear();
            btnGold.Visible   = false;
            btnSilver.Visible = false;
            btnBronze.Visible = false;
            pbGold1.Image     = null;
            pbGold2.Image     = null;
            pbSilver1.Image   = null;
            pbSilver2.Image   = null;
            pbBronze1.Image   = null;
            pbBronze2.Image   = null;
            moreGold.Clear();
            moreGoldResults.Clear();
            moreSilver.Clear();
            moreSilverResults.Clear();
            moreBronze.Clear();
            moreBronzeResults.Clear();
            lblCompletedSessions.Text = 0.ToString();
            lblTotalSession.Text      = 0.ToString();
            using (var context = new Session5Entities())
            {
                var getSkill = (from x in context.Skills
                                where x.skillName == cbSkill.SelectedItem.ToString()
                                select x).FirstOrDefault();
                var getTotalSessions = (from x in context.Competitions
                                        where x.skillIdFK == getSkill.skillId
                                        select x);
                lblTotalSession.Text = getTotalSessions.Count().ToString();
                var completed  = 0;
                var totalMarks = Convert.ToDouble(getTotalSessions.Sum(x => x.q1MaxMarks + x.q2MaxMarks + x.q3MaxMarks + x.q4MaxMarks));
                foreach (var item in getTotalSessions)
                {
                    var getTotalResults = (from x in context.Results
                                           where x.competitionIdFK == item.competitionId
                                           select x).Count();
                    if (getTotalResults == getSkill.noOfCompetitors)
                    {
                        completed += 1;
                    }
                }
                lblCompletedSessions.Text = completed.ToString();

                var getResults = (from x in context.Results
                                  where x.Competition.skillIdFK == getSkill.skillId
                                  group x by x.Competitor.competitorName into y
                                  orderby y.Key
                                  orderby y.Sum(x => x.totalMarks) descending
                                  select y);
                foreach (var item in getResults)
                {
                    var newRow = new List <string>()
                    {
                        item.Key,
                        context.Competitors.Where(x => x.competitorName == item.Key && x.skillIdFK == getSkill.skillId).Select(x => x.competitorCountry).FirstOrDefault(),
                        item.Sum(x => x.totalMarks).ToString()
                    };
                    dataGridView1.Rows.Add(newRow.ToArray());
                }
                foreach (DataGridViewRow item in dataGridView1.Rows)
                {
                    if (Convert.ToDouble(dataGridView1[2, item.Index].Value) > 0.8 * totalMarks)
                    {
                        if (moreGoldResults.Count == 0)
                        {
                            pbGold1.Image = ReturnFlag(dataGridView1[1, item.Index].Value.ToString());
                            moreGold.Add(dataGridView1[1, item.Index].Value.ToString());
                            moreGoldResults.Add(Convert.ToDouble(dataGridView1[2, item.Index].Value));
                        }
                        else if (moreGoldResults.Count > 0 && moreGoldResults[0] - Convert.ToDouble(dataGridView1[2, item.Index].Value) <= moreGoldResults.Count * 2)
                        {
                            if (moreGoldResults.Count == 1)
                            {
                                pbGold2.Image = ReturnFlag(dataGridView1[1, item.Index].Value.ToString());
                                moreGold.Add(dataGridView1[1, item.Index].Value.ToString());
                                moreGoldResults.Add(Convert.ToDouble(dataGridView1[2, item.Index].Value));
                            }
                            else
                            {
                                moreGold.Add(dataGridView1[1, item.Index].Value.ToString());
                                moreGoldResults.Add(Convert.ToDouble(dataGridView1[2, item.Index].Value));
                                btnGold.Visible = true;
                            }
                        }
                        else
                        {
                            if (Convert.ToDouble(dataGridView1[2, item.Index].Value) > 0.75 * totalMarks)
                            {
                                if (moreSilverResults.Count == 0)
                                {
                                    pbSilver1.Image = ReturnFlag(dataGridView1[1, item.Index].Value.ToString());
                                    moreSilver.Add(dataGridView1[1, item.Index].Value.ToString());
                                    moreSilverResults.Add(Convert.ToDouble(dataGridView1[2, item.Index].Value));
                                }
                                else if (moreSilverResults.Count > 0 && moreSilverResults[0] - Convert.ToDouble(dataGridView1[2, item.Index].Value) <= moreGoldResults.Count * 2)
                                {
                                    if (moreSilverResults.Count == 1)
                                    {
                                        pbSilver2.Image = ReturnFlag(dataGridView1[1, item.Index].Value.ToString());
                                        moreSilver.Add(dataGridView1[1, item.Index].Value.ToString());
                                        moreSilverResults.Add(Convert.ToDouble(dataGridView1[2, item.Index].Value));
                                    }
                                    else
                                    {
                                        moreSilver.Add(dataGridView1[1, item.Index].Value.ToString());
                                        moreSilverResults.Add(Convert.ToDouble(dataGridView1[2, item.Index].Value));
                                        btnSilver.Visible = true;
                                    }
                                }
                                else
                                {
                                    if (Convert.ToDouble(dataGridView1[2, item.Index].Value) > 0.71 * totalMarks)
                                    {
                                        if (moreBronzeResults.Count == 0)
                                        {
                                            pbBronze1.Image = ReturnFlag(dataGridView1[1, item.Index].Value.ToString());
                                            moreBronze.Add(dataGridView1[1, item.Index].Value.ToString());
                                            moreBronzeResults.Add(Convert.ToDouble(dataGridView1[2, item.Index].Value));
                                        }
                                        else if (moreBronzeResults.Count > 0 && moreBronzeResults[0] - Convert.ToDouble(dataGridView1[2, item.Index].Value) <= moreGoldResults.Count * 2)
                                        {
                                            if (moreBronzeResults.Count == 1)
                                            {
                                                pbBronze2.Image = ReturnFlag(dataGridView1[1, item.Index].Value.ToString());
                                                moreBronze.Add(dataGridView1[1, item.Index].Value.ToString());
                                                moreBronzeResults.Add(Convert.ToDouble(dataGridView1[2, item.Index].Value));
                                            }
                                            else
                                            {
                                                moreBronze.Add(dataGridView1[1, item.Index].Value.ToString());
                                                moreBronzeResults.Add(Convert.ToDouble(dataGridView1[2, item.Index].Value));
                                                btnBronze.Visible = true;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }

                    else if (Convert.ToDouble(dataGridView1[2, item.Index].Value) > 0.75 * totalMarks)
                    {
                        if (moreSilverResults.Count == 0)
                        {
                            pbSilver1.Image = ReturnFlag(dataGridView1[1, item.Index].Value.ToString());
                            moreSilver.Add(dataGridView1[1, item.Index].Value.ToString());
                            moreSilverResults.Add(Convert.ToDouble(dataGridView1[2, item.Index].Value));
                        }
                        else if (moreSilverResults.Count > 0 && moreSilverResults[0] - Convert.ToDouble(dataGridView1[2, item.Index].Value) <= moreGoldResults.Count * 2)
                        {
                            if (moreSilverResults.Count == 1)
                            {
                                pbSilver2.Image = ReturnFlag(dataGridView1[1, item.Index].Value.ToString());
                                moreSilver.Add(dataGridView1[1, item.Index].Value.ToString());
                                moreSilverResults.Add(Convert.ToDouble(dataGridView1[2, item.Index].Value));
                            }
                            else
                            {
                                moreSilver.Add(dataGridView1[1, item.Index].Value.ToString());
                                moreSilverResults.Add(Convert.ToDouble(dataGridView1[2, item.Index].Value));
                                btnSilver.Visible = true;
                            }
                        }
                        else
                        {
                            if (Convert.ToDouble(dataGridView1[2, item.Index].Value) > 0.71 * totalMarks)
                            {
                                if (moreBronzeResults.Count == 0)
                                {
                                    pbBronze1.Image = ReturnFlag(dataGridView1[1, item.Index].Value.ToString());
                                    moreBronze.Add(dataGridView1[1, item.Index].Value.ToString());
                                    moreBronzeResults.Add(Convert.ToDouble(dataGridView1[2, item.Index].Value));
                                }
                                else if (moreBronzeResults.Count > 0 && moreBronzeResults[0] - Convert.ToDouble(dataGridView1[2, item.Index].Value) <= moreGoldResults.Count * 2)
                                {
                                    if (moreBronzeResults.Count == 1)
                                    {
                                        pbBronze2.Image = ReturnFlag(dataGridView1[1, item.Index].Value.ToString());
                                        moreBronze.Add(dataGridView1[1, item.Index].Value.ToString());
                                        moreBronzeResults.Add(Convert.ToDouble(dataGridView1[2, item.Index].Value));
                                    }
                                    else
                                    {
                                        moreBronze.Add(dataGridView1[1, item.Index].Value.ToString());
                                        moreBronzeResults.Add(Convert.ToDouble(dataGridView1[2, item.Index].Value));
                                        btnBronze.Visible = true;
                                    }
                                }
                            }
                        }
                    }
                    else if (Convert.ToDouble(dataGridView1[2, item.Index].Value) > 0.71 * totalMarks)
                    {
                        if (moreBronzeResults.Count == 0)
                        {
                            pbBronze1.Image = ReturnFlag(dataGridView1[1, item.Index].Value.ToString());
                            moreBronze.Add(dataGridView1[1, item.Index].Value.ToString());
                            moreBronzeResults.Add(Convert.ToDouble(dataGridView1[2, item.Index].Value));
                        }
                        else if (moreBronzeResults.Count > 0 && moreBronzeResults[0] - Convert.ToDouble(dataGridView1[2, item.Index].Value) <= moreGoldResults.Count * 2)
                        {
                            if (moreBronzeResults.Count == 1)
                            {
                                pbBronze2.Image = ReturnFlag(dataGridView1[1, item.Index].Value.ToString());
                                moreBronze.Add(dataGridView1[1, item.Index].Value.ToString());
                                moreBronzeResults.Add(Convert.ToDouble(dataGridView1[2, item.Index].Value));
                            }
                            else
                            {
                                moreBronze.Add(dataGridView1[1, item.Index].Value.ToString());
                                moreBronzeResults.Add(Convert.ToDouble(dataGridView1[2, item.Index].Value));
                                btnBronze.Visible = true;
                            }
                        }
                    }
                }
            }
        }
示例#10
0
        private void cbCompetitors_SelectedIndexChanged(object sender, EventArgs e)
        {
            dataGridView1.Rows.Clear();
            using (var context = new Session5Entities())
            {
                var getSkill = (from x in context.Skills
                                where x.skillName == cbSkill.SelectedItem.ToString()
                                select x).FirstOrDefault();
                var getCompetitons = (from x in context.Competitions
                                      where x.skillIdFK == getSkill.skillId
                                      select x);
                var bonus = 0;
                foreach (var item in getCompetitons)
                {
                    var getCompetitorResult = (from x in context.Results
                                               where x.Competitor.skillIdFK == getSkill.skillId && x.Competitor.competitorName == cbCompetitors.SelectedItem.ToString()
                                               where x.competitionIdFK == item.competitionId
                                               select x).FirstOrDefault();
                    double totalMark = item.q1MaxMarks + item.q2MaxMarks + item.q3MaxMarks + item.q4MaxMarks;
                    double q1Worth   = (item.q1MaxMarks / totalMark) * 100;
                    double q2Worth   = (item.q2MaxMarks / totalMark) * 100;
                    double q3Worth   = (item.q3MaxMarks / totalMark) * 100;
                    double q4Worth   = (item.q4MaxMarks / totalMark) * 100;

                    if (getCompetitorResult == null)
                    {
                        var newRow = new List <string>()
                        {
                            $"Session {item.sessionNo} (Total Marks = {0}/{totalMark})"
                        };
                        dataGridView1.Rows.Add(newRow.ToArray());
                        if (item.q1MaxMarks != 0)
                        {
                            var questionRow = new List <string>()
                            {
                                "Question 1", 0.ToString(),
                                item.q1MaxMarks.ToString(), 0.ToString()
                            };
                            dataGridView1.Rows.Add(questionRow.ToArray());
                        }
                        if (item.q2MaxMarks != 0)
                        {
                            var questionRow = new List <string>()
                            {
                                "Question 2", 0.ToString(),
                                item.q2MaxMarks.ToString(), 0.ToString()
                            };
                            dataGridView1.Rows.Add(questionRow.ToArray());
                        }
                        if (item.q3MaxMarks != 0)
                        {
                            var questionRow = new List <string>()
                            {
                                "Question 3", 0.ToString(),
                                item.q3MaxMarks.ToString(), 0.ToString()
                            };
                            dataGridView1.Rows.Add(questionRow.ToArray());
                        }
                        if (item.q4MaxMarks != 0)
                        {
                            var questionRow = new List <string>()
                            {
                                "Question 4", 0.ToString(),
                                item.q4MaxMarks.ToString(), 0.ToString()
                            };
                            dataGridView1.Rows.Add(questionRow.ToArray());
                        }
                    }
                    else
                    {
                        var newRow = new List <string>()
                        {
                            $"Session {item.sessionNo} (Total Marks = {getCompetitorResult.totalMarks}/{totalMark})"
                        };
                        dataGridView1.Rows.Add(newRow.ToArray());
                        if (item.q1MaxMarks != 0)
                        {
                            var questionRow = new List <string>()
                            {
                                "Question 1", getCompetitorResult.q1Marks.ToString(),
                                item.q1MaxMarks.ToString(),
                                Math.Round(getCompetitorResult.q1Marks / item.q1MaxMarks * q1Worth, 2).ToString()
                            };
                            dataGridView1.Rows.Add(questionRow.ToArray());
                        }
                        if (item.q2MaxMarks != 0)
                        {
                            var questionRow = new List <string>()
                            {
                                "Question 2", getCompetitorResult.q2Marks.ToString(),
                                item.q2MaxMarks.ToString(),
                                Math.Round(getCompetitorResult.q2Marks / item.q2MaxMarks * q2Worth, 2).ToString()
                            };
                            dataGridView1.Rows.Add(questionRow.ToArray());
                        }
                        if (item.q3MaxMarks != 0)
                        {
                            var questionRow = new List <string>()
                            {
                                "Question 3", getCompetitorResult.q3Marks.ToString(),
                                item.q3MaxMarks.ToString(),
                                Math.Round(getCompetitorResult.q3Marks / item.q3MaxMarks * q3Worth, 2).ToString()
                            };
                            dataGridView1.Rows.Add(questionRow.ToArray());
                        }
                        if (item.q4MaxMarks != 0)
                        {
                            var questionRow = new List <string>()
                            {
                                "Question 4", getCompetitorResult.q4Marks.ToString(),
                                item.q4MaxMarks.ToString(),
                                Math.Round(getCompetitorResult.q4Marks / item.q4MaxMarks * q4Worth, 2).ToString()
                            };
                            dataGridView1.Rows.Add(questionRow.ToArray());
                        }
                        if (getCompetitorResult.totalMarks > totalMark * 0.75)
                        {
                            bonus += 5;
                        }
                    }
                }
                var getTotalCompetitorMarks = (from x in context.Results
                                               where x.Competitor.skillIdFK == getSkill.skillId && x.Competitor.competitorName == cbCompetitors.SelectedItem.ToString()
                                               select x.totalMarks).ToList().Sum();
                var medianMark = getSkill.expectedMedianMark * context.Competitions.Where(x => x.skillIdFK == getSkill.skillId).Count();
                if (getTotalCompetitorMarks > medianMark)
                {
                    bonus += 10;
                }
                var totalAmount = 0.0;
                foreach (DataGridViewRow item in dataGridView1.Rows)
                {
                    totalAmount += Convert.ToDouble(dataGridView1[3, item.Index].Value);
                }
                lblAmount.Text = (totalAmount + bonus).ToString();
                lblBonus.Text  = bonus.ToString();
            }
        }
示例#11
0
        private void btnSubmit_Click(object sender, EventArgs e)
        {
            using (var context = new Session5Entities())
            {
                var getSkillID = (from x in context.Skills
                                  where x.skillName == cbSkill.SelectedItem.ToString()
                                  select x.skillId).FirstOrDefault();
                var getSession = (from x in context.Competitions
                                  where x.sessionNo.ToString() == cbSession.SelectedItem.ToString() && x.skillIdFK == getSkillID
                                  select x).FirstOrDefault();
                var getCompetitor = (from x in context.Competitors
                                     where x.competitorName == cbCompetitors.SelectedItem.ToString() && x.skillIdFK == getSkillID
                                     select x.recordsId).FirstOrDefault();
                var findResults = (from x in context.Results
                                   where x.recordsIdFK == getCompetitor && x.competitionIdFK == getSession.competitionId
                                   select x).FirstOrDefault();
                if (findResults != null)
                {
                    foreach (DataGridViewRow item in dataGridView1.Rows)
                    {
                        if (dataGridView1[0, item.Index].Value.ToString() == "Question 1")
                        {
                            findResults.q1Marks = Convert.ToDouble(dataGridView1[3, item.Index].Value);
                        }
                        else if (dataGridView1[0, item.Index].Value.ToString() == "Question 2")
                        {
                            findResults.q2Marks = Convert.ToDouble(dataGridView1[3, item.Index].Value);
                        }
                        else if (dataGridView1[0, item.Index].Value.ToString() == "Question 3")
                        {
                            findResults.q3Marks = Convert.ToDouble(dataGridView1[3, item.Index].Value);
                        }
                        else
                        {
                            findResults.q4Marks = Convert.ToDouble(dataGridView1[3, item.Index].Value);
                        }
                        findResults.totalMarks = double.Parse(lblTotalMarks.Text);
                    }
                }
                else
                {
                    var newResults = new Result();
                    newResults.competitionIdFK = getSession.competitionId;
                    newResults.recordsIdFK     = getCompetitor;
                    newResults.totalMarks      = double.Parse(lblTotalMarks.Text);

                    if (getSession.q2MaxMarks == 0)
                    {
                        newResults.q1Marks = Convert.ToDouble(dataGridView1[3, 0].Value);
                        newResults.q2Marks = 0;
                        newResults.q3Marks = 0;
                        newResults.q4Marks = 0;
                    }
                    else if (getSession.q3MaxMarks == 0)
                    {
                        newResults.q1Marks = Convert.ToDouble(dataGridView1[3, 0].Value);
                        newResults.q2Marks = Convert.ToDouble(dataGridView1[3, 1].Value);
                        newResults.q3Marks = 0;
                        newResults.q4Marks = 0;
                    }
                    else if (getSession.q4MaxMarks == 0)
                    {
                        newResults.q1Marks = Convert.ToDouble(dataGridView1[3, 0].Value);
                        newResults.q2Marks = Convert.ToDouble(dataGridView1[3, 1].Value);
                        newResults.q3Marks = Convert.ToDouble(dataGridView1[3, 2].Value);
                        newResults.q4Marks = 0;
                    }
                    else
                    {
                        newResults.q1Marks = Convert.ToDouble(dataGridView1[3, 0].Value);
                        newResults.q2Marks = Convert.ToDouble(dataGridView1[3, 1].Value);
                        newResults.q3Marks = Convert.ToDouble(dataGridView1[3, 2].Value);
                        newResults.q4Marks = Convert.ToDouble(dataGridView1[3, 3].Value);
                    }
                    context.Results.Add(newResults);
                }
                context.SaveChanges();
                MessageBox.Show("Results saved!");
                btnClear_Click(null, null);
            }
        }
示例#12
0
        private bool random()
        {
            var unassignedSeats = new List <string>();
            var listToRemove    = new List <string>();

            foreach (DataGridViewRow row in dataGridView1.Rows)
            {
                foreach (DataGridViewColumn cell in dataGridView1.Columns)
                {
                    if (dataGridView1[cell.Index, row.Index].Style.BackColor != Color.Blue)
                    {
                        unassignedSeats.Add(dataGridView1[cell.Index, row.Index].Value.ToString());
                    }
                }
            }
            var rand = new Random();

            if (lbUnassigned.Items.Count > unassignedSeats.Count)
            {
                MessageBox.Show("Illegal amount of competitors!");
                return(true);
            }
            else
            {
                using (var context = new Session5Entities())
                {
                    var getSkill = (from x in context.Skills
                                    where x.skillName == cbSkill.SelectedItem.ToString()
                                    select x).FirstOrDefault();
                    foreach (var item in lbUnassigned.Items)
                    {
                        var randIndex   = rand.Next(0, unassignedSeats.Count - 1);
                        var getSeat     = unassignedSeats[randIndex];
                        var getToAssign = (from x in context.Competitors
                                           where item.ToString().Contains(x.competitorName + ", " + x.competitorCountry) && x.skillIdFK == getSkill.skillId
                                           select x).FirstOrDefault();
                        foreach (DataGridViewRow row in dataGridView1.Rows)
                        {
                            foreach (DataGridViewColumn cell in dataGridView1.Columns)
                            {
                                var boolCheck = true;
                                if (dataGridView1[cell.Index, row.Index].Value.ToString() == getSeat)
                                {
                                    if (row.Index == dataGridView1.RowCount - 1)
                                    {
                                        var getAbove        = dataGridView1[cell.Index, row.Index - 1].Value.ToString();
                                        var getAboveCountry = (from x in context.Competitors
                                                               where x.skillIdFK == getSkill.skillId && getAbove.Contains(x.competitorId)
                                                               select x.competitorCountry).FirstOrDefault();
                                        if (getAboveCountry == getToAssign.competitorCountry)
                                        {
                                            boolCheck = false;
                                        }
                                    }
                                    else if (row.Index == 0)
                                    {
                                        var getBelow        = dataGridView1[cell.Index, row.Index + 1].Value.ToString();
                                        var getBelowCountry = (from x in context.Competitors
                                                               where x.skillIdFK == getSkill.skillId && getBelow.Contains(x.competitorId)
                                                               select x.competitorCountry).FirstOrDefault();
                                        if (getBelowCountry == getToAssign.competitorCountry)
                                        {
                                            boolCheck = false;
                                        }
                                    }
                                    else
                                    {
                                        var getAbove        = dataGridView1[cell.Index, row.Index - 1].Value.ToString();
                                        var getBelow        = dataGridView1[cell.Index, row.Index + 1].Value.ToString();
                                        var getAboveCountry = (from x in context.Competitors
                                                               where x.skillIdFK == getSkill.skillId && getAbove.Contains(x.competitorId)
                                                               select x.competitorCountry).FirstOrDefault();
                                        var getBelowCountry = (from x in context.Competitors
                                                               where x.skillIdFK == getSkill.skillId && getBelow.Contains(x.competitorId)
                                                               select x.competitorCountry).FirstOrDefault();
                                        if (getAboveCountry == getToAssign.competitorCountry || getBelowCountry == getToAssign.competitorCountry)
                                        {
                                            boolCheck = false;
                                        }
                                    }
                                    if (boolCheck)
                                    {
                                        var sb = new StringBuilder(getSeat);
                                        sb.Append($"\n{getToAssign.competitorId}");
                                        dataGridView1[cell.Index, row.Index].Value = sb.ToString();
                                        listToRemove.Add(item.ToString());
                                        unassignedSeats.Remove(getSeat);
                                        dataGridView1[cell.Index, row.Index].Style.BackColor = Color.Blue;
                                        dataGridView1[cell.Index, row.Index].Style.ForeColor = Color.White;
                                        lblAssigned.Text   = (int.Parse(lblAssigned.Text) + 1).ToString();
                                        lblUnassigned.Text = (int.Parse(lblUnassigned.Text) - 1).ToString();
                                    }
                                }
                            }
                        }
                    }
                }
            }
            foreach (var item in listToRemove)
            {
                lbUnassigned.Items.Remove(item);
            }
            if (lbUnassigned.Items.Count == 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#13
0
 private void cbSkill_SelectedIndexChanged(object sender, EventArgs e)
 {
     lbUnassigned.Items.Clear();
     lblAssigned.Text   = 0.ToString();
     lblUnassigned.Text = 0.ToString();
     dataGridView1.Rows.Clear();
     using (var context = new Session5Entities())
     {
         var getSkill = (from x in context.Skills
                         where x.skillName == cbSkill.SelectedItem.ToString()
                         select x).FirstOrDefault();
         var c1 = 1;
         var c2 = 2;
         if (getSkill.noOfCompetitors % 2 == 0)
         {
             for (int i = 0; i < getSkill.noOfCompetitors / 2; i++)
             {
                 var newRow = new List <string>()
                 {
                     c1.ToString(), c2.ToString()
                 };
                 dataGridView1.Rows.Add(newRow.ToArray());
                 c1 += 2;
                 c2 += 2;
             }
         }
         else
         {
             for (int i = 0; i < (getSkill.noOfCompetitors + 1) / 2; i++)
             {
                 if (i == ((getSkill.noOfCompetitors + 1) / 2) - 1)
                 {
                     var newRow = new List <string>()
                     {
                         c1.ToString(), ""
                     };
                     dataGridView1.Rows.Add(newRow.ToArray());
                 }
                 else
                 {
                     var newRow = new List <string>()
                     {
                         c1.ToString(), c2.ToString()
                     };
                     dataGridView1.Rows.Add(newRow.ToArray());
                     c1 += 2;
                     c2 += 2;
                 }
             }
         }
         var getUCompetitors = (from x in context.Competitors
                                where x.assignedSeat == 0 && x.skillIdFK == getSkill.skillId
                                select x);
         var getACompetitors = (from x in context.Competitors
                                where x.assignedSeat != 0 && x.skillIdFK == getSkill.skillId
                                select x);
         lblUnassigned.Text = getUCompetitors.Count().ToString();
         foreach (var item in getUCompetitors)
         {
             lbUnassigned.Items.Add($"{item.competitorName}, {item.competitorCountry}");
         }
         lblAssigned.Text = getACompetitors.Count().ToString();
         foreach (var item in getACompetitors)
         {
             var boolCheck = false;
             foreach (DataGridViewRow row in dataGridView1.Rows)
             {
                 foreach (DataGridViewColumn cell in dataGridView1.Columns)
                 {
                     if (dataGridView1[cell.Index, row.Index].Value.ToString() == item.assignedSeat.ToString())
                     {
                         var sb = new StringBuilder(dataGridView1[cell.Index, row.Index].Value.ToString());
                         sb.Append($"\n{item.competitorId}");
                         dataGridView1[cell.Index, row.Index].Value           = sb.ToString();
                         dataGridView1[cell.Index, row.Index].Style.BackColor = Color.Blue;
                         dataGridView1[cell.Index, row.Index].Style.ForeColor = Color.White;
                         boolCheck = true;
                     }
                     if (boolCheck)
                     {
                         break;
                     }
                 }
                 if (boolCheck)
                 {
                     break;
                 }
             }
         }
     }
 }
示例#14
0
 private void btnSwap_Click(object sender, EventArgs e)
 {
     if (dataGridView1.SelectedCells.Count != 2)
     {
         MessageBox.Show("Please select 2 seats to swap!");
     }
     else
     {
         var checkSeats = true;
         foreach (DataGridViewCell item in dataGridView1.SelectedCells)
         {
             if (item.Style.BackColor != Color.Blue)
             {
                 checkSeats = false;
             }
         }
         if (checkSeats)
         {
             var pos = new Dictionary <DataGridViewCell, string>();
             foreach (DataGridViewCell item in dataGridView1.SelectedCells)
             {
                 pos.Add(item, item.Value.ToString().Split('\n')[1]);
             }
             var competitor2ID = pos.ElementAt(1).Value;
             var competitor1ID = pos.ElementAt(0).Value;
             using (var context = new Session5Entities())
             {
                 var getSkill = (from x in context.Skills
                                 where x.skillName == cbSkill.SelectedItem.ToString()
                                 select x).FirstOrDefault();
                 var check2NewRowIndex = pos.ElementAt(0).Key.RowIndex;
                 var check1NewRowIndex = pos.ElementAt(1).Key.RowIndex;
                 var get2Country       = (from x in context.Competitors
                                          where x.competitorId == competitor2ID && x.skillIdFK == getSkill.skillId
                                          select x.competitorCountry).FirstOrDefault();
                 var get1Country = (from x in context.Competitors
                                    where x.competitorId == competitor1ID && x.skillIdFK == getSkill.skillId
                                    select x.competitorCountry).FirstOrDefault();
                 var boolCheck = true;
                 if (check2NewRowIndex == dataGridView1.RowCount - 1)
                 {
                     var getAbove        = dataGridView1[pos.ElementAt(0).Key.ColumnIndex, check2NewRowIndex - 1].Value.ToString();
                     var getAboveCountry = (from x in context.Competitors
                                            where x.skillIdFK == getSkill.skillId && getAbove.Contains(x.competitorId)
                                            select x.competitorCountry).FirstOrDefault();
                     if (getAboveCountry == get2Country)
                     {
                         boolCheck = false;
                     }
                 }
                 else if (check2NewRowIndex == 0)
                 {
                     var getBelow        = dataGridView1[pos.ElementAt(0).Key.ColumnIndex, check2NewRowIndex + 1].Value.ToString();
                     var getBelowCountry = (from x in context.Competitors
                                            where x.skillIdFK == getSkill.skillId && getBelow.Contains(x.competitorId)
                                            select x.competitorCountry).FirstOrDefault();
                     if (getBelowCountry == get2Country)
                     {
                         boolCheck = false;
                     }
                 }
                 else
                 {
                     var getAbove        = dataGridView1[pos.ElementAt(0).Key.ColumnIndex, check2NewRowIndex - 1].Value.ToString();
                     var getBelow        = dataGridView1[pos.ElementAt(0).Key.ColumnIndex, check2NewRowIndex + 1].Value.ToString();
                     var getAboveCountry = (from x in context.Competitors
                                            where x.skillIdFK == getSkill.skillId && getAbove.Contains(x.competitorId)
                                            select x.competitorCountry).FirstOrDefault();
                     var getBelowCountry = (from x in context.Competitors
                                            where x.skillIdFK == getSkill.skillId && getBelow.Contains(x.competitorId)
                                            select x.competitorCountry).FirstOrDefault();
                     if (getAboveCountry == get2Country || getBelowCountry == get2Country)
                     {
                         boolCheck = false;
                     }
                 }
                 if (check1NewRowIndex == dataGridView1.RowCount - 1)
                 {
                     var getAbove        = dataGridView1[pos.ElementAt(1).Key.ColumnIndex, check1NewRowIndex - 1].Value.ToString();
                     var getAboveCountry = (from x in context.Competitors
                                            where x.skillIdFK == getSkill.skillId && getAbove.Contains(x.competitorId)
                                            select x.competitorCountry).FirstOrDefault();
                     if (getAboveCountry == get1Country)
                     {
                         boolCheck = false;
                     }
                 }
                 else if (check1NewRowIndex == 0)
                 {
                     var getBelow        = dataGridView1[pos.ElementAt(1).Key.ColumnIndex, check1NewRowIndex + 1].Value.ToString();
                     var getBelowCountry = (from x in context.Competitors
                                            where x.skillIdFK == getSkill.skillId && getBelow.Contains(x.competitorId)
                                            select x.competitorCountry).FirstOrDefault();
                     if (getBelowCountry == get1Country)
                     {
                         boolCheck = false;
                     }
                 }
                 else
                 {
                     var getAbove        = dataGridView1[pos.ElementAt(1).Key.ColumnIndex, check1NewRowIndex - 1].Value.ToString();
                     var getBelow        = dataGridView1[pos.ElementAt(1).Key.ColumnIndex, check1NewRowIndex + 1].Value.ToString();
                     var getAboveCountry = (from x in context.Competitors
                                            where x.skillIdFK == getSkill.skillId && getAbove.Contains(x.competitorId)
                                            select x.competitorCountry).FirstOrDefault();
                     var getBelowCountry = (from x in context.Competitors
                                            where x.skillIdFK == getSkill.skillId && getBelow.Contains(x.competitorId)
                                            select x.competitorCountry).FirstOrDefault();
                     if (getAboveCountry == get1Country || getBelowCountry == get1Country)
                     {
                         boolCheck = false;
                     }
                 }
                 if (boolCheck)
                 {
                     var sb1 = new StringBuilder(pos.ElementAt(1).Key.Value.ToString().Split('\n')[0]);
                     var sb2 = new StringBuilder(pos.ElementAt(0).Key.Value.ToString().Split('\n')[0]);
                     sb1.Append($"\n{pos.ElementAt(0).Value}");
                     sb2.Append($"\n{pos.ElementAt(1).Value}");
                     dataGridView1[pos.ElementAt(0).Key.ColumnIndex, pos.ElementAt(0).Key.RowIndex].Value = sb2.ToString();
                     dataGridView1[pos.ElementAt(1).Key.ColumnIndex, pos.ElementAt(1).Key.RowIndex].Value = sb1.ToString();
                 }
                 else
                 {
                     MessageBox.Show("Unable to swap seats as one of the competitors will be in front or behind of one of their country's competitor!");
                 }
             }
         }
         else
         {
             MessageBox.Show("Seats must first be occupied before swap!");
         }
     }
 }
示例#15
0
 private void btnManual_Click(object sender, EventArgs e)
 {
     if (dataGridView1.CurrentCell == null || lbUnassigned.SelectedItem == null)
     {
         MessageBox.Show("Please select a seat and a competitor!");
     }
     else
     {
         if (dataGridView1.CurrentCell.Value.ToString() == "")
         {
             MessageBox.Show("Unable to assign to a non-existent seat!");
         }
         else if (dataGridView1.CurrentCell.Style.BackColor == Color.Blue)
         {
             var getCurrentID  = dataGridView1.CurrentCell.Value.ToString().Split('\n')[1];
             var getSeatNumber = int.Parse(dataGridView1.CurrentCell.Value.ToString().Split('\n')[0]);
             using (var context = new Session5Entities())
             {
                 var getSkill = (from x in context.Skills
                                 where x.skillName == cbSkill.SelectedItem.ToString()
                                 select x).FirstOrDefault();
                 var getAssigned = (from x in context.Competitors
                                    where x.competitorId == getCurrentID && x.skillIdFK == getSkill.skillId
                                    select x).FirstOrDefault();
                 var getToAssign = (from x in context.Competitors
                                    where lbUnassigned.SelectedItem.ToString().Contains(x.competitorName + ", " + x.competitorCountry) && x.skillIdFK == getSkill.skillId
                                    select x).FirstOrDefault();
                 var rowIndex  = dataGridView1.CurrentCell.RowIndex;
                 var boolCheck = true;
                 if (rowIndex == dataGridView1.RowCount - 1)
                 {
                     var getAbove        = dataGridView1[dataGridView1.CurrentCell.ColumnIndex, rowIndex - 1].Value.ToString();
                     var getAboveCountry = (from x in context.Competitors
                                            where x.skillIdFK == getSkill.skillId && getAbove.Contains(x.competitorId)
                                            select x.competitorCountry).FirstOrDefault();
                     if (getAboveCountry == getToAssign.competitorCountry)
                     {
                         boolCheck = false;
                     }
                 }
                 else if (rowIndex == 0)
                 {
                     var getBelow        = dataGridView1[dataGridView1.CurrentCell.ColumnIndex, rowIndex + 1].Value.ToString();
                     var getBelowCountry = (from x in context.Competitors
                                            where x.skillIdFK == getSkill.skillId && getBelow.Contains(x.competitorId)
                                            select x.competitorCountry).FirstOrDefault();
                     if (getBelowCountry == getToAssign.competitorCountry)
                     {
                         boolCheck = false;
                     }
                 }
                 else
                 {
                     var getAbove        = dataGridView1[dataGridView1.CurrentCell.ColumnIndex, rowIndex - 1].Value.ToString();
                     var getBelow        = dataGridView1[dataGridView1.CurrentCell.ColumnIndex, rowIndex + 1].Value.ToString();
                     var getAboveCountry = (from x in context.Competitors
                                            where x.skillIdFK == getSkill.skillId && getAbove.Contains(x.competitorId)
                                            select x.competitorCountry).FirstOrDefault();
                     var getBelowCountry = (from x in context.Competitors
                                            where x.skillIdFK == getSkill.skillId && getBelow.Contains(x.competitorId)
                                            select x.competitorCountry).FirstOrDefault();
                     if (getAboveCountry == getToAssign.competitorCountry || getBelowCountry == getToAssign.competitorCountry)
                     {
                         boolCheck = false;
                     }
                 }
                 if (boolCheck)
                 {
                     var sb = new StringBuilder(getSeatNumber.ToString());
                     sb.Append($"\n{getToAssign.competitorId}");
                     dataGridView1.CurrentCell.Value = sb.ToString();
                     lbUnassigned.Items.Add($"{getAssigned.competitorName}, {getAssigned.competitorCountry}");
                     lbUnassigned.Items.Remove(lbUnassigned.SelectedItem);
                 }
                 else
                 {
                     MessageBox.Show("Unable to assign seat as front and/or back has a competitor of the same country!");
                 }
             }
         }
         else
         {
             var getSeatNumber = int.Parse(dataGridView1.CurrentCell.Value.ToString());
             using (var context = new Session5Entities())
             {
                 var getSkill = (from x in context.Skills
                                 where x.skillName == cbSkill.SelectedItem.ToString()
                                 select x).FirstOrDefault();
                 var getToAssign = (from x in context.Competitors
                                    where lbUnassigned.SelectedItem.ToString().Contains(x.competitorName + ", " + x.competitorCountry) && x.skillIdFK == getSkill.skillId
                                    select x).FirstOrDefault();
                 var rowIndex  = dataGridView1.CurrentCell.RowIndex;
                 var boolCheck = true;
                 if (rowIndex == dataGridView1.RowCount - 1)
                 {
                     var getAbove        = dataGridView1[dataGridView1.CurrentCell.ColumnIndex, rowIndex - 1].Value.ToString();
                     var getAboveCountry = (from x in context.Competitors
                                            where x.skillIdFK == getSkill.skillId && getAbove.Contains(x.competitorId)
                                            select x.competitorCountry).FirstOrDefault();
                     if (getAboveCountry == getToAssign.competitorCountry)
                     {
                         boolCheck = false;
                     }
                 }
                 else if (rowIndex == 0)
                 {
                     var getBelow        = dataGridView1[dataGridView1.CurrentCell.ColumnIndex, rowIndex + 1].Value.ToString();
                     var getBelowCountry = (from x in context.Competitors
                                            where x.skillIdFK == getSkill.skillId && getBelow.Contains(x.competitorId)
                                            select x.competitorCountry).FirstOrDefault();
                     if (getBelowCountry == getToAssign.competitorCountry)
                     {
                         boolCheck = false;
                     }
                 }
                 else
                 {
                     var getAbove        = dataGridView1[dataGridView1.CurrentCell.ColumnIndex, rowIndex - 1].Value.ToString();
                     var getBelow        = dataGridView1[dataGridView1.CurrentCell.ColumnIndex, rowIndex + 1].Value.ToString();
                     var getAboveCountry = (from x in context.Competitors
                                            where x.skillIdFK == getSkill.skillId && getAbove.Contains(x.competitorId)
                                            select x.competitorCountry).FirstOrDefault();
                     var getBelowCountry = (from x in context.Competitors
                                            where x.skillIdFK == getSkill.skillId && getBelow.Contains(x.competitorId)
                                            select x.competitorCountry).FirstOrDefault();
                     if (getAboveCountry == getToAssign.competitorCountry || getBelowCountry == getToAssign.competitorCountry)
                     {
                         boolCheck = false;
                     }
                 }
                 if (boolCheck)
                 {
                     var sb = new StringBuilder(getSeatNumber.ToString());
                     sb.Append($"\n{getToAssign.competitorId}");
                     dataGridView1.CurrentCell.Value           = sb.ToString();
                     dataGridView1.CurrentCell.Style.BackColor = Color.Blue;
                     dataGridView1.CurrentCell.Style.ForeColor = Color.White;
                     lbUnassigned.Items.Remove(lbUnassigned.SelectedItem);
                     lblAssigned.Text   = (int.Parse(lblAssigned.Text) + 1).ToString();
                     lblUnassigned.Text = (int.Parse(lblUnassigned.Text) - 1).ToString();
                 }
                 else
                 {
                     MessageBox.Show("Unable to assign seat as front and/or back has a competitor of the same country!");
                 }
             }
         }
     }
 }
示例#16
0
        private void LoadData()
        {
            using (var context = new Session5Entities())
            {
                var getSkill = (from x in context.Skills
                                where x.skillName == cbSkill.SelectedItem.ToString()
                                select x).FirstOrDefault();
                var getBestCountry = (from x in context.Results
                                      where x.Competitor.skillIdFK == getSkill.skillId
                                      group x by x.Competitor.competitorCountry into y
                                      orderby y.Average(x => x.totalMarks) descending
                                      select y).FirstOrDefault();
                if (getBestCountry != null)
                {
                    pbCountry.Image    = ReturnFlag(getBestCountry.Key);
                    lblTotalMarks.Text = getBestCountry.Average(x => x.totalMarks).ToString();
                    var getSessions = (from x in context.Results
                                       where x.Competitor.skillIdFK == getSkill.skillId
                                       group x by x.Competition.sessionNo into y
                                       orderby y.Sum(x => x.totalMarks) descending
                                       select y).ToList();
                    lblEasiest.Text  = $"Session {getSessions.First().Key} ({getSessions.First().Min(x => x.totalMarks)}-{getSessions.First().Max(x => x.totalMarks)})";
                    lblToughest.Text = $"Session {getSessions.Last().Key} ({getSessions.Last().Min(x => x.totalMarks)}-{getSessions.Last().Max(x => x.totalMarks)})";
                    var getAllResults = (from x in context.Results
                                         where x.Competitor.skillIdFK == getSkill.skillId
                                         orderby x.totalMarks
                                         select x.totalMarks).ToList();
                    if (getAllResults.Count() % 2 != 0)
                    {
                        var medianPoint = getAllResults.Count() / 2;
                        lblMedian.Text = getAllResults[medianPoint].ToString();
                        if (getSkill.expectedMedianMark > getAllResults[medianPoint])
                        {
                            pbUp.Visible = false;
                        }
                        else
                        {
                            pbDown.Visible = false;
                        }
                    }
                    else
                    {
                        var medianPoint1 = getAllResults.Count() / 2;
                        var medianPoint2 = (getAllResults.Count() / 2) + 1;
                        var trueMedian   = (getAllResults[medianPoint1] + getAllResults[medianPoint2]) / 2;
                        lblMedian.Text = trueMedian.ToString();
                        if (getSkill.expectedMedianMark > trueMedian)
                        {
                            pbUp.Visible = false;
                        }
                        else
                        {
                            pbDown.Visible = false;
                        }
                    }

                    var getCompetitorsResults = (from x in context.Results
                                                 where x.Competitor.skillIdFK == getSkill.skillId
                                                 group x by x.Competitor.competitorName into y
                                                 select y);
                    var getCompetitions = (from x in context.Competitions
                                           where x.skillIdFK == getSkill.skillId
                                           orderby x.sessionNo
                                           select x);
                    foreach (var competitor in getCompetitorsResults)
                    {
                        chart1.Series.Add(competitor.Key);
                        chart1.Series[competitor.Key].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
                        foreach (var sessions in getCompetitions)
                        {
                            if (competitor.Where(x => x.competitionIdFK == sessions.competitionId).Select(x => x).FirstOrDefault() == null)
                            {
                                var idx = chart1.Series[competitor.Key].Points.AddXY($"Session {sessions.sessionNo}", 0);
                                chart1.Series[competitor.Key].Points[idx].BorderWidth = 3;
                            }
                            else
                            {
                                var idx = chart1.Series[competitor.Key].Points.AddXY($"Session {sessions.sessionNo}", competitor.Where(x => x.competitionIdFK == sessions.competitionId).Select(x => x.totalMarks).FirstOrDefault());
                                chart1.Series[competitor.Key].Points[idx].BorderWidth = 3;
                            }
                        }
                    }
                }
            }
        }