-
Notifications
You must be signed in to change notification settings - Fork 0
/
CityForm.cs
231 lines (184 loc) · 5.85 KB
/
CityForm.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
231
using System;
using System.Windows.Forms;
namespace WindowsFormsApp1
{
public partial class CityForm : Form
{
public CityForm()
{
InitializeComponent();
}
public City C;
private void button1_Click(object sender, EventArgs e)
{
try
{
C = new City
{
CityName = textBox1.Text,
NumberOfDistricts = int.Parse(textBox2.Text),
TimeZone = int.Parse(textBox3.Text),
Latitude = float.Parse(textBox5.Text),
Longitude = float.Parse(textBox4.Text),
Telcod = textBox6.Text,
Level = int.Parse(textBox7.Text),
Iso = int.Parse(textBox8.Text),
Vid = int.Parse(textBox9.Text),
Post = textBox10.Text,
Id = int.Parse(textBox11.Text)
};
Close();
}
catch { MessageBox.Show("Вы заполнили не все поля"); Close(); }
}
private void Form3_Load(object sender, EventArgs e)
{
}
private void textBox2_KeyPress_1(object sender, KeyPressEventArgs e)
{
var number = e.KeyChar;
if (!char.IsDigit(number) && number != 8)
{
e.Handled = true;
}
}
private void textBox3_KeyPress(object sender, KeyPressEventArgs e)
{
var number = e.KeyChar;
if (!char.IsDigit(number) && number != 8)
{
e.Handled = true;
}
}
private void textBox5_KeyPress(object sender, KeyPressEventArgs e)
{
var number = e.KeyChar;
if (!char.IsDigit(number) && number != 8)
{
e.Handled = true;
}
}
private void textBox4_KeyPress(object sender, KeyPressEventArgs e)
{
var number = e.KeyChar;
if (!char.IsDigit(number) && number != 8)
{
e.Handled = true;
}
}
public void WriteInForm()
{
textBox1.Text = C.CityName;
textBox2.Text = C.NumberOfDistricts.ToString();
textBox3.Text = C.TimeZone.ToString();
textBox5.Text = C.Latitude.ToString();
textBox4.Text = C.Longitude.ToString();
textBox6.Text = C.Telcod.ToString();
textBox7.Text = C.Level.ToString();
textBox8.Text = C.Iso.ToString();
textBox9.Text = C.Vid.ToString();
textBox10.Text = C.Post.ToString();
textBox11.Text = C.Id.ToString();
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
private void textBox7_TextChanged(object sender, EventArgs e)
{
}
private void textBox9_TextChanged(object sender, EventArgs e)
{
}
private void textBox7_KeyPress(object sender, KeyPressEventArgs e)
{
var number = e.KeyChar;
if (!char.IsDigit(number) && number != 8)
{
e.Handled = true;
}
}
private void textBox9_KeyPress(object sender, KeyPressEventArgs e)
{
var number = e.KeyChar;
if (!char.IsDigit(number) && number != 8)
{
e.Handled = true;
}
}
private void textBox5_TextChanged(object sender, EventArgs e)
{
}
private void textBox8_KeyPress(object sender, KeyPressEventArgs e)
{
var number = e.KeyChar;
if (!char.IsDigit(number) && number != 8)
{
e.Handled = true;
}
}
private void textBox4_TextChanged(object sender, EventArgs e)
{
}
private void textBox6_KeyPress(object sender, KeyPressEventArgs e)
{
var number = e.KeyChar;
if (!char.IsDigit(number) && number != 8)
{
e.Handled = true;
}
}
}
public class City
{
public string CityName;
public int NumberOfDistricts;
public int TimeZone;
public float Latitude;
public float Longitude;
public string Telcod;
public int Level;
public int Iso;
public int Vid;
public string Post;
public int Id;
public City(string cityName,
int numberOfDistricts,
int timeZone,
float latitude,
float longitude,
string telcod,
int level,
int iso,
int vid,
string post,
int id
)
{
this.CityName = cityName;
this.Id = id;
this.NumberOfDistricts = numberOfDistricts;
this.TimeZone = timeZone;
this.Latitude = latitude;
this.Longitude = longitude;
this.Telcod = telcod;
this.Level = level;
this.Iso = iso;
this.Vid = vid;
this.Post = post;
}
public City()
{
this.CityName = "";
this.Id = 0;
this.NumberOfDistricts = 0;
this.TimeZone = 0;
this.Latitude = 0;
this.Longitude = 0;
this.Telcod = "";
this.Level = 0;
this.Iso = 0;
this.Vid = 0;
this.Post = "";
}
}
}