Exemplo n.º 1
0
 //them
 public bool addLICHTD(DTO_LICHTD d)
 {
     try
     {
         connect.Open();
         string time;
         if (string.Format("{0:yyyy/MM/dd HH:mm:ss}", d.ThoiGianDienRa) == "")
         {
             time = null;
         }
         else
         {
             time = string.Format("{0:yyyy/MM/dd HH:mm:ss}", d.ThoiGianDienRa);
         }
         string sql = "";
         sql += "INSERT INTO LICHTD(MaTran,TenDoi1,TenDoi2,ThoiGianDienRa,TrongTai,BanThang1,BanThang2,TheVang1,TheVang2,TheDo1,TheDo2,SoDiem1,SoDiem2) ";
         sql += "VALUES (@MA,@TEN1,@TEN2,@TIME,@TT,@BT1,@BT2,@TV1,@TV2,@TD1,@TD2,@SD1,@SD2)";
         SqlCommand cmd = new SqlCommand(sql, connect);
         cmd.CommandType = CommandType.Text;
         cmd.Parameters.Add(new SqlParameter("@MA", d.MaTran));
         cmd.Parameters.Add(new SqlParameter("@TEN1", d.TenDoi1));
         cmd.Parameters.Add(new SqlParameter("@TEN2", d.TenDoi2));
         //Add param with confused beween two type
         cmd.Parameters.Add(new SqlParameter("@TIME", (object)time ?? DBNull.Value));
         cmd.Parameters.Add(new SqlParameter("@TT", (object)d.TrongTai ?? DBNull.Value));
         cmd.Parameters.Add(new SqlParameter("@BT1", (object)d.BanThang1 ?? DBNull.Value));
         cmd.Parameters.Add(new SqlParameter("@BT2", (object)d.BanThang2 ?? DBNull.Value));
         cmd.Parameters.Add(new SqlParameter("@TV1", (object)d.TheVang1 ?? DBNull.Value));
         cmd.Parameters.Add(new SqlParameter("@TV2", (object)d.TheVang2 ?? DBNull.Value));
         cmd.Parameters.Add(new SqlParameter("@TD1", (object)d.TheDo1 ?? DBNull.Value));
         cmd.Parameters.Add(new SqlParameter("@TD2", (object)d.TheDo2 ?? DBNull.Value));
         cmd.Parameters.Add(new SqlParameter("@SD1", (object)d.SoDiem1 ?? DBNull.Value));
         cmd.Parameters.Add(new SqlParameter("@SD2", (object)d.SoDiem2 ?? DBNull.Value));
         //kiem tra
         if (cmd.ExecuteNonQuery() > 0)
         {
             return(true);
         }
     }
     catch (Exception e) { }
     finally
     {
         //close connect
         connect.Close();
     }
     return(false);
 }
Exemplo n.º 2
0
 //sua
 public bool upLICHTD(DTO_LICHTD d)
 {
     try
     {
         connect.Open();
         string time;
         if (string.Format("{0:yyyy/MM/dd HH:mm:ss}", d.ThoiGianDienRa) == "")
         {
             time = null;
         }
         else
         {
             time = string.Format("{0:yyyy/MM/dd HH:mm:ss}", d.ThoiGianDienRa);
         }
         string sql = "UPDATE LICHTD SET ThoiGianDienRa=@TIME,TrongTai=@TT,BanThang1=@BT1,BanThang2=@BT2,";
         sql += "TheVang1=@TV1,TheVang2=@TV2,TheDo1=@TD1,TheDo2=@TD2,SoDiem1=@SD1,SoDiem2=@SD2 WHERE MaTran=@MA AND TenDoi1=@TEN1 AND TenDoi2=@TEN2";
         SqlCommand cmd = new SqlCommand(sql, connect);
         cmd.CommandType = CommandType.Text;
         cmd.Parameters.Add(new SqlParameter("@MA", d.MaTran));
         cmd.Parameters.Add(new SqlParameter("@TEN1", d.TenDoi1));
         cmd.Parameters.Add(new SqlParameter("@TEN2", d.TenDoi2));
         //Add param with confused beween two type
         cmd.Parameters.Add(new SqlParameter("@TIME", (object)time ?? DBNull.Value));
         cmd.Parameters.Add(new SqlParameter("@TT", (object)d.TrongTai ?? DBNull.Value));
         cmd.Parameters.Add(new SqlParameter("@BT1", (object)d.BanThang1 ?? DBNull.Value));
         cmd.Parameters.Add(new SqlParameter("@BT2", (object)d.BanThang2 ?? DBNull.Value));
         cmd.Parameters.Add(new SqlParameter("@TV1", (object)d.TheVang1 ?? DBNull.Value));
         cmd.Parameters.Add(new SqlParameter("@TV2", (object)d.TheVang2 ?? DBNull.Value));
         cmd.Parameters.Add(new SqlParameter("@TD1", (object)d.TheDo1 ?? DBNull.Value));
         cmd.Parameters.Add(new SqlParameter("@TD2", (object)d.TheDo2 ?? DBNull.Value));
         cmd.Parameters.Add(new SqlParameter("@SD1", (object)d.SoDiem1 ?? DBNull.Value));
         cmd.Parameters.Add(new SqlParameter("@SD2", (object)d.SoDiem2 ?? DBNull.Value));
         //kiem tra
         if (cmd.ExecuteNonQuery() > 0)
         {
             return(true);
         }
     }
     catch (Exception e) { }
     finally
     {
         connect.Close();
     }
     return(false);
 }
Exemplo n.º 3
0
        public void ListMatches(List <string> ListTeam, string mag)
        {
            DataTable     t        = getRangenon(mag);
            List <string> teamdone = new List <string>();

            if (ListTeam.Count % 2 != 0)
            {
                ListTeam.Add("Bye");
            }
            int numTeams = ListTeam.Count;
            int numDays  = (numTeams - 1);
            int halfSize = numTeams / 2;

            List <string> teams = new List <string>();

            teams.AddRange(ListTeam.Skip(halfSize).Take(halfSize));
            teams.AddRange(ListTeam.Skip(1).Take(halfSize - 1).ToArray().Reverse());

            int teamsSize = teams.Count;

            for (int day = 0; day < numDays; day++)
            {
                //add dau tien
                string     matran  = t.Rows[day * halfSize].Field <string>(0);
                int        teamIdx = day % teamsSize;
                DTO_LICHTD dtol    = new DTO_LICHTD(matran, teams[teamIdx], ListTeam[0], null, null, null, null, null, null, null, null, null, null);
                if (CheckTrung(mag, dtol.TenDoi1, dtol.TenDoi2))
                {
                    addLICHTD(dtol);
                }
                for (int idx = 1; idx < halfSize; idx++)
                {
                    int firstTeam  = (day + idx) % teamsSize;
                    int secondTeam = (day + teamsSize - idx) % teamsSize;
                    matran = t.Rows[(day * halfSize) + idx].Field <string>(0);
                    dtol   = new DTO_LICHTD(matran, teams[firstTeam], teams[secondTeam], null, null, null, null, null, null, null, null, null, null);
                    if (CheckTrung(mag, dtol.TenDoi1, dtol.TenDoi2))
                    {
                        addLICHTD(dtol);
                    }
                }
            }
        }
Exemplo n.º 4
0
 //xoa
 public bool delLICHTD(DTO_LICHTD d)
 {
     try
     {
         connect.Open();
         string     sql = string.Format("DELETE FROM LICHTD WHERE MaTran='{0}'", d.MaTran);
         SqlCommand cmd = new SqlCommand(sql, connect);
         //kiem tra
         if (cmd.ExecuteNonQuery() > 0)
         {
             return(true);
         }
     }
     catch (Exception e) { }
     finally
     {
         connect.Close();
     }
     return(false);
 }
Exemplo n.º 5
0
        private void dtaTime_CellEndEdit(object sender, DataGridViewCellEventArgs e)
        {
            int?rowIdx = e?.RowIndex;
            int?colIdx = e?.ColumnIndex;

            if (rowIdx.HasValue && colIdx.HasValue)
            {
                var dgv  = (DataGridView)sender;
                var cell = dgv?.Rows?[rowIdx.Value]?.Cells?[colIdx.Value]?.Value;
                if (!string.IsNullOrEmpty(cell?.ToString()))
                {
                    DataGridViewRow row  = dgv?.Rows?[rowIdx.Value];
                    string          mat  = row?.Cells?[0]?.Value.ToString();
                    string          ten1 = row?.Cells?[1]?.Value.ToString();
                    string          ten2 = row?.Cells?[2]?.Value.ToString();
                    object          o    = row?.Cells?[3]?.Value;
                    DateTime?       time = o == DBNull.Value ? null : (DateTime?)o;
                    string          tt   = row?.Cells?[4]?.Value.ToString();
                    //convert to null param
                    o = row?.Cells?[5]?.Value;
                    int?bt1 = o == DBNull.Value ? null : (int?)o;
                    o = row?.Cells?[6]?.Value;
                    int?bt2 = o == DBNull.Value ? null : (int?)o;
                    o = row?.Cells?[7]?.Value;
                    int?tv1 = o == DBNull.Value ? null : (int?)o;
                    o = row?.Cells?[8]?.Value;
                    int?tv2 = o == DBNull.Value ? null : (int?)o;
                    o = row?.Cells?[9]?.Value;
                    int?td1 = o == DBNull.Value ? null : (int?)o;
                    o = row?.Cells?[10]?.Value;
                    int?td2 = o == DBNull.Value ? null : (int?)o;
                    o = row?.Cells?[11]?.Value;
                    int?sd1 = o == DBNull.Value ? null : (int?)o;
                    o = row?.Cells?[12]?.Value;
                    int?       sd2  = o == DBNull.Value ? null : (int?)o;
                    DTO_LICHTD dtol = new DTO_LICHTD(mat, ten1, ten2, time, tt, bt1, bt2, tv1, tv2, td1, td2, sd1, sd2);
                    l.upLICHTD(dtol);
                    //
                    switch (colIdx)
                    {
                    case 5:
                        show();
                        lblChon.Text    = "Ghi bàn đội 1";
                        numChon.Maximum = (decimal)bt1;
                        madoi           = d.getMa(ten1);
                        p = bt1;
                        DataTable temp = d.getCauThu(madoi);
                        if (temp.Rows.Count > 0)
                        {
                            cboChon.DataSource    = temp;
                            cboChon.DisplayMember = "HoTenCT";
                            dtaTime.ColumnHeadersDefaultCellStyle.ForeColor = Color.Gray;
                            dtaTime.RowsDefaultCellStyle.ForeColor          = Color.Gray;
                            dtaTime.Enabled = false;
                        }
                        break;

                    case 6:
                        show();
                        lblChon.Text = "Ghi bàn đội 2";
                        madoi        = d.getMa(ten2);
                        p            = bt2;
                        temp         = d.getCauThu(madoi);
                        if (temp.Rows.Count > 0)
                        {
                            cboChon.DataSource    = temp;
                            cboChon.DisplayMember = "HoTenCT";
                            dtaTime.ColumnHeadersDefaultCellStyle.ForeColor = Color.Gray;
                            dtaTime.RowsDefaultCellStyle.ForeColor          = Color.Gray;
                            dtaTime.Enabled = false;
                        }
                        break;

                    case 7:
                        show();
                        lblChon.Text = "Thẻ vàng đội 1";
                        madoi        = d.getMa(ten1);
                        p            = tv1;
                        temp         = d.getCauThu(madoi);
                        if (temp.Rows.Count > 0)
                        {
                            cboChon.DataSource    = temp;
                            cboChon.DisplayMember = "HoTenCT";
                            dtaTime.ColumnHeadersDefaultCellStyle.ForeColor = Color.Gray;
                            dtaTime.RowsDefaultCellStyle.ForeColor          = Color.Gray;
                            dtaTime.Enabled = false;
                        }
                        break;

                    case 8:
                        show();
                        lblChon.Text = "Thẻ vàng đội 2";
                        madoi        = d.getMa(ten2);
                        p            = tv2;
                        temp         = d.getCauThu(madoi);
                        if (temp.Rows.Count > 0)
                        {
                            cboChon.DataSource    = temp;
                            cboChon.DisplayMember = "HoTenCT";
                            dtaTime.ColumnHeadersDefaultCellStyle.ForeColor = Color.Gray;
                            dtaTime.RowsDefaultCellStyle.ForeColor          = Color.Gray;
                            dtaTime.Enabled = false;
                        }
                        break;

                    case 9:
                        show();
                        lblChon.Text = "Thẻ đỏ đội 1";
                        madoi        = d.getMa(ten1);
                        p            = td1;
                        temp         = d.getCauThu(madoi);
                        if (temp.Rows.Count > 0)
                        {
                            cboChon.DataSource    = temp;
                            cboChon.DisplayMember = "HoTenCT";
                            dtaTime.ColumnHeadersDefaultCellStyle.ForeColor = Color.Gray;
                            dtaTime.RowsDefaultCellStyle.ForeColor          = Color.Gray;
                            dtaTime.Enabled = false;
                        }
                        break;

                    case 10:
                        show();
                        lblChon.Text = "Thẻ đỏ đội 2";
                        madoi        = d.getMa(ten2);
                        p            = td2;
                        temp         = d.getCauThu(madoi);
                        if (temp.Rows.Count > 0)
                        {
                            cboChon.DataSource    = temp;
                            cboChon.DisplayMember = "HoTenCT";
                            dtaTime.ColumnHeadersDefaultCellStyle.ForeColor = Color.Gray;
                            dtaTime.RowsDefaultCellStyle.ForeColor          = Color.Gray;
                            dtaTime.Enabled = false;
                        }
                        break;
                    }
                }
                ;
            }
            ;
        }
Exemplo n.º 6
0
 public bool delLICHTD(DTO_LICHTD g)
 {
     return(dalLICHTD.delLICHTD(g));
 }
Exemplo n.º 7
0
 public bool upLICHTD(DTO_LICHTD g)
 {
     return(dalLICHTD.upLICHTD(g));
 }
Exemplo n.º 8
0
 public bool addLICHTD(DTO_LICHTD g)
 {
     return(dalLICHTD.addLICHTD(g));
 }
Exemplo n.º 9
0
        public void SetupTimewithLoai(string mag, int sodoitg)
        {
            //get table
            DataTable     t = getRange(mag);
            DataTable     ten;
            string        matran;
            int           sotran, sodoidk, sodoitemp;
            List <string> win32 = new List <string>();
            List <string> win16 = new List <string>();
            List <string> win8  = new List <string>();
            List <string> win4  = new List <string>();
            List <string> win2  = new List <string>();

            switch (t.Rows[0].Field <string>(2))
            {
            case "1/32":
                matran    = t.Rows[0].Field <string>(0);
                ten       = getTeam(mag);
                sotran    = t.Rows[0].Field <int>(3);
                sodoidk   = ten.Rows.Count;
                sodoitemp = sotran * 2;
                //neu sodoi co the tham gia lon hon sodoi da dang ky
                win32 = new List <string>();
                if (sodoidk < sodoitg)      //them ten doi cho cac doi
                {
                    for (int i = sodoidk + 1; i <= sodoitg; i++)
                    {
                        string str = string.Format("Đội #{0}", i);
                        ten.Rows.Add(str);
                    }
                }
                for (int i = 0; i < sotran; i++)
                {
                    string     ten1 = ten.Rows[i * 2].Field <string>(0);
                    string     ten2 = ten.Rows[i * 2 + 1].Field <string>(0);
                    DTO_LICHTD dtol = new DTO_LICHTD(matran, ten1, ten2, null, null, null, null, null, null, null, null, null, null);
                    if (CheckTrungbelow(mag, dtol.TenDoi1, dtol.TenDoi2))
                    {
                        addLICHTD(dtol);
                    }
                    string str = string.Format("W#{0} Vòng 1/32", i + 1);
                    win32.Add(str);
                }
                //1/16
                sotran = t.Rows[1].Field <int>(3);
                matran = t.Rows[1].Field <string>(0);
                win16  = new List <string>();
                for (int i = 0; i < sotran; i++)
                {
                    string ten1; string ten2;
                    if (sodoitg % 2 != 0)
                    {
                        if (i == 0)
                        {
                            ten1 = ten.Rows[sodoitg - 1].Field <string>(0);
                            ten2 = win32[i * 2];
                        }
                        else
                        {
                            if (sodoidk < sodoitemp)
                            {
                                ten1 = win32[i * 2 - 1];
                                ten2 = win32[i * 2];
                            }
                            else
                            {
                                ten1 = ten.Rows[i * 2].Field <string>(0);
                                ten2 = ten.Rows[i * 2 + 1].Field <string>(0);
                            }
                        }
                    }
                    else
                    {
                        if (sodoitg < 32)
                        {
                            if (i == sotran - 1)
                            {
                                ten1 = ten.Rows[sodoitg - 2].Field <string>(0);
                                ten2 = ten.Rows[sodoitg - 1].Field <string>(0);
                            }
                            else
                            {
                                ten1 = win32[i * 2];
                                ten2 = win32[i * 2 + 1];
                            }
                        }
                        if (sodoitg == 32)
                        {
                            ten1 = win32[i * 2];
                            ten2 = win32[i * 2 + 1];
                        }
                        else
                        {
                            if (i == sotran - 1)
                            {
                                ten1 = win32[sodoitg - (sotran + 1) * 2];
                                ten2 = win32[sodoitg - (sotran * 2 + 1)];
                            }
                            else
                            {
                                if (i * 2 + win32.Count * 2 < sodoitg)
                                {
                                    ten1 = ten.Rows[i * 2 + win32.Count * 2].Field <string>(0);
                                    ten2 = ten.Rows[i * 2 + 1 + win32.Count * 2].Field <string>(0);
                                }
                                else
                                {
                                    ten1 = win32[((i + win32.Count) * 2) - Math.Abs(sotran + win32.Count / 2) * 2];
                                    ten2 = win32[((i + win32.Count) * 2) - Math.Abs(sotran + win32.Count / 2) * 2 + 1];
                                }
                            }
                        }
                    }
                    DTO_LICHTD dtol = new DTO_LICHTD(matran, ten1, ten2, null, null, null, null, null, null, null, null, null, null);
                    if (CheckTrungbelow(mag, dtol.TenDoi1, dtol.TenDoi2))
                    {
                        addLICHTD(dtol);
                    }
                    string str = string.Format("W#{0} Vòng 1/16", i + 1);
                    win16.Add(str);
                }
                //1/8
                sotran = t.Rows[2].Field <int>(3);
                matran = t.Rows[2].Field <string>(0);
                win8   = new List <string>();
                for (int i = 0; i < sotran; i++)
                {
                    string ten1; string ten2;
                    ten1 = win16[i * 2];
                    ten2 = win16[i * 2 + 1];
                    DTO_LICHTD dtol = new DTO_LICHTD(matran, ten1, ten2, null, null, null, null, null, null, null, null, null, null);
                    if (CheckTrungbelow(mag, dtol.TenDoi1, dtol.TenDoi2))
                    {
                        addLICHTD(dtol);
                    }
                    string str = string.Format("W#{0} Vòng 1/8", i + 1);
                    win8.Add(str);
                }
                //tu ket
                sotran = t.Rows[3].Field <int>(3);
                matran = t.Rows[3].Field <string>(0);
                win4   = new List <string>();
                for (int i = 0; i < sotran; i++)
                {
                    string ten1; string ten2;
                    ten1 = win8[i * 2];
                    ten2 = win8[i * 2 + 1];
                    DTO_LICHTD dtol = new DTO_LICHTD(matran, ten1, ten2, null, null, null, null, null, null, null, null, null, null);
                    if (CheckTrungbelow(mag, dtol.TenDoi1, dtol.TenDoi2))
                    {
                        addLICHTD(dtol);
                    }
                    string str = string.Format("W#{0} Vòng Tứ Kết", i + 1);
                    win4.Add(str);
                }
                //ban ket
                sotran = t.Rows[4].Field <int>(3);
                matran = t.Rows[4].Field <string>(0);
                win2   = new List <string>();
                for (int i = 0; i < sotran; i++)
                {
                    string ten1; string ten2;
                    ten1 = win4[i * 2];
                    ten2 = win4[i * 2 + 1];
                    DTO_LICHTD dtol = new DTO_LICHTD(matran, ten1, ten2, null, null, null, null, null, null, null, null, null, null);
                    if (CheckTrungbelow(mag, dtol.TenDoi1, dtol.TenDoi2))
                    {
                        addLICHTD(dtol);
                    }
                    string str = string.Format("W#{0} Vòng Bán Kết", i + 1);
                    win2.Add(str);
                }
                //chung ket
                sotran = t.Rows[5].Field <int>(3);
                matran = t.Rows[5].Field <string>(0);
                for (int i = 0; i < sotran; i++)
                {
                    string ten1; string ten2;
                    ten1 = win2[i * 2];
                    ten2 = win2[i * 2 + 1];
                    DTO_LICHTD dtol = new DTO_LICHTD(matran, ten1, ten2, null, null, null, null, null, null, null, null, null, null);
                    if (CheckTrungbelow(mag, dtol.TenDoi1, dtol.TenDoi2))
                    {
                        addLICHTD(dtol);
                    }
                }
                break;

            case "1/16":
                matran    = t.Rows[0].Field <string>(0);
                ten       = getTeam(mag);
                sotran    = t.Rows[0].Field <int>(3);
                sodoidk   = ten.Rows.Count;
                sodoitemp = sotran * 2;
                //neu sodoi co the tham gia lon hon sodoi da dang ky
                win16 = new List <string>();
                if (sodoidk < sodoitg)      //them ten doi cho cac doi
                {
                    for (int i = sodoidk + 1; i <= sodoitg; i++)
                    {
                        string str = string.Format("Đội #{0}", i);
                        ten.Rows.Add(str);
                    }
                }
                for (int i = 0; i < sotran; i++)
                {
                    string     ten1 = ten.Rows[i * 2].Field <string>(0);
                    string     ten2 = ten.Rows[i * 2 + 1].Field <string>(0);
                    DTO_LICHTD dtol = new DTO_LICHTD(matran, ten1, ten2, null, null, null, null, null, null, null, null, null, null);
                    if (CheckTrungbelow(mag, dtol.TenDoi1, dtol.TenDoi2))
                    {
                        addLICHTD(dtol);
                    }
                    string str = string.Format("W#{0} Vòng 1/16", i + 1);
                    win16.Add(str);
                }
                //1/8
                sotran = t.Rows[1].Field <int>(3);
                matran = t.Rows[1].Field <string>(0);
                win8   = new List <string>();
                for (int i = 0; i < sotran; i++)
                {
                    string ten1; string ten2;
                    if (sodoitg % 2 != 0)
                    {
                        if (i == 0)
                        {
                            ten1 = ten.Rows[sodoitg - 1].Field <string>(0);
                            ten2 = win16[i * 2];
                        }
                        else
                        {
                            if (sodoidk < sodoitemp)
                            {
                                ten1 = win16[i * 2 - 1];
                                ten2 = win16[i * 2];
                            }
                            else
                            {
                                ten1 = ten.Rows[i * 2].Field <string>(0);
                                ten2 = ten.Rows[i * 2 + 1].Field <string>(0);
                            }
                        }
                    }
                    else
                    {
                        if (i == sotran - 1)
                        {
                            ten1 = win16[sodoitg - (sotran + 1) * 2];
                            ten2 = win16[sodoitg - (sotran * 2 + 1)];
                        }
                        else
                        {
                            if (i * 2 + win16.Count * 2 < sodoitg)
                            {
                                ten1 = ten.Rows[i * 2 + win16.Count * 2].Field <string>(0);
                                ten2 = ten.Rows[i * 2 + 1 + win16.Count * 2].Field <string>(0);
                            }
                            else
                            {
                                ten1 = win16[((i + win16.Count) * 2) - Math.Abs(sotran + win16.Count / 2) * 2];
                                ten2 = win16[((i + win16.Count) * 2) - Math.Abs(sotran + win16.Count / 2) * 2 + 1];
                            }
                        }
                    }
                    DTO_LICHTD dtol = new DTO_LICHTD(matran, ten1, ten2, null, null, null, null, null, null, null, null, null, null);
                    if (CheckTrungbelow(mag, dtol.TenDoi1, dtol.TenDoi2))
                    {
                        addLICHTD(dtol);
                    }
                    string str = string.Format("W#{0} Vòng 1/8", i + 1);
                    win8.Add(str);
                }
                //tu ket
                sotran = t.Rows[2].Field <int>(3);
                matran = t.Rows[2].Field <string>(0);
                win4   = new List <string>();
                for (int i = 0; i < sotran; i++)
                {
                    string ten1; string ten2;
                    ten1 = win8[i * 2];
                    ten2 = win8[i * 2 + 1];
                    DTO_LICHTD dtol = new DTO_LICHTD(matran, ten1, ten2, null, null, null, null, null, null, null, null, null, null);
                    if (CheckTrungbelow(mag, dtol.TenDoi1, dtol.TenDoi2))
                    {
                        addLICHTD(dtol);
                    }
                    string str = string.Format("W#{0} Vòng Tứ Kết", i + 1);
                    win4.Add(str);
                }
                //ban ket
                sotran = t.Rows[3].Field <int>(3);
                matran = t.Rows[3].Field <string>(0);
                win2   = new List <string>();
                for (int i = 0; i < sotran; i++)
                {
                    string ten1; string ten2;
                    ten1 = win4[i * 2];
                    ten2 = win4[i * 2 + 1];
                    DTO_LICHTD dtol = new DTO_LICHTD(matran, ten1, ten2, null, null, null, null, null, null, null, null, null, null);
                    if (CheckTrungbelow(mag, dtol.TenDoi1, dtol.TenDoi2))
                    {
                        addLICHTD(dtol);
                    }
                    string str = string.Format("W#{0} Vòng Bán Kết", i + 1);
                    win2.Add(str);
                }
                //chung ket
                sotran = t.Rows[4].Field <int>(3);
                matran = t.Rows[4].Field <string>(0);
                for (int i = 0; i < sotran; i++)
                {
                    string ten1; string ten2;
                    ten1 = win2[i * 2];
                    ten2 = win2[i * 2 + 1];
                    DTO_LICHTD dtol = new DTO_LICHTD(matran, ten1, ten2, null, null, null, null, null, null, null, null, null, null);
                    if (CheckTrungbelow(mag, dtol.TenDoi1, dtol.TenDoi2))
                    {
                        addLICHTD(dtol);
                    }
                }
                break;

            case "1/8":
                matran    = t.Rows[0].Field <string>(0);
                ten       = getTeam(mag);
                sotran    = t.Rows[0].Field <int>(3);
                sodoidk   = ten.Rows.Count;
                sodoitemp = sotran * 2;
                //neu sodoi co the tham gia lon hon sodoi da dang ky
                win8 = new List <string>();
                if (sodoidk < sodoitg)      //them ten doi cho cac doi
                {
                    for (int i = sodoidk + 1; i <= sodoitg; i++)
                    {
                        string str = string.Format("Đội #{0}", i);
                        ten.Rows.Add(str);
                    }
                }
                for (int i = 0; i < sotran; i++)
                {
                    string     ten1 = ten.Rows[i * 2].Field <string>(0);
                    string     ten2 = ten.Rows[i * 2 + 1].Field <string>(0);
                    DTO_LICHTD dtol = new DTO_LICHTD(matran, ten1, ten2, null, null, null, null, null, null, null, null, null, null);
                    if (CheckTrungbelow(mag, dtol.TenDoi1, dtol.TenDoi2))
                    {
                        addLICHTD(dtol);
                    }
                    string str = string.Format("W#{0} Vòng 1/8", i + 1);
                    win8.Add(str);
                }
                //tu ket
                sotran = t.Rows[1].Field <int>(3);
                matran = t.Rows[1].Field <string>(0);
                win4   = new List <string>();
                for (int i = 0; i < sotran; i++)
                {
                    string ten1; string ten2;
                    if (sodoitg % 2 != 0)
                    {
                        if (i == 0)
                        {
                            ten1 = ten.Rows[sodoitg - 1].Field <string>(0);
                            ten2 = win8[i * 2];
                        }
                        else
                        {
                            if (sodoidk < sodoitemp)
                            {
                                ten1 = win8[i * 2 - 1];
                                ten2 = win8[i * 2];
                            }
                            else
                            {
                                ten1 = ten.Rows[i * 2].Field <string>(0);
                                ten2 = ten.Rows[i * 2 + 1].Field <string>(0);
                            }
                        }
                    }
                    else
                    {
                        if (i == sotran - 1)
                        {
                            ten1 = win8[sodoitg - (sotran + 1) * 2];
                            ten2 = win8[sodoitg - (sotran * 2 + 1)];
                        }
                        else
                        {
                            if (i * 2 + win8.Count * 2 < sodoitg)
                            {
                                ten1 = ten.Rows[i * 2 + win8.Count * 2].Field <string>(0);
                                ten2 = ten.Rows[i * 2 + 1 + win8.Count * 2].Field <string>(0);
                            }
                            else
                            {
                                ten1 = win8[((i + win8.Count) * 2) - Math.Abs(sotran + win8.Count / 2) * 2];
                                ten2 = win8[((i + win8.Count) * 2) - Math.Abs(sotran + win8.Count / 2) * 2 + 1];
                            }
                        }
                    }
                    DTO_LICHTD dtol = new DTO_LICHTD(matran, ten1, ten2, null, null, null, null, null, null, null, null, null, null);
                    if (CheckTrungbelow(mag, dtol.TenDoi1, dtol.TenDoi2))
                    {
                        addLICHTD(dtol);
                    }
                    string str = string.Format("W#{0} Vòng Tứ Kết", i + 1);
                    win4.Add(str);
                }
                //ban ket
                sotran = t.Rows[2].Field <int>(3);
                matran = t.Rows[2].Field <string>(0);
                win2   = new List <string>();
                for (int i = 0; i < sotran; i++)
                {
                    string ten1; string ten2;
                    ten1 = win4[i * 2];
                    ten2 = win4[i * 2 + 1];
                    DTO_LICHTD dtol = new DTO_LICHTD(matran, ten1, ten2, null, null, null, null, null, null, null, null, null, null);
                    if (CheckTrungbelow(mag, dtol.TenDoi1, dtol.TenDoi2))
                    {
                        addLICHTD(dtol);
                    }
                    string str = string.Format("W#{0} Vòng Bán Kết", i + 1);
                    win2.Add(str);
                }
                //chung ket
                sotran = t.Rows[3].Field <int>(3);
                matran = t.Rows[3].Field <string>(0);
                for (int i = 0; i < sotran; i++)
                {
                    string ten1; string ten2;
                    ten1 = win2[i * 2];
                    ten2 = win2[i * 2 + 1];
                    DTO_LICHTD dtol = new DTO_LICHTD(matran, ten1, ten2, null, null, null, null, null, null, null, null, null, null);
                    if (CheckTrungbelow(mag, dtol.TenDoi1, dtol.TenDoi2))
                    {
                        addLICHTD(dtol);
                    }
                }
                break;

            case "Tứ Kết":
                matran    = t.Rows[0].Field <string>(0);
                ten       = getTeam(mag);
                sotran    = t.Rows[0].Field <int>(3);
                sodoidk   = ten.Rows.Count;
                sodoitemp = sotran * 2;
                //neu sodoi co the tham gia lon hon sodoi da dang ky
                win4 = new List <string>();
                if (sodoidk < sodoitg)      //them ten doi cho cac doi
                {
                    for (int i = sodoidk + 1; i <= sodoitg; i++)
                    {
                        string str = string.Format("Đội #{0}", i);
                        ten.Rows.Add(str);
                    }
                }
                for (int i = 0; i < sotran; i++)
                {
                    string     ten1 = ten.Rows[i * 2].Field <string>(0);
                    string     ten2 = ten.Rows[i * 2 + 1].Field <string>(0);
                    DTO_LICHTD dtol = new DTO_LICHTD(matran, ten1, ten2, null, null, null, null, null, null, null, null, null, null);
                    if (CheckTrungbelow(mag, dtol.TenDoi1, dtol.TenDoi2))
                    {
                        addLICHTD(dtol);
                    }
                    string str = string.Format("W#{0} Vòng Tứ Kết", i + 1);
                    win4.Add(str);
                }
                //ban ket
                sotran = t.Rows[1].Field <int>(3);
                matran = t.Rows[1].Field <string>(0);
                win2   = new List <string>();
                for (int i = 0; i < sotran; i++)
                {
                    string ten1; string ten2;
                    if (sodoitg % 2 != 0)
                    {
                        if (i == 0)
                        {
                            ten1 = ten.Rows[sodoitg - 1].Field <string>(0);
                            ten2 = win4[i * 2];
                        }
                        else
                        {
                            if (sodoidk < sodoitemp)
                            {
                                ten1 = win4[i * 2 - 1];
                                ten2 = win4[i * 2];
                            }
                            else
                            {
                                ten1 = ten.Rows[i * 2].Field <string>(0);
                                ten2 = ten.Rows[i * 2 + 1].Field <string>(0);
                            }
                        }
                    }
                    else
                    {
                        if (i == sotran - 1)
                        {
                            ten1 = win4[sodoitg - (sotran + 1) * 2];
                            ten2 = win4[sodoitg - (sotran * 2 + 1)];
                        }
                        else
                        {
                            if (i * 2 + win4.Count * 2 < sodoitg)
                            {
                                ten1 = ten.Rows[i * 2 + win4.Count * 2].Field <string>(0);
                                ten2 = ten.Rows[i * 2 + 1 + win4.Count * 2].Field <string>(0);
                            }
                            else
                            {
                                ten1 = win4[((i + win4.Count) * 2) - Math.Abs(sotran + win4.Count / 2) * 2];
                                ten2 = win4[((i + win4.Count) * 2) - Math.Abs(sotran + win4.Count / 2) * 2 + 1];
                            }
                        }
                    }
                    DTO_LICHTD dtol = new DTO_LICHTD(matran, ten1, ten2, null, null, null, null, null, null, null, null, null, null);
                    if (CheckTrungbelow(mag, dtol.TenDoi1, dtol.TenDoi2))
                    {
                        addLICHTD(dtol);
                    }
                    string str = string.Format("W#{0} Vòng Bán Kết", i + 1);
                    win2.Add(str);
                }
                //chung ket
                sotran = t.Rows[2].Field <int>(3);
                matran = t.Rows[2].Field <string>(0);
                for (int i = 0; i < sotran; i++)
                {
                    string ten1; string ten2;
                    ten1 = win2[i * 2];
                    ten2 = win2[i * 2 + 1];
                    DTO_LICHTD dtol = new DTO_LICHTD(matran, ten1, ten2, null, null, null, null, null, null, null, null, null, null);
                    if (CheckTrungbelow(mag, dtol.TenDoi1, dtol.TenDoi2))
                    {
                        addLICHTD(dtol);
                    }
                }
                break;

            case "Bán Kết":
                matran    = t.Rows[0].Field <string>(0);
                ten       = getTeam(mag);
                sotran    = t.Rows[0].Field <int>(3);
                sodoidk   = ten.Rows.Count;
                sodoitemp = sotran * 2;
                //neu sodoi co the tham gia lon hon sodoi da dang ky
                win2 = new List <string>();
                if (sodoidk < sodoitg)      //them ten doi cho cac doi
                {
                    for (int i = sodoidk + 1; i <= sodoitg; i++)
                    {
                        string str = string.Format("Đội #{0}", i);
                        ten.Rows.Add(str);
                    }
                }
                for (int i = 0; i < sotran; i++)
                {
                    string     ten1 = ten.Rows[i * 2].Field <string>(0);
                    string     ten2 = ten.Rows[i * 2 + 1].Field <string>(0);
                    DTO_LICHTD dtol = new DTO_LICHTD(matran, ten1, ten2, null, null, null, null, null, null, null, null, null, null);
                    if (CheckTrungbelow(mag, dtol.TenDoi1, dtol.TenDoi2))
                    {
                        addLICHTD(dtol);
                    }
                    string str = string.Format("W#{0} Vòng Bán Kết", i + 1);
                    win2.Add(str);
                }
                //ban ket
                for (int i = 0; i < sotran; i++)
                {
                    string ten1; string ten2;
                    if (sodoitg % 2 != 0)
                    {
                        if (i == 0)
                        {
                            ten1 = ten.Rows[sodoitg - 1].Field <string>(0);
                            ten2 = win2[i * 2];
                        }
                        else
                        {
                            if (sodoidk < sodoitemp)
                            {
                                ten1 = win2[i * 2 - 1];
                                ten2 = win2[i * 2];
                            }
                            else
                            {
                                ten1 = ten.Rows[i * 2].Field <string>(0);
                                ten2 = ten.Rows[i * 2 + 1].Field <string>(0);
                            }
                        }
                    }
                    else
                    {
                        if (i == sotran - 1)
                        {
                            ten1 = win2[sodoitg - (sotran + 1) * 2];
                            ten2 = win2[sodoitg - (sotran * 2 + 1)];
                        }
                        else
                        {
                            if (i * 2 + win2.Count * 2 < sodoitg)
                            {
                                ten1 = ten.Rows[i * 2 + win2.Count * 2].Field <string>(0);
                                ten2 = ten.Rows[i * 2 + 1 + win2.Count * 2].Field <string>(0);
                            }
                            else
                            {
                                ten1 = win2[((i + win2.Count) * 2) - Math.Abs(sotran + win2.Count / 2) * 2];
                                ten2 = win2[((i + win2.Count) * 2) - Math.Abs(sotran + win2.Count / 2) * 2 + 1];
                            }
                        }
                    }
                    DTO_LICHTD dtol = new DTO_LICHTD(matran, ten1, ten2, null, null, null, null, null, null, null, null, null, null);
                    if (CheckTrungbelow(mag, dtol.TenDoi1, dtol.TenDoi2))
                    {
                        addLICHTD(dtol);
                    }
                }
                //chung ket
                sotran = t.Rows[1].Field <int>(3);
                matran = t.Rows[1].Field <string>(0);
                for (int i = 0; i < sotran; i++)
                {
                    string ten1; string ten2;
                    ten1 = win2[i * 2];
                    ten2 = win2[i * 2 + 1];
                    DTO_LICHTD dtol = new DTO_LICHTD(matran, ten1, ten2, null, null, null, null, null, null, null, null, null, null);
                    if (CheckTrungbelow(mag, dtol.TenDoi1, dtol.TenDoi2))
                    {
                        addLICHTD(dtol);
                    }
                }
                break;

            case "Chung Kết":
                matran = t.Rows[0].Field <string>(0);
                ten    = getTeam(mag);
                sotran = t.Rows[0].Field <int>(3);
                //chung ket
                for (int i = 0; i < sotran; i++)
                {
                    string ten1; string ten2;
                    ten1 = ten.Rows[i * 2].Field <string>(0);
                    ten2 = ten.Rows[i * 2 + 1].Field <string>(0);
                    DTO_LICHTD dtol = new DTO_LICHTD(matran, ten1, ten2, null, null, null, null, null, null, null, null, null, null);
                    if (CheckTrungbelow(mag, dtol.TenDoi1, dtol.TenDoi2))
                    {
                        addLICHTD(dtol);
                    }
                }
                break;
            }
        }