-
Notifications
You must be signed in to change notification settings - Fork 41
/
Form3.cs
135 lines (118 loc) · 4.29 KB
/
Form3.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
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace MR_Corporation
{
public partial class Form3 : Form
{
public Form3()
{
InitializeComponent();
}
private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
if ((Keys)e.KeyChar == Keys.Enter)
{
string key = textBox1.Text;
if (key.Length != 7)
{
MessageBox.Show("Error. The number of digits must be 7. Please try again!");
return;
}
int[] tver = new int[7];
for (int i = 0; i < 7; i++)
try
{
tver[i] = int.Parse(key[i].ToString());
}
catch
{
MessageBox.Show("Error. All digits must be only numbers. Please try again.");
return;
}
string s = "";
if (tver[0] == 0) s += 0;
if (tver[0] == 1) s += 9;
if (tver[0] == 2) s += 8;
if (tver[0] == 3) s += 7;
if (tver[0] == 4) s += 6;
if (tver[0] == 5) s += 5;
if (tver[0] == 6) s += 4;
if (tver[0] == 7) s += 3;
if (tver[0] == 8) s += 2;
if (tver[0] == 9) s += 1;
/*The second bite*/
if (tver[1] == 0) s += 8;
if (tver[1] == 1) s += 7;
if (tver[1] == 2) s += 6;
if (tver[1] == 3) s += 5;
if (tver[1] == 4) s += 4;
if (tver[1] == 5) s += 3;
if (tver[1] == 6) s += 2;
if (tver[1] == 7) s += 1;
if (tver[1] == 8) s += 0;
if (tver[1] == 9) s += 9;
/*The third bite*/
if (tver[2] == 0) s += 7;
if (tver[2] == 1) s += 6;
if (tver[2] == 2) s += 5;
if (tver[2] == 3) s += 4;
if (tver[2] == 4) s += 3;
if (tver[2] == 5) s += 2;
if (tver[2] == 6) s += 1;
if (tver[2] == 7) s += 0;
if (tver[2] == 8) s += 9;
if (tver[2] == 9) s += 8;
/*The forth bite*/
if (tver[3] == 0) s += 2;
if (tver[3] == 1) s += 1;
if (tver[3] == 2) s += 0;
if (tver[3] == 3) s += 9;
if (tver[3] == 4) s += 8;
if (tver[3] == 5) s += 7;
if (tver[3] == 6) s += 6;
if (tver[3] == 7) s += 5;
if (tver[3] == 8) s += 4;
if (tver[3] == 9) s += 3;
/*The fifth bite*/
if (tver[4] == 0) s += 1;
if (tver[4] == 1) s += 0;
if (tver[4] == 2) s += 9;
if (tver[4] == 3) s += 8;
if (tver[4] == 4) s += 7;
if (tver[4] == 5) s += 6;
if (tver[4] == 6) s += 5;
if (tver[4] == 7) s += 4;
if (tver[4] == 8) s += 3;
if (tver[4] == 9) s += 2;
/*The sixth bite*/
if (tver[5] == 0) s += 2;
if (tver[5] == 1) s += 1;
if (tver[5] == 2) s += 0;
if (tver[5] == 3) s += 9;
if (tver[5] == 4) s += 8;
if (tver[5] == 5) s += 7;
if (tver[5] == 6) s += 6;
if (tver[5] == 7) s += 5;
if (tver[5] == 8) s += 4;
if (tver[5] == 9) s += 3;
/*The seventh bite*/
if (tver[6] == 0) s += 6;
if (tver[6] == 1) s += 5;
if (tver[6] == 2) s += 4;
if (tver[6] == 3) s += 3;
if (tver[6] == 4) s += 2;
if (tver[6] == 5) s += 1;
if (tver[6] == 6) s += 0;
if (tver[6] == 7) s += 9;
if (tver[6] == 8) s += 8;
if (tver[6] == 9) s += 7;
textBox2.Text = s;
}
}
}
}