示例#1
0
        public void LoadData()
        {
            OpenConnection();

            Query("select * from Groups");
            int n = dataSet.Tables[0].Rows.Count;

            groups = new CustomArray <Group>(n);
            for (int i = 0; i < n; i++)
            {
                groups[i] = new Group(Int32.Parse(dataSet.Tables[0].Rows[i]["Id"].ToString()),
                                      dataSet.Tables[0].Rows[i]["Description"].ToString());
            }

            Query("select * from Students");

            n        = dataSet.Tables[0].Rows.Count;
            students = new CustomArray <Student>(n);
            for (int i = 0; i < n; i++)
            {
                students[i] = new Student(
                    Int32.Parse(dataSet.Tables[0].Rows[i]["Id"].ToString()),
                    Int32.Parse(dataSet.Tables[0].Rows[i]["GroupId"].ToString()),
                    dataSet.Tables[0].Rows[i]["Name"].ToString(),
                    Int32.Parse(dataSet.Tables[0].Rows[i]["EnrollYear"].ToString())
                    );
            }

            CloseConnection();

            Console.WriteLine("Sql");

            foreach (var @group in groups)
            {
                Console.WriteLine(@group);
            }

            foreach (var student in students)
            {
                Console.WriteLine(student);
            }

            Console.WriteLine("Групп: {0}, студентов: {1}", GroupCount, StudentCount);
        }
示例#2
0
        public void LoadData()
        {
            OpenXML();

            XmlNodeList xnl = xd.GetElementsByTagName("group");

            groups = new CustomArray <Group>(xnl.Count);
            for (int i = 0; i < xnl.Count; i++)
            {
                groups[i] = new Group(
                    Int32.Parse(xnl.Item(i).Attributes["id"].InnerText),
                    xnl.Item(i).Attributes["description"].InnerText);
            }

            xnl      = xd.GetElementsByTagName("student");
            students = new CustomArray <Student>(xnl.Count);
            for (int i = 0; i < xnl.Count; i++)
            {
                students[i] = new Student(
                    Int32.Parse(xnl.Item(i).Attributes["id"].InnerText),
                    Int32.Parse(xnl.Item(i).Attributes["groupid"].InnerText),
                    xnl.Item(i).Attributes["name"].InnerText,
                    Int32.Parse(xnl.Item(i).Attributes["year"].InnerText));
            }

            CloseXml();

            Console.WriteLine("XML");

            foreach (var @group in groups)
            {
                Console.WriteLine(@group);
            }

            foreach (var student in students)
            {
                Console.WriteLine(student);
            }

            Console.WriteLine("Групп: {0}, студентов: {1}", GroupCount, StudentCount);
        }
示例#3
0
        public void LoadData()
        {
            OpenFile();
            int n = Int32.Parse(sw.ReadLine());

            groups = new CustomArray <Group>(n);
            for (int i = 0; i < n; i++)
            {
                string   s  = sw.ReadLine();
                string[] sA = s.Split(';');
                Group    gr = new Group(Int32.Parse(sA[0]), sA[1]);
                groups[i] = gr;
            }
            n        = Int32.Parse(sw.ReadLine());
            students = new CustomArray <Student>(n);
            for (int i = 0; i < n; i++)
            {
                string   s  = sw.ReadLine();
                string[] sA = s.Split(';');
                Student  st = new Student(Int32.Parse(sA[0]), Int32.Parse(sA[1]), sA[2], Int32.Parse(sA[3]));
                students[i] = st;
            }

            CloseFile();

            Console.WriteLine("TXT");
            foreach (var @group in Groups)
            {
                Console.WriteLine(@group);
            }

            foreach (var student in students)
            {
                Console.WriteLine(student);
            }

            Console.WriteLine("Групп: {0}, студентов: {1}", GroupCount, StudentCount);
        }