Esempio n. 1
0
 //save competition
 public void saveRound()
 {
     if (txt_NameRound.Text.Trim() == "")
     {
         MessageBox.Show("Vui lòng nhập tên vòng thi.", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     else
     {
         RoundBL RoundBL = new RoundBL();
         Round Round = new Round();
         Round.NameRound = txt_NameRound.Text.Trim();
         Round.IDCompetition = idCompetition;
         if (RoundBL.AddRound(Round) == true)
         {
             this.Close();
         }
         else
         {
             MessageBox.Show("Vòng thi này đã tồn tại trong cuộc thi "+ nameCompetition +".", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
 }
        //Load round
        public void LoadRound()
        {
            RoundBL RoundBL = new RoundBL();
            Round Round = new Round();
            CompetitionBL CompetitionBL = new CompetitionBL();

            List<Competition> ListCompetition;
            ListCompetition = CompetitionBL.GetCompetition();
            if (ListCompetition != null)
            {
                for (int i = 0; i < ListCompetition.Count; i++)
                {
                    if (cmb_Competition.SelectedItem.ToString() == ListCompetition.ElementAt(i).NameCompetition)
                    {
                        Round.IDCompetition = ListCompetition.ElementAt(i).IDCompetition;
                        idCompetition = ListCompetition.ElementAt(i).IDCompetition;
                        nameCompetition = cmb_Competition.SelectedItem.ToString();
                    }
                }
            }
            //load commobox round
            List<Round> ListRound;
            ListRound = RoundBL.GetRoundByIDCompetition(Round);
            if (ListRound != null)
            {
                for (int i = 0; i < ListRound.Count; i++)
                {
                    cmb_Round.Items.Add(ListRound.ElementAt(i).NameRound);
                }
            }
            if (cmb_Round.Items.Count > 0)
            {
                cmb_Round.SelectedIndex = 0;
            }
        }
 //Get Id Round
 public void GetIDround()
 {
     RoundBL RoundBl = new RoundBL();
     List<Round> ListRound;
     ListRound = RoundBl.GetRound();
     if (ListRound != null)
     {
         for (int i = 0; i < ListRound.Count; i++)
         {
             if (cmb_Round.SelectedItem.ToString() == ListRound.ElementAt(i).NameRound && ListRound.ElementAt(i).IDCompetition == idCompetition)
             {
                 idRound = ListRound.ElementAt(i).IDRound;
             }
         }
     }
 }