Exemplo n.º 1
0
        //-------------------------------------------------------------------------------------------------------------------------------------------------------------------
        public void NapDaTaSVGioi()
        {
            // SanPham x = new SanPham();

            if (conn == null)
            {
                conn = new SqlConnection(sqlconn);
            }
            if (conn.State == ConnectionState.Closed)
            {
                conn.Open();
            }
            SqlCommand command = new SqlCommand();

            command.CommandType = CommandType.Text;
            command.CommandText = "select *from SINHVIEN where DiemTB >= 8.5 and DiemTB<= 10";
            command.Connection  = conn;

            SqlDataReader reader = command.ExecuteReader();



            while (reader.Read())
            {
                SinhVien x = new SinhVien();

                x.MaSV     = reader.GetValue(0) + "";
                x.TenSV    = reader.GetValue(1) + "";
                x.NamSinh  = DateTime.Parse(reader.GetValue(2) + "");
                x.GioiTinh = reader.GetValue(3) + "";
                x.DiemToan = float.Parse(reader.GetValue(4) + "");
                x.DiemLy   = float.Parse(reader.GetValue(5) + "");
                x.DiemHoa  = float.Parse(reader.GetValue(6) + "");
                x.DiemTB   = float.Parse(reader.GetValue(7) + "");
                x.MaLop    = reader.GetValue(8) + "";
                CSDL_SV.AddHead(x);
            }
            //CSDL_SP01.AddHead(x);
            reader.Close();
        }
Exemplo n.º 2
0
        //-------------------------------------------------------------------------------------------------------------

        public void QuickSort(LinkedListSV <SinhVien> l)
        {
            LinkedListSV <SinhVien> l1 = new LinkedListSV <SinhVien>();
            LinkedListSV <SinhVien> l2 = new LinkedListSV <SinhVien>();

            LinkedListSV <SinhVien> .Node tag, p;
            if (l.pHead == l.pTail)
            {
                return;
            }

            tag       = l.pHead;
            l.pHead   = l.pHead.pNext; // cap nhat lai l.head
            tag.pNext = null;          // co lap tag
            while (l.pHead != null)
            {
                p       = l.pHead;
                l.pHead = l.pHead.pNext;
                p.pNext = null;
                if (p.data.DiemTB >= tag.data.DiemTB)
                {
                    l1.AddHead(p.data);
                }
                else
                {
                    l2.AddHead(p.data);
                }
            }
            QuickSort(l1); // goi de qui sap xep l1, l2
            QuickSort(l2);
            if (l1.pHead != null)
            {                              // l1 k rong
                l.pHead        = l1.pHead; // lay head cua l1 gan cho head cua l;
                l1.pTail.pNext = tag;
            } // l1 rong
            else
            {
                l.pHead = tag;
            }
            tag.pNext = l2.pHead;
            if (l2.pHead != null)
            {
                l.pTail = l2.pTail;
            }
            else
            {
                l.pTail = tag;
            }
        }