コード例 #1
0
ファイル: PlayerBL.cs プロジェクト: antang/NewCapstoneProject
 //Check Player Exist
 //public bool ExistPlayer(Player Player)
 //{
 //    string query = "SELECT [Player_ID],[Player_Name]"
 //               + " FROM [Player]"
 //               + " WHERE [Player_Name] = '" + Player.PlayerName.ToUpper() + "'";
 //    DataTable dt = DA.SelectDatabase(query);
 //    if (dt.Rows.Count != 0)
 //    {
 //        return true;
 //    }
 //    else
 //    {
 //        return false;
 //    }
 //}
 //Edit Player
 public bool EditPlayerbyID(Player Player)
 {
     string query = "UPDATE [Player] SET "
                  + "[Contest_ID] ='" + Player.IDContest + "',[Player_Name] ='" + Player.PlayerName + "',[Player_Score] ='" + Player.PlayerScore + "',[Color] ='" + Player.Color + "',[Player_Sequence] ='" + Player.Sequence + "'"
                  + " WHERE Player_ID = '" + Player.IDPlayer + "'";
     return DA.UpdateDatabase(query);
 }
コード例 #2
0
ファイル: Contest.cs プロジェクト: antang/NewCapstoneProject
 public Contest()
 {
     round = new Round();
     competition = new Competition();
     phase = new Phase();
     player = new Player();
     playerList = new List<Player>();
 }
コード例 #3
0
ファイル: PlayerBL.cs プロジェクト: antang/NewCapstoneProject
        //Insert Player
        public bool AddPlayer(Player Player)
        {
            string query = "INSERT INTO [Player]([Contest_ID],[Player_Sequence],[Player_Name],[Player_Score],[Color])"
                           + " VALUES ('" + Player.IDContest + "','" + Player.Sequence + "','" + Player.PlayerName + "',"
                           + "'" + Player.PlayerScore + "','" + Player.Color + "')";

            if (DA.InsertDatabase(query))
            {
                return true;
            }
            else
            {
                return false;
            }
        }
コード例 #4
0
ファイル: PlayerBL.cs プロジェクト: antang/NewCapstoneProject
        //select Player table
        public List<Player> GetPlayer()
        {
            List<Player> PlayerList = new List<Player>();
            string query = "SELECT [Player_ID],[Contest_ID],[Player_Name],[Player_Score],[Color],[Player_Sequence]"
                        +  " FROM [Player]";
            DataTable dt = DA.SelectDatabase(query);
            //int i = 1;
            if (dt!= null)
            {
                foreach (DataRow item in dt.Rows)
                {
                    Player Player = new Player();
                    Player.IDPlayer = Convert.ToInt32(item["Player_ID"].ToString());
                    Player.IDContest = Convert.ToInt32(item["Contest_ID"].ToString());
                    Player.PlayerName = item["Player_Name"].ToString();
                    Player.PlayerScore = Convert.ToInt32(item["Player_Score"].ToString());
                    Player.Color = item["Color"].ToString();
                    Player.Sequence = Convert.ToInt32(item["Player_Sequence"].ToString());

                    PlayerList.Add(Player);
                    //i++;
                }
            }
            return PlayerList;
        }
コード例 #5
0
ファイル: PlayerBL.cs プロジェクト: antang/NewCapstoneProject
 public bool DeletePlayerbyIDContest(Player Player)
 {
     string query = "DELETE FROM [Player]"
                  + " WHERE [Contest_ID] = '" + Player.IDContest + "'";
     return DA.DeleteDatabase(query);
 }
コード例 #6
0
ファイル: PlayerBL.cs プロジェクト: antang/NewCapstoneProject
        // get player by id contest
        public List<Player> GetPlayerByIDContest(Player player)
        {
            List<Player> PlayerList = new List<Player>();
            string query = "SELECT pl.[Player_ID],pl.[Contest_ID],pl.[Player_Name],pl.[Player_Score],pl.[Color],pl.[Player_Sequence]"
                        + " FROM [Player]pl"
                        + " INNER JOIN Contest  c ON c.Contest_ID = pl.Contest_ID"
                        //+ " INNER JOIN Phase ph ON ph.Contest_ID = c.Contest_ID"
                        + " WHERE pl.[Contest_ID] = '" + player.IDContest + "' ORDER BY [Player_Sequence] ASC";
            //ORDER BY [Player_Sequence] ASC
            DataTable dt = DA.SelectDatabase(query);
            if (dt != null)
            {
                foreach (DataRow item in dt.Rows)
                {
                    Player Player = new Player();
                    Player.IDPlayer = Convert.ToInt32(item["Player_ID"].ToString());
                    Player.IDContest = Convert.ToInt32(item["Contest_ID"].ToString());
                    Player.PlayerName = item["Player_Name"].ToString();
                    Player.PlayerScore = Convert.ToInt32(item["Player_Score"].ToString());
                    Player.Color = item["Color"].ToString();
                    Player.Sequence = Convert.ToInt32(item["Player_Sequence"].ToString());

                    PlayerList.Add(Player);
                }
            }
            return PlayerList;
        }
コード例 #7
0
ファイル: New_Game.cs プロジェクト: antang/NewCapstoneProject
        private void deleteSetupToolStripMenuItem_Click(object sender, EventArgs e)
        {
            DialogResult dialogResult = MessageBox.Show("Bạn muốn xóa cuộc thi này không?", "Xóa Thiết Đặt", MessageBoxButtons.YesNo);
            if (dialogResult == DialogResult.Yes)
            {
                Contest Contest = new Contest();
                Phase Phase = new Phase();
                Player Player = new Player();
                Record Record = new Record();

                ContestBL ContestBL = new ContestBL();
                PhaseBL PhaseBl = new PhaseBL();
                PlayerBL PlayerBL = new PlayerBL();
                PhaseQuestionBL PhaseQuestionBL = new PhaseQuestionBL();
                RecordBL RecordBL = new RecordBL();

                Contest.IDContest = Convert.ToInt32(lbl_IDContest.Text);
                Phase.IDContest = Convert.ToInt32(lbl_IDContest.Text);
                Player.IDContest = Convert.ToInt32(lbl_IDContest.Text);
                Record.IDContest = Convert.ToInt32(lbl_IDContest.Text);

                RecordBL.DeleteRecordByIDContest(Record);
                PhaseQuestionBL.DeletePhaseQuestionbyIDContest(Phase);
                PlayerBL.DeletePlayerbyIDContest(Player);
                PhaseBl.DeletePhasebyIDContest(Phase);
                ContestBL.DeleteContestbyID(Contest);
                LoadAll();

                EventHandler delete = onDelete;

                if (delete != null)
                {
                    MyEventArgs args = new MyEventArgs();
                    args.IDNewGame = iD_NewGame;
                    delete(this, args);
                }
            }
        }