private void ImportSchedule_Click(object sender, EventArgs e) { Classes.Enabled = false; Subjects.Enabled = false; listViewInfo = ListViewInfo.Schedule; if (openFileDialog.ShowDialog() == DialogResult.OK) { StudentServices service = new StudentServices(); var Data = service.GetDataFromFile(openFileDialog.FileName); _Id.Text = "Subject ID"; _Id.Width = 220; _Name.Text = "Subject name"; _Name.Width = 440; _Info1.Text = "Room"; _Info1.Width = 220; listView.Items.Clear(); listView.Columns.Clear(); listView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { _No, _Id, _Name, _Info1 }); NotiLabel.Text = $"Press 'Import' button to import the schedule below to class '{Data[0].Id}'."; currClass = Data[0].Id; Data.RemoveAt(0); BindDataToListView(Data); listView.View = View.Details; FileData = Data; ImportButton.Enabled = true; EditButton.Enabled = false; } }
private void ViewStudents_Click(object sender, EventArgs e) { NotiLabel.Text = ""; Classes.Enabled = true; Subjects.Enabled = true; EditButton.Enabled = false; listViewInfo = ListViewInfo.Students; _Id.Text = "Student ID"; _Id.Width = 150; _Name.Text = "Student name"; _Name.Width = 175; _Info1.Text = "Class"; _Info1.Width = 125; _Info2.Text = "Date of Birth"; _Info2.Width = 155; _Info3.Text = "Gender"; _Info3.Width = 125; _Info4.Text = "Identify Card No."; _Info4.Width = 150; listView.Items.Clear(); listView.Columns.Clear(); listView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { _No, _Id, _Name, _Info1, _Info2, _Info3, _Info4 }); try { StudentServices service = new StudentServices(); var Data = service.GetStudentsFromDB(Classes.SelectedItem.ToString(), Subjects.SelectedItem.ToString()); BindDataToListView(Data); } catch (Exception ex) { MessageBox.Show(ex.Message); } if (listView.Items.Count == 0) { NotiLabel.Text = "Nothing is found..."; } listView.View = View.Details; }
private void ViewSchedule_Click(object sender, EventArgs e) { NotiLabel.Text = ""; EditButton.Enabled = false; Classes.Enabled = true; ComboBoxChangeable = false; Subjects.Enabled = false; Subjects.SelectedIndex = 0; ComboBoxChangeable = true; listViewInfo = ListViewInfo.Schedule; _Id.Text = "Subject ID"; _Id.Width = 180; _Name.Text = "Class"; _Name.Width = 180; _Info1.Text = "Subject"; _Info1.Width = 340; _Info2.Text = "Room"; _Info2.Width = 180; listView.Items.Clear(); listView.Columns.Clear(); listView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { _No, _Id, _Name, _Info1, _Info2 }); try { StudentServices service = new StudentServices(); var Data = service.GetScheduleFromDB(Classes.SelectedItem.ToString(), Subjects.SelectedItem.ToString()); BindDataToListView(Data); } catch (Exception ex) { MessageBox.Show(ex.Message); } if (listView.Items.Count == 0) { NotiLabel.Text = "Nothing is found..."; } listView.View = View.Details; }
private void ImportScore_Click(object sender, EventArgs e) { Classes.Enabled = false; Subjects.Enabled = false; listViewInfo = ListViewInfo.Scoreboard; if (openFileDialog.ShowDialog() == DialogResult.OK) { StudentServices service = new StudentServices(); var Data = service.GetDataFromFile(openFileDialog.FileName); _Id.Text = "Student ID"; _Id.Width = 170; _Name.Text = "Student name"; _Name.Width = 210; _Info1.Text = "Mid-term score"; _Info1.Width = 125; _Info2.Text = "Final-term score"; _Info2.Width = 125; _Info3.Text = "Other score"; _Info3.Width = 125; _Info4.Text = "Final score"; _Info4.Width = 125; listView.Items.Clear(); listView.Columns.Clear(); listView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { _No, _Id, _Name, _Info1, _Info2, _Info3, _Info4 }); NotiLabel.Text = $"Press 'Import' button to import the '{Data[0].Name}' scoreboard below for class '{Data[0].Id}'."; currClass = Data[0].Id; currSubject = Data[0].Name; Data.RemoveAt(0); BindDataToListView(Data); listView.View = View.Details; FileData = Data; ImportButton.Enabled = true; EditButton.Enabled = false; } }
private void ImportClass_Click(object sender, EventArgs e) { Classes.Enabled = false; Subjects.Enabled = false; listViewInfo = ListViewInfo.Students; if (openFileDialog.ShowDialog() == DialogResult.OK) { _Id.Text = "Student ID"; _Id.Width = 170; _Name.Text = "Student name"; _Name.Width = 200; _Info1.Text = "Gender"; _Info1.Width = 170; _Info2.Text = "Identify Card No."; _Info2.Width = 170; _Info3.Text = "Date of Birth"; _Info3.Width = 170; listView.Items.Clear(); listView.Columns.Clear(); listView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { _No, _Id, _Name, _Info1, _Info2, _Info3 }); StudentServices service = new StudentServices(); var Data = service.GetDataFromFile(openFileDialog.FileName); NotiLabel.Text = $"Press 'Import' button to import these students below to class '{Data[0].Id}'."; currClass = Data[0].Id; Data.RemoveAt(0); BindDataToListView(Data); listView.View = View.Details; FileData = Data; ImportButton.Enabled = true; EditButton.Enabled = false; } }
private void ViewScore_Click(object sender, EventArgs e) { NotiLabel.Text = ""; EditButton.Enabled = true; Classes.Enabled = true; Subjects.Enabled = true; listViewInfo = ListViewInfo.Scoreboard; _Id.Text = "Student ID"; _Id.Width = 110; _Name.Text = "Student name"; _Name.Width = 190; _Info1.Text = "Class"; _Info1.Width = 90; _Info2.Text = "Subject ID"; _Info2.Width = 110; _Info3.Text = "Mid-term"; _Info3.Width = 80; _Info4.Text = "Final-term"; _Info4.Width = 80; _Info5.Text = "Other score"; _Info5.Width = 80; _Info6.Text = "Final score"; _Info6.Width = 80; _Info7.Text = "Pass"; _Info7.Width = 60; listView.Items.Clear(); listView.Columns.Clear(); listView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { _No, _Id, _Name, _Info1, _Info2, _Info3, _Info4, _Info5, _Info6, _Info7 }); try { StudentServices service = new StudentServices(); var Data = service.GetScoreboardFromDB(Classes.SelectedItem.ToString(), Subjects.SelectedItem.ToString()); int pass = 0; foreach (var data in Data) { if (data.Info[6] == "Yes") { pass++; } } BindDataToListView(Data); if (Classes.SelectedItem.ToString() != "All" && Subjects.SelectedItem.ToString() != "All") { NotiLabel.Text = $"There are {pass} student(s) ({((float) pass / (float) Data.Count).ToString("p")}) " + $"of class {Classes.SelectedItem.ToString()} passed this subject."; } } catch (Exception ex) { MessageBox.Show(ex.Message); } if (listView.Items.Count == 0) { NotiLabel.Text = "Nothing is found..."; } listView.View = View.Details; }