-
Notifications
You must be signed in to change notification settings - Fork 0
/
Form1.cs
55 lines (49 loc) · 1.84 KB
/
Form1.cs
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
using MySql.Data.MySqlClient;
namespace StudentMiniApp
{
public partial class Form1 : Form
{
List<Student> studentList;
public Form0 form0;
public Form1()
{
InitializeComponent();
studentList = (new StudentController()).GetStudents();
studentDataGrid.DataSource = studentList;
DataGridViewButtonColumn buttonColumn = new DataGridViewButtonColumn();
buttonColumn.Text = "Details";
buttonColumn.Name = "Details";
buttonColumn.UseColumnTextForButtonValue = true;
studentDataGrid.Columns.Add(buttonColumn);
studentDataGrid.CellContentClick += studentDataGrid_CellContentClick;
form0 = new Form0();
form0.MdiParent = this;
form0.StartPosition = FormStartPosition.Manual;
form0.Location = new Point(760, 10);
form0.Show();
}
private void studentDataGrid_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
var currentRow = studentDataGrid.CurrentRow;
(new StudentController()).SetStudentInfo((Student)currentRow.DataBoundItem);
form0.ShowStudentInfo();
}
public void UpdateStudentList()
{
studentList = (new StudentController()).GetStudents();
studentDataGrid.DataSource = studentList;
studentDataGrid.Refresh();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void addButton_Click(object sender, EventArgs e)
{
AddEditForm addEditForm = new AddEditForm();
addEditForm.ShowInsertFeatures();
Student student = new Student();
(new StudentController()).SetStudentInfo(student);
addEditForm.ShowDialog();
}
}
}