1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
|
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Globalization;
namespace WinStudents
{
public partial class Form1 : Form
{
private Student std;
private Student[] myStudents;
private Course cs;
public Form1()
{
InitializeComponent();
button2.Enabled = false;
}
private void button1_Click(object sender, EventArgs e)
{
button2.Enabled = false;
cs = new Course();
cs.CourseName = "Biologie";
Student[] myStudents = new Student[5];
DateTime t = DateTime.Parse("05/12/1990",CultureInfo.CurrentCulture );
for (int i = 0; i < myStudents.Length; i++)
{
std = new Student();
std.FirstName = "Nom" + i.ToString();
std.LastName = "Prenom" + i.ToString();
std.CourseAffected = cs.CourseName;
t = t.AddYears(2);
std.Birthdate = t;
myStudents[i] = std;
}
cs.ArrStudents = myStudents;
button2.Enabled = true;
}
private void button2_Click(object sender, EventArgs e)
{
textBox1.Clear();
string s;
foreach (Student item in cs.ArrStudents )
{
s = item.FirstName + " ; " + item.LastName + " ; " + item.CourseAffected.ToString() + " ; " + item.Birthdate.ToShortDateString()+ Environment.NewLine;
textBox1.Text += s;
}
}
}
} |