Exemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string CS = ConfigurationManager.ConnectionStrings["SampleConnectionString"].ConnectionString;
            SqlConnection con = new SqlConnection(CS);
                SqlCommand cmd = new SqlCommand("select ID, Name, Gender from tblStudents where Gender = 'Male'", con);
                List<Student>listStudent = new List<Student>();
            con.Open();
            SqlDataReader rdr = cmd.ExecuteReader();
            while (rdr.Read())
            {
                Student student = new Student();
                student.ID = Convert.ToInt32(rdr["ID"]);
                student.Name = rdr["Name"].ToString();
                student.Gender= rdr["Gender"].ToString();

                listStudent.Add(student);

            }
            con.Close();

            GridView1.DataSource = listStudent;
            GridView1.DataBind();
        }
Exemplo n.º 2
0
 public Statistics()
 {
     _Student = new Student();
     _Subject = new Subject();
     _DataBase = new StudentDataBase();
 }
Exemplo n.º 3
0
        public static DataTable GetTableStudents()
        {
            DataTable table = new DataTable("Students");
            DataColumn column; //столбцы
            DataRow row; //строки

            column = new DataColumn();
            column.DataType = typeof(System.String);
            column.ColumnName = "surname";
            table.Columns.Add(column);

            column = new DataColumn();
            column.DataType = typeof(System.String);
            column.ColumnName = "name";
            table.Columns.Add(column);

            column = new DataColumn();
            column.DataType = typeof(System.String);
            column.ColumnName = "patronymic";
            table.Columns.Add(column);

            column = new DataColumn();
            column.DataType = typeof(System.DateTime);
            column.ColumnName = "birthday";
            table.Columns.Add(column);

            column = new DataColumn();
            column.DataType = typeof(System.String);
            column.ColumnName = "gender";
            table.Columns.Add(column);

            column = new DataColumn();
            column.DataType = typeof(System.String);
            column.ColumnName = "hometown";
            table.Columns.Add(column);

            string name = "Анастасия";
            string surname = "Бирилло";
            string patronymic = "Игоревна";
            string gender = "Ж";

            Student student1 = new Student(name, surname, patronymic, gender);
            student1.AddBirthday(new DateTime(1995, 11, 3));
            student1.AddHometown("Ухта");

            name = "Евгений";
            surname = "Ключиков";
            patronymic = "Сергеевич";
            gender = "М";

            Student student2 = new Student(name, surname, patronymic, gender);
            student2.AddBirthday(new DateTime(1995, 10, 17));
            student2.AddHometown("Владивосток");

            name = "Ольга";
            surname = "Артемьева";
            patronymic = "Александровна";
            gender = "Ж";

            Student student4 = new Student(name, surname, patronymic, gender);
            student4.AddBirthday(new DateTime(1995, 6, 18));
            student4.AddHometown("Санкт-Петербург");

            name = "Георгий";
            surname = "Багрецов";
            patronymic = "Игоревич";
            gender = "М";

            Student student5 = new Student(name, surname, patronymic, gender);
            student5.AddBirthday(new DateTime(1995, 7, 20));
            student5.AddHometown("Магнитогорск");

            name = "Елена";
            surname = "Веревкина";
            patronymic = "Борисовна";
            gender = "Ж";

            Student student6 = new Student(name, surname, patronymic, gender);
            student6.AddBirthday(new DateTime(1995, 3, 9));
            student6.AddHometown("Магнитогорск");

            name = "Вячеслав";
            surname = "Галактионов";
            patronymic = "Аркадьевич";
            gender = "М";

            Student student7 = new Student(name, surname, patronymic, gender);
            student7.AddBirthday(new DateTime(1995, 4, 27));
            student7.AddHometown("Новокузнецк");

            name = "Александр";
            surname = "Головань";
            patronymic = "Александрович";
            gender = "М";

            Student student8 = new Student(name, surname, patronymic, gender);
            student8.AddBirthday(new DateTime(1995, 12, 3));
            student8.AddHometown("Комсомольск на Амуре");

            name = "Валентин";
            surname = "Григорьев";
            patronymic = "Дмитриевич";
            gender = "М";

            Student student9 = new Student(name, surname, patronymic, gender);
            student9.AddBirthday(new DateTime(1994, 3, 18));
            student9.AddHometown("Колпино");

            name = "Алексей";
            surname = "Зернов";
            patronymic = "Викторович";
            gender = "М";

            Student student10 = new Student(name, surname, patronymic, gender);
            student10.AddBirthday(new DateTime(1994, 7, 23));
            student10.AddHometown("Нижний Новгород");

            name = "Дмитрий";
            surname = "Искрич";
            patronymic = "Павлович";
            gender = "М";

            Student student11 = new Student(name, surname, patronymic, gender);
            student11.AddBirthday(new DateTime(1995, 7, 26));
            student11.AddHometown("Ставрополь");

            name = "Евгений";
            surname = "Лабузов";
            patronymic = "Вячеславович";
            gender = "М";

            Student student12 = new Student(name, surname, patronymic, gender);
            student12.AddBirthday(new DateTime(1995, 11, 9));
            student12.AddHometown("Всеволожск");

            name = "Василий";
            surname = "Миронович";
            patronymic = "Сергеевич";
            gender = "М";

            Student student13 = new Student(name, surname, patronymic, gender);
            student13.AddBirthday(new DateTime(1995, 1, 26));
            student13.AddHometown("Санкт-Петербург");

            name = "Святослав Тхон Иль ";
            surname = "Пак";
            patronymic = "Владимирович";
            gender = "М";

            Student student14 = new Student(name, surname, patronymic, gender);
            student14.AddBirthday(new DateTime(1995, 11, 30));
            student14.AddHometown("Санкт-Петербург");

            name = "Никита";
            surname = "Шиндарев";
            patronymic = "Андреевич";
            gender = "М";

            Student student15 = new Student(name, surname, patronymic, gender);
            student15.AddBirthday(new DateTime(1995, 1, 2));
            student15.AddHometown("Санкт-Петербург");

            List<Student> students = new List<Student>() { student2, student1, student4, student5, student6, student7, student8, student9, student10, student11, student12, student13, student14, student15 };

            for (int i = 0; i < students.Count; i++)
            {
                row = table.NewRow();
                row["surname"] = students[i].surname;
                row["name"] = students[i].name;
                row["patronymic"] = students[i].patronymic;
                row["gender"] = students[i].gender;
                row["birthday"] = students[i].birthday;
                row["hometown"] = students[i].hometown;
                table.Rows.Add(row);
            }
            return table;
        }
Exemplo n.º 4
0
 public static string GetFIO(Student s)
 {
     return (s.surname + " " + s.name + " " + s.patronymic);
 }