-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDataEntry.cs
123 lines (114 loc) · 3.99 KB
/
DataEntry.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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Scheduling
{
public partial class DataEntry : Form
{
Form1 scheduleForm;
Schedule scheduler;
public int index = 1;
public DataEntry()
{
InitializeComponent();
scheduleForm = new Form1();
scheduleForm.Show();
}
private void btnAdd_Click(object sender, EventArgs e)
{
if (index == 1)
{
SchedulesList.totalArrival = 0;
scheduler = new Schedule(index, 0, (int)txtService.Value);
SchedulesList.schedules.Add(scheduler);
scheduler.setSchedule();
index++;
txtArrival.Minimum = txtArrival.Value + 1;
}
else if (index > 1)
{
SchedulesList.totalArrival += Convert.ToInt32(txtArrival.Value);
scheduler = new Schedule(index, Convert.ToInt32(txtArrival.Value), (int)txtService.Value);
SchedulesList.schedules.Add(scheduler);
scheduler.setSchedule();
index++;
txtArrival.Minimum = txtArrival.Value+1;
}
}
}
public static class SchedulesList
{
public static List<Schedule> schedules = new List<Schedule>();
public static int totalArrival { get; set; }
public static int lastEnd { get; set; }
}
public class Schedule
{
public Schedule(int jobNumber, int arrival, int service)
{
this.JobNumber = jobNumber;
this.InterArrival = arrival;
this.Service = service;
this.Arrival = SchedulesList.totalArrival;
// this.setArrival();
//this.setSchedule();
}
public int JobNumber { get; set; }
public int InterArrival { get; set; }
public int Arrival { get; set; }
public int Service { get; set; }
public int Start { get; set; }
public int End { get; set; }
public int Waiting { get; set; }
public int Idle { get; set; }
public int TimeInSystem { get; set; }
public void setSchedule()
{
if (this.JobNumber == 1)
{
this.Start = 0;
this.End = this.Service;
SchedulesList.lastEnd = this.End;
this.TimeInSystem = this.End - this.Arrival;
this.Waiting = 0;
this.Idle = 0;
}
else
{
if (this.Arrival == SchedulesList.lastEnd)
{
this.Start = SchedulesList.lastEnd;
this.End = this.Start + this.Service;
SchedulesList.lastEnd = this.End;
this.TimeInSystem = this.End - this.Arrival;
this.Waiting = 0;
this.Idle = 0;
}
else if (this.Arrival < SchedulesList.lastEnd)
{
this.Start = SchedulesList.lastEnd;
this.End = this.Start + this.Service;
SchedulesList.lastEnd = this.End;
this.TimeInSystem = this.End - this.Arrival;
this.Waiting = this.Start - this.Arrival;
this.Idle = 0;
}
else if (this.Arrival > SchedulesList.lastEnd)
{
this.Start = this.Arrival;
this.End = this.Start + this.Service;
this.Idle = this.Arrival - SchedulesList.lastEnd;
SchedulesList.lastEnd = this.End;
this.TimeInSystem = this.End - this.Arrival;
this.Waiting = 0;
}
}
}
}
}