-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathForm1.cs
87 lines (72 loc) · 2.97 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
using System;
using System.Windows.Forms;
using System.Windows.Forms.DataVisualization.Charting;
namespace Scheduling
{
public partial class Form1 : Form
{
ListViewItem lvItem;
public Form1()
{
InitializeComponent();
lblCredits.Text = "Name: Student Name \n Student ID: Student's ID";
}
private void btnSchedule_Click(object sender, EventArgs e)
{
lvDisplay.Items.Clear();
chart1.Series.Clear();
chart1.Series.Add("Jobs");
float totalWaiting=0;
float totalTimeInSystem =0;
float totalService = 0;
foreach (var item in SchedulesList.schedules)
{
lvItem = new ListViewItem();
lvItem.Text = item.JobNumber.ToString();
lvItem.SubItems.Add(item.InterArrival.ToString());
lvItem.SubItems.Add(item.Arrival.ToString());
lvItem.SubItems.Add(item.Start.ToString());
lvItem.SubItems.Add(item.Service.ToString());
totalService += item.Service;
lvItem.SubItems.Add(item.End.ToString());
lvItem.SubItems.Add(item.Waiting.ToString());
totalWaiting += item.Waiting;
lvItem.SubItems.Add(item.TimeInSystem.ToString());
totalTimeInSystem += item.TimeInSystem;
lvItem.SubItems.Add(item.Idle.ToString());
lvDisplay.Items.Add(lvItem);
chart1.Series["Jobs"].Points.AddXY(item.JobNumber, item.End);
}
try
{
chart1.Series["Jobs"].ChartType =
SeriesChartType.Column;
chart1.Series["Jobs"].Color = System.Drawing.Color.Red;
totalWaiting /= SchedulesList.schedules.Count;
totalTimeInSystem /= SchedulesList.schedules.Count;
totalService /= SchedulesList.schedules[SchedulesList.schedules.Count - 1].End;
lblAWT.Text = "Average Waiting Time= " + totalWaiting.ToString("n2");
lblATS.Text = "Average Time in System= " + totalTimeInSystem.ToString("n2");
lblUtilization.Text = "Utilization is " + totalService.ToString("p2");
}
catch (Exception ex)
{
MessageBox.Show("Please do some jobs assigning before clicking Schedule\n");
}
}
private void btnClear_Click(object sender, EventArgs e)
{
lvDisplay.Items.Clear();
chart1.Series.Clear();
lblATS.Text = "";
lblAWT.Text = "";
lblUtilization.Text = "";
chart1.Series.Clear();
SchedulesList.schedules.Clear();
}
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
Environment.Exit(1);
}
}
}