-
Notifications
You must be signed in to change notification settings - Fork 0
/
JE_SignInToApply.aspx.cs
216 lines (186 loc) · 7.34 KB
/
JE_SignInToApply.aspx.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
using MyProject.BLL;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Security.Cryptography;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace MyProject
{
public partial class JE_SignInToApply : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
bool IsValidEmail(string email)
{
try
{
var addr = new System.Net.Mail.MailAddress(email);
return addr.Address == email;
}
catch
{
return false;
}
}
private bool ValidateInput()
{
lbErrorName.Text = String.Empty;
lbErrorMobile.Text = String.Empty;
lbErrorEmail.Text = String.Empty;
lbErrorTick.Text = String.Empty;
lbErrorExist.Text = String.Empty;
if (tbFirstName.Text == "")
{
lbErrorName.Text += "First name is required!" + "<br/>";
lbErrorName.ForeColor = Color.Red;
}if (String.IsNullOrEmpty(tbLastName.Text))
{
lbErrorName.Text += "Last Name is required!" + "<br/>";
lbErrorName.ForeColor = Color.Red;
}
bool result;
int mobile;
if (String.IsNullOrEmpty(tbMobile.Text))
{
lbErrorMobile.Text += "Mobile Number is required!" ;
lbErrorMobile.ForeColor = Color.Red;
}
else
{
result = int.TryParse(tbMobile.Text, out mobile);
if (!result)
{
lbErrorMobile.Text += "Please enter a valid Mobile Number!" ;
lbErrorMobile.ForeColor = Color.Red;
}
else
{
if (tbMobile.Text.Length!=8)
{
lbErrorMobile.Text += "Please enter a valid Mobile Number!";
lbErrorMobile.ForeColor = Color.Red;
}
//else
//{
// if(tbMobile.Text[0]= )
//}
}
}
if (String.IsNullOrEmpty(tbEmail.Text))
{
lbErrorEmail.Text += "Email is required!" ;
lbErrorEmail.ForeColor = Color.Red;
}
else
{
if (IsValidEmail(tbEmail.Text) == false)
{
lbErrorEmail.Text += "Please enter a valid Email!" ;
lbErrorEmail.ForeColor = Color.Red;
}
}
if (cbTick.Checked == false)
{
lbErrorTick.Text += "Please Tick" ;
lbErrorTick.ForeColor = Color.Red;
}
if (String.IsNullOrEmpty(lbErrorEmail.Text)&& String.IsNullOrEmpty(lbErrorMobile.Text)&& String.IsNullOrEmpty(lbErrorName.Text) && String.IsNullOrEmpty(lbErrorTick.Text))
{
return true;
}
else
{
return false;
}
}
public string Get10Digits()
{
var bytes = new byte[10];
var rng = RandomNumberGenerator.Create();
rng.GetBytes(bytes);
uint random = BitConverter.ToUInt32(bytes, 0) % 100000000;
return String.Format("{0:D10}", random);
}
public string Get6Digits()
{
Random r = new Random();
var random = r.Next(100000, 999999);
return String.Format("{0:D6}", random);
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
JE_TourGuideInfo TG = new JE_TourGuideInfo();
SMSSvrRef.SMSSoapClient S = new SMSSvrRef.SMSSoapClient();
if (TG.GetTGByEmail(tbEmail.Text) != null)
{
lbErrorExist.Text = "Record already exists!";
lbErrorExist.ForeColor = Color.Red;
}
else
{
if (ValidateInput())
{
var id = DateTime.Now.ToString("MMddyyyyHHmmss") + Get10Digits();
var name = tbLastName.Text +" "+ tbFirstName.Text;
TG = new JE_TourGuideInfo(id,name,tbFirstName.Text, tbLastName.Text, tbMobile.Text, tbEmail.Text,null,null,null,null,null,null,null,null,null,null,null,null,null,null);
int result = TG.AddTG();
if (result == 1)
{
Session["SSTGName"] = tbLastName.Text+" "+ tbFirstName.Text;
Session["SSTGEmail"] = tbEmail.Text;
Session["SSTGMobile"] = tbMobile.Text;
Session["SSTGOTP"] = Get6Digits();
var message = "Your OTP is " + Session["SSTGOTP"].ToString() + " for you to continue to apply as a Tour guide.";
//string display = S.sendMessage("EA02", "609000", Session["SSTGMobile"].ToString(), message );
//var mdlPopup = $find('MODALPOPUPBEHAVIORID');
//if (mdlPopup)
//{
// mdlPopup.show();
// return false;
//}
Response.Redirect("JE_OTP.aspx");
// ClientScript.RegisterStartupScript(this.GetType(), "Popup", "ShowPopup('hello');", true);
}
}
else
{
lbErrorExist.Text = "Error in adding record! Inform System Administrator!";
lbErrorExist.ForeColor = Color.Red;
}
}
}
protected void btntry_Click(object sender, EventArgs e)
{
}
}
//protected void btnSubmitOTP_Click(object sender, EventArgs e)
//{
// //lbError.Text = String.Empty;
// //if (tbOTP.Text == Session["SSTGOTP"].ToString())
// //{
// // Response.Redirect("JE_ApplicationForm.aspx");
// //}
// //if (Session["SSTGOTP"].ToString() == "-1")
// //{
// // lbError.Text = "Your OTP have expired!";
// // lbError.ForeColor = Color.Red;
// //}
// //if (tbOTP.Text != Session["SSTGOTP"].ToString() && tbOTP.Text != "-1")
// //{
// // lbError.Text = "Wrong OTP!";
// // lbError.ForeColor = Color.Red;
// //}
//}
//protected void btnSubmitOTP0_Click(object sender, EventArgs e)
//{
// Response.Redirect("JE_ApplicationForm.aspx");
//}
//protected void btntry_Click(object sender, EventArgs e)
//{
//}
}
//}