/
formAcUserRegistration.cs
209 lines (200 loc) · 9.6 KB
/
formAcUserRegistration.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
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Pulsuz_Mesaj
{
public partial class formAcUserRegistration : Form
{
public formAcUserRegistration()
{
InitializeComponent();
}
private void btnClear_Click(object sender, EventArgs e)
{
cmbOperator.SelectedIndex = -1;
txtMobileNumber.Clear();
txtUsername.Clear();
txtPassword.Clear();
txtSign.Clear();
}
private void btnSubmit_Click(object sender, EventArgs e)
{
try
{
btnSubmit.Enabled = false;
this.Cursor = Cursors.WaitCursor;
string mobileOperator = (string)cmbOperator.SelectedItem;
string mobilNumberPrefix = (string)cmbMobileNumberPrefix.SelectedItem;
string mobileNumber = txtMobileNumber.Text.Trim();
string username = txtUsername.Text.Trim();
string password = txtPassword.Text.Trim();
string sign = txtSign.Text.Trim();
bool hasError = false;
if (mobileNumber.Length != 7)
{
hasError = true;
MessageBox.Show("Mobil nömrənizi düzgün daxil etmədiniz!\nNömrə 7 rəqəmli olmalıdır",
"Xəbərdarlıq",
MessageBoxButtons.OK,
MessageBoxIcon.Warning);
}
else
{
if (!hasError)
{
switch (mobileOperator)
{
case "Bakcell":
Bakcell bk = new Bakcell();
bk.UserName = username;
bk.Password = password;
bk.Login();
if (bk.SuccessLogin)
{
//heqiqetende bele istifadeci var
hasError = false;
}
else
{
//Bakcell de bele istifadeci yoxdur
hasError = true;
//Bakcell de bele istifadeci yoxdur
MessageBox.Show("Bakcell -də daxil etdiyniz istifadəçi adı və şifrə \n" +
"kombinasiyasına uyğun məlumat tapılmadı!",
"Xəbərdarlıq",
MessageBoxButtons.OK,
MessageBoxIcon.Warning);
}
break;
case "Azercell":
Azercell az = new Azercell();
az.LoginPrefix = mobilNumberPrefix;
az.UserName = mobileNumber;
az.Password = password;
az.Login();
if (az.SuccessLogin)
{
//heqiqetende bele istifadeci var
hasError = false;
}
else
{
//Bakcell de bele istifadeci yoxdur
hasError = true;
//Azercell de bele istifadeci yoxdur
MessageBox.Show("Azercell-də daxil etdiyniz istifadəçi adı və şifrə \n" +
"kombinasiyasına uyğun məlumat tapılmadı!",
"Xəbərdarlıq",
MessageBoxButtons.OK,
MessageBoxIcon.Warning);
}
break;
default:
//opertaor secmeyende
hasError = true;
MessageBox.Show("Operator seçməlisiniz! \n",
"Xəbərdarlıq",
MessageBoxButtons.OK,
MessageBoxIcon.Warning);
break;
}
}
if (!hasError)
{
//yuxaridaki yoxlamadan sonra da sehv olmadigina gore
//melumatlari sistemin bazasina gonderirik
AutoCongratulate ac = new AutoCongratulate();
Pulsuz_Mesaj.AutoCongratulateServices.UserObject user = new Pulsuz_Mesaj.AutoCongratulateServices.UserObject();
user.mobileOperator = mobileOperator;
user.username = username;
user.password = password;
user.phoneNumber = mobilNumberPrefix + mobileNumber;
user.sign = sign;
int result = ac.createUser(user);
if (result == 1)//yeni ugurla yaradildisa
{
//yeni bazaya ugurla yazildi=istifadeci yaradildi
MessageBox.Show("Təbriklər, siz uğurla qeydiyyatdan keçdiniz\n",
"Məlumat",
MessageBoxButtons.OK,
MessageBoxIcon.Information);
}
//bu nomre artiq sistemde qydiyyatdan kecib
else if (result == -1)
{
MessageBox.Show("Daxil etdiyiniz nömrəyə uyğun istifadəçi artıq sistemdə mövcuddur! \n" +
"Əgər şifrəni unutmuşsunuzsa \"Şifrəni xatırla\" düyməsinə sıxın",
"Xəbərdarlıq",
MessageBoxButtons.OK,
MessageBoxIcon.Warning);
}
//bele istifadeci movcuddur
else if (result == -2)
{
MessageBox.Show("Daxil etdiyiniz istifadəçi adı artıq sistemdə mövcuddur! \n" +
"Zəhmət olmasa fərqli istifadəçi adı seçin!",
"Xəbərdarlıq",
MessageBoxButtons.OK,
MessageBoxIcon.Warning);
}
else
{
//bazaya yazilma ile elaqeli sehv bas verdi, yada nese basqa anlasilmaz bir sehv
MessageBox.Show("Sorğunun icrası ilə əlaqəli səhv baş verdi! \n" +
"Zəhmət olmasa bir az sonra yenidən yoxlayın",
"Xəbərdarlıq",
MessageBoxButtons.OK,
MessageBoxIcon.Warning);
}
}//if !hasRrror
}
}
catch
{
MessageBox.Show("Səhv baş verdi! \n",
"Xəbərdarlıq",
MessageBoxButtons.OK,
MessageBoxIcon.Warning);
}
finally
{
this.Cursor = Cursors.Default;
btnSubmit.Enabled = true;
}
}
private void btnClose_Click(object sender, EventArgs e)
{
this.Close();
}
private void txtMobileNumber_Leave(object sender, EventArgs e)
{
//azercell de istifadeci adi nore olur adeten ona gore rehatladiraq userin isini biraz
if ((string)cmbOperator.SelectedItem == "Azercell")
{
txtUsername.Text = (string)cmbMobileNumberPrefix.SelectedItem + txtMobileNumber.Text;
}
}
private void cmbOperator_SelectedIndexChanged(object sender, EventArgs e)
{
ComboBox.ObjectCollection rows = new ComboBox.ObjectCollection(cmbMobileNumberPrefix);
rows.Clear();
if (cmbOperator.SelectedItem.ToString() == "Bakcell")
{
//bakcell de prefix yalniz bir denedir
rows.Add("55");
cmbMobileNumberPrefix.SelectedItem = "55";
}
else
{
rows.Add("50");
rows.Add("51");
cmbMobileNumberPrefix.SelectedItem = "50";
}
}
}
}