温馨提示:代码在线浏览功能只能做为源码浏览参考,不能展示项目的全部,如果想更进一步了解该代码请下载:星幻短信群发平台Web源码
当前文件路径:XingHuanWebSms/SMS_Reg.aspx.cs

1using System; 2
using System.Data; 3
using System.Configuration; 4
using System.Collections; 5
using System.Web; 6
using System.Web.Security; 7
using System.Web.UI; 8
using System.Web.UI.WebControls; 9
using System.Web.UI.WebControls.WebParts; 10
using System.Web.UI.HtmlControls; 11
using DBLibrary; 12
using System.Text.RegularExpressions; 13
//该源码下载自www.51aspx.com(51aspx.com) 14
15
public partial class SMS_SMS_Reg : System.Web.UI.Page 16
{ 17
private DBLibrary.DBClass db = new DBClass(); 18
protected void Page_Load(object sender, EventArgs e) 19
{ 20
string flag = Request["ac"] == null ? "0" : Request["ac"].ToString().Trim(); 21
switch (flag) 22
{ 23
case "1": 24
SMS_Login(); 25
break; 26
case "2": 27
SMS_Reg(); 28
break; 29
case "3": 30
SMS_GetPassword(); 31
break; 32
case "4": 33
ExitLog(); 34
break; 35
} 36
} 37
38
private void ExitLog() 39
{ 40
Session["SMS_ID"] = null; 41
Session["SMS_NO"] = null; 42
Session["SMS_NAME"] = null; 43
Session["SMS_Grade"] = null; 44
Response.Write("<script>alert('退出成功!');window.close();window.parent.location='SMS_Reg.aspx';</script>"); 45
} 46
private void SMS_Login() 47
{ 48
string js = ""; 49
string mobile = Request["mob"] == null ? "" : Request["mob"].ToString().Trim(); 50
string password = Request["pwd"] == null ? "" : Request["pwd"].ToString().Trim(); 51
string code = Request["scode1"] == null ? "" : Request["scode1"].ToString().Trim(); 52
try 53
{ 54
if (Session["RandCode"].ToString().Trim() != code) 55
{ 56
Response.Write("<script>alert('验证码错误!请重新输入.');window.history.back();</script>"); 57
return; 58
} 59
if (mobile.ToString().Trim() == "" || (!isMobileNo(mobile.ToString().Trim()))) 60
{ 61
Response.Write("<script>alert('号码为空或者格式有误!请重新输入.');window.history.back();</script>"); 62
return; 63
} 64
} 65
catch 66
{ 67
Response.Redirect("SMS_Reg.aspx"); 68
} 69
System.Data.SqlClient.SqlParameter[] para = 70
{ 71
db.MakeInputParameter("@MobileNo",SqlDbType.NVarChar,50,mobile), 72
db.MakeInputParameter("@PassWord",SqlDbType.NVarChar,50,password), 73
}; 74
int nRet = 0; 75
DataTable dt =null; 76
try 77
{ 78
dt = db.RunProcedureForDataSet("SMS_Web_Login", para).Tables[0]; 79
if (dt == null || dt.Rows.Count<=0) 80
{ 81
js = "<script>alert('登陆失败,手机号或者密码输入错误!');window.history.back();</script>"; 82
Response.Write(js); 83
return; 84
} 85
86
} 87
catch(Exception ex) 88
{ 89
js = "<script>alert('登陆失败,系统出现异常!原因:"+ex.Message.ToString().Replace("'","\\'")+"');window.history.back();</script>"; 90
Response.Write(js); 91
return; 92
} 93
//登陆成功 94
Session["SMS_ID"] = dt.Rows[0]["id"].ToString().Trim(); 95
Session["SMS_NO"] = dt.Rows[0]["MobileNo"].ToString().Trim(); 96
Session["SMS_NAME"] = dt.Rows[0]["RealName"].ToString().Trim(); 97
Session["SMS_Grade"] = dt.Rows[0]["Grade"].ToString().Trim(); 98
Response.Redirect("wel.html"); 99
100
101
} 102
private void SMS_GetPassword() 103
{ 104
string js = ""; 105
string mobile = Request["mob3"] == null ? "" : Request["mob3"].ToString().Trim(); 106
string code = Request["scode3"] == null ? "" : Request["scode3"].ToString().Trim(); 107
try 108
{ 109
if (Session["RandCode2"].ToString().Trim() != code) 110
{ 111
Response.Write("<script>alert('验证码错误!请重新输入.');window.history.back();</script>"); 112
return; 113
} 114
if (mobile.ToString().Trim() == "" || (!isMobileNo(mobile.ToString().Trim()))) 115
{ 116
Response.Write("<script>alert('号码为空或者格式有误!请重新输入.');window.history.back();</script>"); 117
return; 118
} 119
} 120
catch 121
{ 122
Response.Redirect("SMS_Reg.aspx"); 123
} 124
125
System.Data.SqlClient.SqlParameter[] para = 126
{ 127
db.MakeInputParameter("@MobileNo",SqlDbType.NVarChar,50,mobile) 128
}; 129
try 130
{ 131
int ret = db.RunProcedureForInt("SMS_Web_GetPassWord", para); 132
if (ret == 0) //失败 133
{ 134
js = "<script>alert('没有找到此号码,操作失败!');window.history.back();</script>"; 135
} 136
else 137
{ 138
js = "<script>alert('操作成功.密码已发送,请耐心等待!');window.location='SMS_Reg.aspx';</script>"; 139
} 140
} 141
catch (Exception ex) 142
{ 143
js = "<script>alert('发送密码失败,出现异常!');window.location='SMS_Reg.aspx';</script>"; 144
} 145
Response.Write(js); 146
147
} 148
private bool isMobileNo(string no) 149
{ 150
if (no.Trim() == "10086") 151
{ 152
return true; 153
} 154
if (no.ToString().Trim().StartsWith("1")) 155
{ 156
if (!IsRegEx("(^15[3|8|9]{1}[0-9]{8}$)|(^13[0-9]{9}$)", no)) 157
{ 158
return false; 159
} 160
} 161
else if (no.ToString().Trim().StartsWith("0")) //小灵通 162
{ 163
if (!IsRegEx("^0[0-9]{10,11}$", no)) 164
{ 165
return false; 166
} 167
168
} 169
else 170
{ 171
return false; 172
} 173
return true; 174
} 175
private bool IsRegEx(string regExValue, string itemValue) 176
{ 177
178
try 179
{ 180
Regex regex = new System.Text.RegularExpressions.Regex(regExValue); 181
if (regex.IsMatch(itemValue)) 182
{ 183
return true; 184
} 185
else 186
{ 187
return false; 188
} 189
} 190
catch (Exception) 191
{ 192
return false; 193
} 194
finally 195
{ 196
} 197
} 198
private void SMS_Reg() 199
{ 200
string js=""; 201
string mobile = Request["mob2"] == null ? "" : Request["mob2"].ToString().Trim(); 202
string rname = Request["realname"] == null ? "" : Request["realname"].ToString().Trim(); 203
string code = Request["scode2"] == null ? "" : Request["scode2"].ToString().Trim(); 204
try 205
{ 206
if (Session["RandCode1"].ToString().Trim() != code) 207
{ 208
Response.Write("<script>alert('验证码错误!请重新输入.');window.history.back();</script>"); 209
return; 210
} 211
if (mobile.ToString().Trim() == "" || (!isMobileNo(mobile.ToString().Trim()))) 212
{ 213
Response.Write("<script>alert('号码为空或者格式有误!请重新输入.');window.history.back();</script>"); 214
return; 215
} 216
if (rname.Trim() == "") 217
{ 218
Response.Write("<script>alert('姓名不能为空!请重新输入.');window.history.back();</script>"); 219
return; 220
} 221
} 222
catch 223
{ 224
Response.Redirect("SMS_Reg.aspx"); 225
} 226
System.Data.SqlClient.SqlParameter[] para = 227
{ 228
db.MakeInputParameter("@MobileNo",SqlDbType.NVarChar,50,mobile), 229
db.MakeInputParameter("@RealName",SqlDbType.NVarChar,50,rname), 230
db.MakeInputParameter("@Reg_Ip",SqlDbType.NVarChar,50,Request.ServerVariables["REMOTE_ADDR"].ToString().Trim()) 231
}; 232
try 233
{ 234
int ret = db.RunProcedureForInt("SMS_Web_Register", para); 235
if (ret == 0) //失败 236
{ 237
js = "<script>alert('注册失败,真实姓名或者手机号已存在,请重新输入!');window.history.back();</script>"; 238
} 239
else 240
{ 241
js = "<script>alert('注册成功,密码以短信方式发送给您!');window.location='SMS_Reg.aspx';</script>"; 242
} 243
} 244
catch(Exception ex) 245
{ 246
js = "<script>alert('注册失败,出现异常!');window.location='SMS_Reg.aspx';</script>"; 247
} 248
Response.Write(js); 249
} 250
} 251





}
}