CapDemo.BL.ContestBL.GetAllSetup C# (CSharp) Method

GetAllSetup() public method

public GetAllSetup ( ) : List
return List
        public List<Contest> GetAllSetup()
        {
            List<Contest> ContestList = new List<Contest>();
            string query = "SELECT c.[Contest_ID],c.[Round_ID],c.[Contest_Name],c.[Bonus],c.[Request_Time],c.[Challenge_Score],c.[Number_Challenge]"
                        + ",c.[Time_show_Anwer],c.[Time_show_Question],c.[Time_of_True],c.[Time_of_False]"
                        + ",r.[Round_Name],n.[Competition_Name],r.[Competition_ID], c.[EndContest],c.[Run]"
                        + " FROM [Contest] c"
                        + " INNER JOIN [Round] r ON r.[Round_ID] = c.[Round_ID]"
                        + " INNER JOIN [Competition] n ON n.[Competition_ID] = r.[Competition_ID]";
            DataTable dt = DA.SelectDatabase(query);
            //int i = 1;
            if (dt != null)
            {
                foreach (DataRow item in dt.Rows)
                {
                    Contest Contest = new Contest();
                    Contest.IDContest = Convert.ToInt32(item["Contest_ID"].ToString());
                    Contest.IDRound = Convert.ToInt32(item["Round_ID"].ToString());
                    Contest.NameContest = (item["Contest_Name"]).ToString();
                    Contest.Bonus = Convert.ToInt32(item["Bonus"].ToString());
                    Contest.TimeSupport = Convert.ToInt32(item["Request_Time"].ToString());
                    Contest.ChallengceScore = Convert.ToInt32(item["Challenge_Score"].ToString());
                    Contest.NumberChallenge = Convert.ToInt32(item["Number_Challenge"].ToString());
                    Contest.TimeShowAnswer = Convert.ToInt32(item["Time_show_Anwer"].ToString());
                    Contest.TimeShowQuestion = Convert.ToInt32(item["Time_show_Question"].ToString());
                    Contest.TimesTrue = Convert.ToInt32(item["Time_of_True"].ToString());
                    Contest.Status = (bool)item["EndContest"];
                    Contest.Run = (bool)(item["Run"]);
                    //round
                    Contest.TimesFalse = Convert.ToInt32(item["Time_of_False"].ToString());
                    Contest.Round.IDRound = Convert.ToInt32(item["Round_ID"].ToString());
                    Contest.Round.IDCompetition = Convert.ToInt32(item["Competition_ID"].ToString());
                    Contest.Round.NameRound = (item["Round_Name"]).ToString();
                    Contest.Competition.NameCompetition = (item["Competition_Name"]).ToString();

                    ContestList.Add(Contest);
                    //i++;
                }
            }
            return ContestList;
        }

Usage Example

Exemplo n.º 1
0
        //Load
        public void LoadContest()
        {
            ContestBL ContestBL = new ContestBL();
            List<Contest> ListContest;
            ListContest = ContestBL.GetAllSetup();

            if (ListContest != null)
            {
                for (int i = 0; i < ListContest.Count; i++)
                {
                    if (ListContest.ElementAt(i).IDContest == Convert.ToInt32(lbl_IDContest.Text))
                    {
                        lbl_CompetitionName.Text = ListContest.ElementAt(i).Competition.NameCompetition;
                        lbl_RoundName.Text = ListContest.ElementAt(i).Round.NameRound;
                        lbl_ContestName.Text = ListContest.ElementAt(i).NameContest;
                        lbl_IDContest.Text = ListContest.ElementAt(i).IDContest.ToString();
                        //lbl_Number.Text = (i + 1).ToString();
                        if (ListContest.ElementAt(i).Status == true)
                        {
                            lbl_Status.Text = "Hoàn tất";
                            lbl_Status.ForeColor = Color.Red;
                            lbl_EndContest.Text = "0";
                            lbl_Result.Visible = true;
                        }
                        else
                        {
                            lbl_Status.Text = "Chưa hoàn Tất";
                            lbl_Status.ForeColor = Color.Red;
                            lbl_EndContest.Text = "1";
                            lbl_Result.Visible = false;
                        }
                    }
                }
            }
        }
All Usage Examples Of CapDemo.BL.ContestBL::GetAllSetup