Esempio n. 1
0
 private void UpdateUI()
 {
     using (var db = new Session5Entities())
     {
         assignedlist.Clear();
         UnassignedList.Clear();
         unassigned_listbox.Items.Clear();
         toolTip1.SetToolTip(seat1, "");
         toolTip2.SetToolTip(seat2, "");
         toolTip3.SetToolTip(seat3, "");
         toolTip4.SetToolTip(seat4, "");
         toolTip5.SetToolTip(seat5, "");
         toolTip6.SetToolTip(seat6, "");
         toolTip7.SetToolTip(seat7, "");
         toolTip8.SetToolTip(seat8, "");
         seat1.Text = "1";
         seat2.Text = "2";
         seat3.Text = "3";
         seat4.Text = "4";
         seat5.Text = "5";
         seat6.Text = "6";
         seat7.Text = "7";
         seat8.Text = "8";
         var selectedskill = skill_combo.SelectedItem.ToString();
         var skillid       = (from s in db.Skills
                              where s.skillName == selectedskill
                              select s.skillId).First();
         var comps = (from c in db.Competitors
                      where c.skillIdFK == skillid
                      select c).ToList();
         foreach (var item in comps)
         {
             unassigned_listbox.Items.Add($"{item.competitorName}, {item.competitorCountry}");
             var c = new Competitors()
             {
                 Country     = item.competitorCountry,
                 CountryAbbr = item.competitorId,
                 ID          = item.recordsId,
                 Name        = item.competitorName,
                 SeatNumber  = 0
             };
             UnassignedList.Add(c);
             Console.WriteLine(c);
         }
         if (comps.Count < 8)
         {
             seat7.Visible = false;
             seat8.Visible = false;
         }
         else
         {
             seat7.Visible = true;
             seat8.Visible = true;
         }
         if (comps.Count < 6)
         {
             seat7.Visible = false;
             seat8.Visible = false;
             seat6.Visible = false;
         }
         else
         {
             seat7.Visible = true;
             seat8.Visible = true;
             seat6.Visible = true;
         }
         assignedcomp_label.Text = assignedlist.Count.ToString();
         unassigned_label.Text   = UnassignedList.Count.ToString();
     }
 }
Esempio n. 2
0
        private bool AssignSeat(int seatnumber, Competitors selected)
        {
            if (seatnumber > 2)
            {
                switch (seatnumber)
                {
                case 3:
                    if (!seat1.Text.Contains(selected.CountryAbbr.Substring(0, 2)))
                    {
                        seat3.Text          = $"3 \n{selected.CountryAbbr}";
                        seat3.BackColor     = Color.LightBlue;
                        selected.SeatNumber = 3;
                        assignedlist.Add(selected);
                        UnassignedList.Remove(selected);
                        unassigned_listbox.Items.Clear();
                        toolTip3.SetToolTip(seat3, $"{selected.Name}, {selected.Country}");
                        foreach (var item in UnassignedList)
                        {
                            unassigned_listbox.Items.Add($"{item.Name}, {item.Country}");
                        }
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                    break;

                case 4:
                    if (!seat2.Text.Contains(selected.CountryAbbr.Substring(0, 2)))
                    {
                        seat4.Text          = $"4 \n{selected.CountryAbbr}";
                        seat4.BackColor     = Color.LightBlue;
                        selected.SeatNumber = 4;
                        assignedlist.Add(selected);
                        UnassignedList.Remove(selected);
                        unassigned_listbox.Items.Clear();
                        toolTip4.SetToolTip(seat4, $"{selected.Name}, {selected.Country}");
                        foreach (var item in UnassignedList)
                        {
                            unassigned_listbox.Items.Add($"{item.Name}, {item.Country}");
                        }
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                    break;

                case 5:
                    if (!seat3.Text.Contains(selected.CountryAbbr.Substring(0, 2)))
                    {
                        seat5.Text          = $"5 \n{selected.CountryAbbr}";
                        seat5.BackColor     = Color.LightBlue;
                        selected.SeatNumber = 5;
                        assignedlist.Add(selected);
                        UnassignedList.Remove(selected);
                        unassigned_listbox.Items.Clear();
                        toolTip5.SetToolTip(seat5, $"{selected.Name}, {selected.Country}");
                        foreach (var item in UnassignedList)
                        {
                            unassigned_listbox.Items.Add($"{item.Name}, {item.Country}");
                        }
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                    break;

                case 6:
                    if (!seat4.Text.Contains(selected.CountryAbbr.Substring(0, 2)))
                    {
                        seat6.Text          = $"6 \n{selected.CountryAbbr}";
                        seat6.BackColor     = Color.LightBlue;
                        selected.SeatNumber = 6;
                        assignedlist.Add(selected);
                        UnassignedList.Remove(selected);
                        unassigned_listbox.Items.Clear();
                        toolTip6.SetToolTip(seat6, $"{selected.Name}, {selected.Country}");
                        foreach (var item in UnassignedList)
                        {
                            unassigned_listbox.Items.Add($"{item.Name}, {item.Country}");
                        }
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                    break;

                case 7:
                    if (!seat5.Text.Contains(selected.CountryAbbr.Substring(0, 2)))
                    {
                        seat7.Text          = $"7 \n{selected.CountryAbbr}";
                        seat7.BackColor     = Color.LightBlue;
                        selected.SeatNumber = 7;
                        assignedlist.Add(selected);
                        UnassignedList.Remove(selected);
                        unassigned_listbox.Items.Clear();
                        toolTip7.SetToolTip(seat7, $"{selected.Name}, {selected.Country}");
                        foreach (var item in UnassignedList)
                        {
                            unassigned_listbox.Items.Add($"{item.Name}, {item.Country}");
                        }
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                    break;

                case 8:
                    if (!seat6.Text.Contains(selected.CountryAbbr.Substring(0, 2)))
                    {
                        seat8.Text          = $"8 \n{selected.CountryAbbr}";
                        seat8.BackColor     = Color.LightBlue;
                        selected.SeatNumber = 8;
                        assignedlist.Add(selected);
                        UnassignedList.Remove(selected);
                        unassigned_listbox.Items.Clear();
                        toolTip8.SetToolTip(seat8, $"{selected.Name}, {selected.Country}");
                        foreach (var item in UnassignedList)
                        {
                            unassigned_listbox.Items.Add($"{item.Name}, {item.Country}");
                        }
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                    break;
                }
            }
            else
            {
                switch (seatnumber)
                {
                case 1:
                    seat1.Text          = $"1 \n{selected.CountryAbbr}";
                    seat1.BackColor     = Color.LightBlue;
                    selected.SeatNumber = 1;
                    assignedlist.Add(selected);
                    UnassignedList.Remove(selected);
                    unassigned_listbox.Items.Clear();
                    toolTip1.SetToolTip(seat1, $"{selected.Name}, {selected.Country}");
                    foreach (var item in UnassignedList)
                    {
                        unassigned_listbox.Items.Add($"{item.Name}, {item.Country}");
                    }
                    break;

                case 2:
                    seat2.Text          = $"2 \n{selected.CountryAbbr}";
                    seat2.BackColor     = Color.LightBlue;
                    selected.SeatNumber = 2;
                    assignedlist.Add(selected);
                    UnassignedList.Remove(selected);
                    unassigned_listbox.Items.Clear();
                    toolTip2.SetToolTip(seat2, $"{selected.Name}, {selected.Country}");
                    foreach (var item in UnassignedList)
                    {
                        unassigned_listbox.Items.Add($"{item.Name}, {item.Country}");
                    }
                    break;
                }
                foreach (var item in UnassignedList)
                {
                    unassigned_listbox.Items.Add($"{item.Name}, {item.Country}");
                }
                return(true);
            }
            return(false);
        }