/
u_AddUsers.aspx.cs
149 lines (139 loc) · 5.55 KB
/
u_AddUsers.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using yuenanGupiao.Bll;
using yuenanGupiao.Model;
using System.Web.Security;
public partial class u_AddUsers : System.Web.UI.Page
{
public string regName
{
get
{
if (this.ViewState["regName"] == null)
{
return "";
}
return this.ViewState["regName"].ToString();
}
set
{
this.ViewState["regName"] = value;
}
}
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Page_Load(object sender, EventArgs e)
{
if (this.Session["userName"] == null)
{
base.Response.Write("<script type='text/javascript'>window.location.href='index.aspx';</script>");
}
else if (this.Session["twoLogin"] == null)
{
this.Session["PostBack"] = base.Request.RawUrl;
base.Response.Write("<script type='text/javascript'>window.location.replace('TwoLogin.aspx');</script>");
}
else if (!base.IsPostBack)
{
string userName = "";
int num = 0;
try
{
userName = Convert.ToString(base.Request.QueryString["tn"]);
num = Convert.ToInt32(base.Request.QueryString["il"]);
}
catch
{
userName = "";
num = 0;
}
this.regName = this.Session["userName"].ToString();
UserData model = new UserDataManager().GetModel(this.regName);
Random random = new Random();
int num2 = random.Next(0x186a1, 0xf423f);
while (new UserDataManager().GetModel("cn" + num2.ToString()) != null)
{
num2 = random.Next(0x186a1, 0xf423f);
}
this.untx.Value = "cn" + num2.ToString();
this.rntx.Value = model.userName;
if (new UserDataManager().GetModel(userName) != null)
{
this.topTx.Value = userName;
}
this.RadioButtonList1.SelectedValue = num.ToString();
}
}
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void addUserBtn_Click(object sender, EventArgs e)
{
string bankAddr = this.bankAddr.Value.Trim();
string userName = this.untx.Value.Trim();
string password = this.pstx1.Value.Trim();
string str4 = this.pstx3.Value.Trim();
string refName = this.rntx.Value.Trim();
string selectedValue = this.DropDownList2.SelectedValue;
string bankNum = this.butx.Value.Trim();
string realName = this.realtx.Value.Trim();
string phone = this.phtx.Value.Trim();
string address = this.addtx.Value.Trim();
string zip = this.zipTx.Value.Trim();
string pid = this.pidTx.Value.Trim();
string qqNum = this.qqNumTx.Value.Trim();
string niCheng = this.niChengTx.Value.Trim();
int groupId = Convert.ToInt32(this.DropDownList1.SelectedValue);
int isLeft = Convert.ToInt32(this.RadioButtonList1.SelectedValue);
string topName = this.topTx.Value.Trim();
password = FormsAuthentication.HashPasswordForStoringInConfigFile(password, "MD5");
str4 = FormsAuthentication.HashPasswordForStoringInConfigFile(str4, "MD5");
int num3 = new UserDataManager().AddModel(userName, password, str4, address, pid, phone, selectedValue, bankNum, realName, refName, bankAddr, zip, qqNum, niCheng, topName, isLeft, groupId, this.regName, 1);
Random random = new Random();
int num4 = random.Next(0x186a1, 0xf423f);
while (new UserDataManager().GetModel("cn" + num4.ToString()) != null)
{
num4 = random.Next(0x186a1, 0xf423f);
}
switch (num3)
{
case 0:
this.Page.ClientScript.RegisterStartupScript(base.GetType(), "", "alert('数据库繁忙,请重试');", true);
return;
case 1:
this.untx.Value = "cn" + num4.ToString();
this.Page.ClientScript.RegisterStartupScript(base.GetType(), "", "alert('注册成功');window.location.href='u_dailiMark.aspx';", true);
return;
case 2:
this.untx.Value = "cn" + num4.ToString();
this.Page.ClientScript.RegisterStartupScript(base.GetType(), "", "alert('账号已存在');", true);
return;
case 3:
this.rntx.Value = "";
this.rntx.Focus();
this.Page.ClientScript.RegisterStartupScript(base.GetType(), "", "alert('推荐人不存在');", true);
return;
case 5:
this.topTx.Value = "";
this.topTx.Focus();
this.Page.ClientScript.RegisterStartupScript(base.GetType(), "", "alert('安置人不可用');", true);
return;
case 6:
this.Page.ClientScript.RegisterStartupScript(base.GetType(), "", "alert('所选分区已满');", true);
return;
case 7:
this.Page.ClientScript.RegisterStartupScript(base.GetType(), "", "alert('注册失败,请退出重新登录');", true);
return;
}
this.Page.ClientScript.RegisterStartupScript(base.GetType(), "", "alert('数据库繁忙,请重试');", true);
}
}