-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
efedcdb
commit 962ffe1
Showing
42 changed files
with
6,733 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.vs/ |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,152 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Windows.Forms; | ||
|
||
namespace Syareel | ||
{ | ||
public partial class Form1 : Form | ||
{ | ||
public Form1() | ||
{ | ||
InitializeComponent(); | ||
InitializeListViews(); | ||
} | ||
|
||
private void InitializeListViews() | ||
{ | ||
listViewTotalScores.Columns.Add("Name", 100); | ||
listViewTotalScores.Columns.Add("Total Score", 100); | ||
listViewTotalScores.View = View.Details; | ||
|
||
listViewPassingStudents.Columns.Add("Name", 100); | ||
listViewPassingStudents.View = View.Details; | ||
|
||
listViewTopStudents.Columns.Add("Name", 100); | ||
listViewTopStudents.Columns.Add("Total Score", 100); | ||
listViewTopStudents.View = View.Details; | ||
|
||
listViewCsv.View = View.Details; | ||
} | ||
|
||
private void buttonBrowse_Click(object sender, EventArgs e) | ||
{ | ||
using (OpenFileDialog openFileDialog = new OpenFileDialog()) | ||
{ | ||
openFileDialog.Filter = "CSV files (*.csv)|*.csv|All files (*.*)|*.*"; | ||
openFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); | ||
|
||
if (openFileDialog.ShowDialog() == DialogResult.OK) | ||
{ | ||
string filePath = openFileDialog.FileName; | ||
var students = ReadCsv(filePath); | ||
|
||
DisplayCsvContent(filePath); | ||
|
||
var studentScores = students.Select(s => new | ||
{ | ||
s.Name, | ||
TotalScore = s.MathScore + s.EnglishScore + s.ProgrammingScore | ||
}).ToList(); | ||
|
||
var passingStudents = students.Where(s => s.MathScore > 60 && s.EnglishScore > 60 && s.ProgrammingScore > 60) | ||
.Select(s => s.Name) | ||
.ToList(); | ||
|
||
var topStudents = studentScores.OrderByDescending(s => s.TotalScore) | ||
.Take(3) | ||
.ToList(); | ||
|
||
listViewTotalScores.Items.Clear(); | ||
foreach (var student in studentScores) | ||
{ | ||
var item = new ListViewItem(student.Name); | ||
item.SubItems.Add(student.TotalScore.ToString()); | ||
listViewTotalScores.Items.Add(item); | ||
} | ||
|
||
listViewPassingStudents.Items.Clear(); | ||
foreach (var student in passingStudents) | ||
{ | ||
var item = new ListViewItem(student); | ||
listViewPassingStudents.Items.Add(item); | ||
} | ||
|
||
listViewTopStudents.Items.Clear(); | ||
foreach (var student in topStudents) | ||
{ | ||
var item = new ListViewItem(student.Name); | ||
item.SubItems.Add(student.TotalScore.ToString()); | ||
listViewTopStudents.Items.Add(item); | ||
} | ||
} | ||
} | ||
} | ||
|
||
private void buttonReset_Click(object sender, EventArgs e) | ||
{ | ||
listViewTotalScores.Items.Clear(); | ||
listViewPassingStudents.Items.Clear(); | ||
listViewTopStudents.Items.Clear(); | ||
listViewCsv.Items.Clear(); | ||
listViewCsv.Columns.Clear(); | ||
} | ||
|
||
private List<Student> ReadCsv(string filePath) | ||
{ | ||
var students = new List<Student>(); | ||
var lines = File.ReadAllLines(filePath); | ||
|
||
foreach (var line in lines.Skip(1)) | ||
{ | ||
var values = line.Split(','); | ||
var student = new Student | ||
{ | ||
StudentId = int.Parse(values[0]), | ||
Name = values[1], | ||
MathScore = int.Parse(values[2]), | ||
EnglishScore = int.Parse(values[3]), | ||
ProgrammingScore = int.Parse(values[4]) | ||
}; | ||
students.Add(student); | ||
} | ||
|
||
return students; | ||
} | ||
|
||
private void DisplayCsvContent(string filePath) | ||
{ | ||
var lines = File.ReadAllLines(filePath); | ||
|
||
if (lines.Length > 0) | ||
{ | ||
var header = lines[0].Split(','); | ||
foreach (var column in header) | ||
{ | ||
listViewCsv.Columns.Add(column); | ||
} | ||
|
||
for (int i = 1; i < lines.Length; i++) | ||
{ | ||
var values = lines[i].Split(','); | ||
var item = new ListViewItem(values[0]); | ||
for (int j = 1; j < values.Length; j++) | ||
{ | ||
item.SubItems.Add(values[j]); | ||
} | ||
listViewCsv.Items.Add(item); | ||
} | ||
} | ||
} | ||
} | ||
|
||
public class Student | ||
{ | ||
public int StudentId { get; set; } | ||
public string Name { get; set; } | ||
public int MathScore { get; set; } | ||
public int EnglishScore { get; set; } | ||
public int ProgrammingScore { get; set; } | ||
} | ||
} |
Oops, something went wrong.