Beispiel #1
0
        public void Sort(int check)
        {
            List <SV> sv    = new List <SV>(CSDL.Instance.DTSV.Rows.Count);
            int       count = 0;

            foreach (DataRow dr in CSDL.Instance.DTSV.Rows)
            {
                count++;
                sv.Add(GetSV(dr));
            }
            switch (check)
            {
            case 1:
            {
                for (int i = 0; i < count; i++)
                {
                    for (int j = 0; j < count - 1; j++)
                    {
                        if (Convert.ToInt32(sv[j].MSSV) > Convert.ToInt32(sv[j + 1].MSSV))

                        {
                            SV temp = sv[j];
                            sv[j]     = sv[j + 1];
                            sv[j + 1] = temp;
                        }
                    }
                }
                break;
            }

            case 2:
            {
                for (int i = 0; i < count; i++)
                {
                    for (int j = 0; j < count - 1; j++)
                    {
                        if (sv[j].Name.CompareTo(sv[j + 1].Name) > 0)

                        {
                            SV temp = sv[j];
                            sv[j]     = sv[j + 1];
                            sv[j + 1] = temp;
                        }
                    }
                }
                break;
            }

            case 3:
            {
                for (int i = 0; i < count; i++)
                {
                    for (int j = 0; j < count - 1; j++)
                    {
                        if (sv[j].Gender.ToString().CompareTo(sv[j + 1].Gender.ToString()) > 0)

                        {
                            SV temp = sv[j];
                            sv[j]     = sv[j + 1];
                            sv[j + 1] = temp;
                        }
                    }
                }
                break;
            }

            case 4:
            {
                for (int i = 0; i < count; i++)
                {
                    for (int j = 0; j < count - 1; j++)
                    {
                        if (sv[j].NS.ToString().CompareTo(sv[j + 1].NS.ToString()) > 0)

                        {
                            SV temp = sv[j];
                            sv[j]     = sv[j + 1];
                            sv[j + 1] = temp;
                        }
                    }
                }
                break;
            }

            default:
            {
                for (int i = 0; i < count; i++)
                {
                    for (int j = 0; j < count - 1; j++)
                    {
                        if (sv[j].ID_Lop > sv[j + 1].ID_Lop)

                        {
                            SV temp = sv[j];
                            sv[j]     = sv[j + 1];
                            sv[j + 1] = temp;
                        }
                    }
                }
                break;
            }
            }
            CSDL.Instance.CapNhatDSSV(sv);
        }