Exemplo n.º 1
0
 public Contest()
 {
     round = new Round();
     competition = new Competition();
     phase = new Phase();
     player = new Player();
     playerList = new List<Player>();
 }
Exemplo n.º 2
0
 //Insert Round
 public bool AddRound(Round Round)
 {
     string query = "INSERT INTO [Round]([Competition_ID],[Round_Name])"
                    + " VALUES ('" + Round.IDCompetition+ "','" + Round.NameRound.Replace("'","''") + "')";
     if (ExistRound(Round) == true)
     {
         return false;
     }
     else
     {
         return DA.InsertDatabase(query);
     }
 }
Exemplo n.º 3
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);
         }
     }
 }
Exemplo n.º 4
0
 //Check Round Exist
 public bool ExistRound(Round Round)
 {
     string query = "SELECT [Round_ID],[Competition_ID],[Round_Name]"
                     + " FROM [Round]";
     DataTable dt = DA.SelectDatabase(query);
     int i = 0;
     if (dt != null)
     {
         foreach (DataRow item in dt.Rows)
         {
             if (item["Round_Name"].ToString().ToUpper() == Round.NameRound.ToUpper() && Convert.ToInt32(item["Competition_ID"])== Round.IDCompetition)
             {
                 i++;
             }
         }
     }
     if (i==0)
     {
         return false;
     }
     else
     {
         return true;
     }
 }
Exemplo n.º 5
0
 //Edit Round
 //public bool EditRoundbyID(Round Round)
 //{
 //    string query = "UPDATE [Round] SET"
 //                 + " [Round_Name] ='" + Round.NameRound.Replace("'","''") + "'"
 //                 + " WHERE [Round_ID] = '" + Round.IDRound + "'";
 //    if (EditExistRound(Round) == true)
 //    {
 //        return false;
 //    }
 //    else
 //    {
 //        return DA.UpdateDatabase(query);
 //    }
 //}
 ////Edit Round exist in Round table
 //public bool EditExistRound(Round Round)
 //{
 //    string query = "SELECT [Round_ID],[Competition_ID],[Round_Name]"
 //                 + " FROM [Round]"
 //                 + " WHERE [Round_Name]= '" + Round.NameRound.ToUpper() + "'"
 //                 + " AND [Competition_ID] = '" + Round.IDCompetition + "'"
 //                 + " AND [Round_ID] <> '" + Round.IDRound + "'";
 //    DataTable dt = DA.SelectDatabase(query);
 //    if (dt != null)
 //    {
 //        return true;
 //    }
 //    else
 //    {
 //        return false;
 //    }
 //}
 //Delete Round
 public bool DeleteRoundbyID(Round Round)
 {
     string query = "DELETE FROM [Round]"
                  + " WHERE [Round_ID] = '" + Round.IDRound + "'";
     return DA.DeleteDatabase(query);
 }
Exemplo n.º 6
0
 //select Round by id Competition
 public List<Round> GetRoundByIDCompetition(Round round)
 {
     List<Round> RoundList = new List<Round>();
     string query = "SELECT [Round_ID],[Competition_ID],[Round_Name]"
                     + " FROM [Round]"
                     + "WHERE [Competition_ID] = '"+round.IDCompetition+"'";
     DataTable dt = DA.SelectDatabase(query);
     if (dt != null)
     {
         foreach (DataRow item in dt.Rows)
         {
             Round Round = new Round();
             Round.IDRound = Convert.ToInt32(item["Round_ID"].ToString());
             Round.IDCompetition = Convert.ToInt32(item["Competition_ID"].ToString());
             Round.NameRound = item["Round_Name"].ToString();
             RoundList.Add(Round);
         }
     }
     return RoundList;
 }
Exemplo n.º 7
0
        //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;
            }
        }