-
Notifications
You must be signed in to change notification settings - Fork 0
/
SignupControl.cs
180 lines (152 loc) · 6.49 KB
/
SignupControl.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
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
using MySql.Data.MySqlClient;
using Retweet_Done.Classes;
using System.Net;
using System.Net.Cache;
using System.Text.RegularExpressions;
using System.Globalization;
namespace Retweet_Done
{
public partial class SignupControl : UserControl
{
public SignupControl()
{
InitializeComponent();
}
public static DateTime GetNistTime()
{
var myHttpWebRequest = (HttpWebRequest)WebRequest.Create("http://www.microsoft.com");
var response = myHttpWebRequest.GetResponse();
string todaysDates = response.Headers["date"];
return DateTime.ParseExact(todaysDates,
"ddd, dd MMM yyyy HH:mm:ss 'GMT'",
CultureInfo.InvariantCulture.DateTimeFormat,
DateTimeStyles.AssumeUniversal);
}
private void SignupControl_Load(object sender, EventArgs e)
{
datetext.Text = Convert.ToString(GetNistTime());
}
public String Usertext
{
get { return usertext.Text; }
set { usertext.Text = value; }
}
public String Nametext
{
get { return nametext.Text; }
set { nametext.Text = value; }
}
public string Phonetext
{
get { return phonetext.Text; }
set { phonetext.Text = value; }
}
public String Passtext
{
get { return passtext1.Text; }
set { passtext1.Text = value; }
}
public String Twusertext
{
get { return twusertext.Text; }
set { twusertext.Text = value; }
}
public String Datetext
{
get { return datetext.Text; }
set { datetext.Text = value; }
}
public bool Checkbox
{
get { return checkboxsu.Checked; }
set { checkboxsu.Checked = value; }
}
private void phonetext_KeyPress(object sender, KeyPressEventArgs e)
{
if (!char.IsControl(e.KeyChar) && !char.IsDigit(e.KeyChar) &&
(e.KeyChar != '.'))
{
e.Handled = true;
}
// only allow one decimal point
if ((e.KeyChar == '.') && ((sender as TextBox).Text.IndexOf('.') > -1))
{
e.Handled = true;
}
}
private static Conn conn;
private void Nextsu_Click(object sender, EventArgs e)
{
if (String.IsNullOrEmpty(Usertext) || String.IsNullOrWhiteSpace(Passtext) || String.IsNullOrWhiteSpace(Twusertext) || String.IsNullOrWhiteSpace(Nametext) || String.IsNullOrWhiteSpace(Phonetext))
{
erorrmsg.Visible = true; erorrmsg.Text = "هناك حقول فارغة يرجى تعبئة جميع الحقول بمعلومات صحيحة";
}
else
{
if (checkboxsu.Checked == false)
{
erorrmsg.Visible = true; erorrmsg.Text = "يرجى الموافقة على بنود الخدمة وسياسة الخصوصية";
}
else
{
conn = new Conn();
try
{
conn.open();
string query = "select * from users where user ='" + Usertext + "'";
MySqlCommand cmd = new MySqlCommand(query, conn.maincon);
MySqlDataReader dataReader = cmd.ExecuteReader();
int count = 0;
while (dataReader.Read())
{
count = count + 1;
}
if (count == 1) { erorrmsg.Visible = true; erorrmsg.Text = "اسم المستخدم هذا بالفعل مسجل لدينا برجى المحاولة باسم مستخدم آخر"; }
else if (count > 1) { erorrmsg.Visible = true; erorrmsg.Text = "اسم المستخدم هذا بالفعل مسجل لدينا برجى المحاولة باسم مستخدم آخر"; }
else
{
dataReader.Close();
string query1 = "select * from twaccounts where twuser ='" + Twusertext + "'";
MySqlCommand cmd1 = new MySqlCommand(query1, conn.maincon);
MySqlDataReader dataReader1 = cmd1.ExecuteReader();
int count1 = 0;
while (dataReader1.Read())
{
count1 = count1 + 1;
}
if (count1 == 1) { erorrmsg.Visible = true; erorrmsg.Text = "حساب تويتر الذي تحاول التسجيل به موجود لدينا بالفعل !"; }
else if (count1 > 1) { erorrmsg.Visible = true; erorrmsg.Text = "حساب تويتر الذي تحاول التسجيل به موجود لدينا بالفعل !"; }
else
{
DateTime datereg = Convert.ToDateTime(Datetext);
Operations.RegUser(Nametext, Usertext, Passtext, Phonetext, datereg);
Operations.RegUserTw(Usertext, Twusertext, datereg);
ThankForReg uc = new ThankForReg();
if (!label1.Contains(uc))
{
this.Controls.Add(uc);
uc.Dock = DockStyle.Fill;
uc.BringToFront();
}
else { uc.BringToFront(); }
}
dataReader1.Close();
}
}
catch (Exception ex) { ex.Message.ToString(); }
finally { conn.close(); }
}
}
}
}
}