/
Branch.cs
230 lines (196 loc) · 7.38 KB
/
Branch.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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
using System;
using System.Collections;
using System.Linq;
using System.Text;
namespace WindowsFormsApplication1
{
class Branch
{
//Local Variables of <branch> class
private string branchID;
private string branchNickname;
private string branchAddressNo;
private string branchAddressStreet;
private string branchAddressCity;
private string branchAddressCounty;
private string branchAddressPostCode;
private string nearestBranch1;
private string nearestBranch2;
private string nearestBranch3;
//int[] nearestBranches;
private int noCategories;
ArrayList branchCategories;
///////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////
//<branch> Constructor
public void branch(string inBranchID, string inBranchNickname, string inBranchAddressNo,
string inBranchAddressStreet, string inBranchAddressCity, string inBranchAddressCounty,
string inBranchAddressPostCode, string inNearestBranch1,
string inNearestBranch2, string inNearestBranch3, int inNoCategories)
{
branchID = inBranchID;
branchNickname = inBranchNickname;
branchAddressNo = inBranchAddressNo;
branchAddressStreet = inBranchAddressStreet;
branchAddressCity = inBranchAddressCity;
branchAddressCounty = inBranchAddressCounty;
branchAddressPostCode = inBranchAddressPostCode;
nearestBranch1 = inNearestBranch1;
nearestBranch2 = inNearestBranch2;
nearestBranch3 = inNearestBranch3;
//setNearestBranches(nearestBranch1, nearestBranch2, nearestBranch3);
setNoCategories(inNoCategories);
branchCategories = new ArrayList();
}
///////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////
//<branch> class getter methods
public string getBranchID()
{
return branchID;
}
public string getBranchAddressNo()
{
return branchAddressNo;
}
public string getBranchAddressStreet()
{
return branchAddressStreet;
}
public string getBranchAddressCity()
{
return branchAddressCity;
}
public string getBranchAddressCounty()
{
return branchAddressCounty;
}
public string getBranchAddressPostCode()
{
return branchAddressPostCode;
}
//getter method for array of closest branch ids
/*public int[] getNearestBranches()
{
return nearestBranches;
}*/
public string getNearestBranch1()
{
return nearestBranch1;
}
public string getNearestBranch2()
{
return nearestBranch2;
}
public string getNearestBranch3()
{
return nearestBranch3;
}
public int getNoCategories()
{
return noCategories;
}
///////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////
//<branch> class setter methods
public void setBranchID(string inBranchID)
{
try
{
branchID = inBranchID; //convert local variable to global variable, and save it
}
catch (FormatException e)
{
System.Windows.Forms.MessageBox.Show("ERROR: " + e.Message + " please enter a valid integer (for Branch IDs)");
}
}
public void setBranchNickname(string inBranchNickname)
{
branchNickname = inBranchNickname;
}
public void setBranchAddressNo(string inBranchAddressNo)
{
branchAddressNo = inBranchAddressNo;
}
public void setBranchAddressStreet(string inBranchAddressStreet)
{
branchAddressStreet = inBranchAddressStreet;
}
public void setBranchAddressCity(string inBranchAddressCity)
{
branchAddressCity = inBranchAddressCity;
}
public void setBranchAddressCounty(string inBranchAddressCounty)
{
branchAddressCounty = inBranchAddressCounty;
}
public void setBranchAddressPostCode(string inBranchAddressPostCode)
{
branchAddressPostCode = inBranchAddressPostCode;
}
public void setNearestBranch1(string inNearestBranch1)
{
try
{
nearestBranch1 = inNearestBranch1; //convert local variable to global variable, and save it
}
catch (FormatException e)
{
System.Windows.Forms.MessageBox.Show("ERROR: " + e.Message + " please enter a valid integer (for Branch IDs)");
}
}
public void setNearestBranch2(string inNearestBranch2)
{
try
{
nearestBranch2 = inNearestBranch2; //convert local variable to global variable, and save it
}
catch (FormatException e)
{
System.Windows.Forms.MessageBox.Show("ERROR: " + e.Message + " please enter a valid integer (for Branch IDs)");
}
}
public void setNearestBranch3(string inNearestBranch3)
{
try
{
nearestBranch3 = inNearestBranch3; //convert local variable to global variable, and save it
}
catch (FormatException e)
{
System.Windows.Forms.MessageBox.Show("ERROR: " + e.Message + " please enter a valid integer (for Branch IDs)");
}
}
//setter method for array of get nearest branch ids
/*public void setNearestBranches(int[] inNearestBranches)
{
inNearestBranches[0] =
}*/
public void setNoCategories(int inNoCategories)
{
try
{
noCategories = Convert.ToInt32(inNoCategories);
}
catch (FormatException e)
{
System.Windows.Forms.MessageBox.Show("ERROR: " + e.Message + " please enter a valid integer (for number of categories)");
}
}
///////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////
//Add branch to main array of branches
public void addBranchToMainArgus(Branch tempBranch)
{
frmMainBranch mainArray = new frmMainBranch();
mainArray.mainArgus.Add(tempBranch);
}
///////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////
//Add category to branch
public void addCategoryToBranch(Category tempCategory)
{
branchCategories.Add(tempCategory);
}
}
}