/********一个登录按钮下的代码netwom********/
1 //--登录
2 if (String.Compare(Request.Cookies["CheckCode"].Value, this.tbxValidate.Text.Trim(), true) != 0) //这里判断验证码
3 {
4 Response.Write("<script>alert('您输入的验证码有误!');</script>");
5 }
6 else
7 {
8 try
9 {
10 string DEStr = NetwomTools.Safe.getMD5(this.tbxPwd.Text.Trim(),8,16);//通过加密函数加密用户密码
11 SqlParameter[] parameters =
12 {
13 new SqlParameter("@username", SqlDbType.NVarChar ),
14 new SqlParameter("@userpassword", SqlDbType.NVarChar )
15 };
16 parameters[0].Value = this.tbxUserName.Text;
17 parameters[1].Value = DEStr;
18 int i = (int)DataBase.CreateSqlComm("UserLogin", parameters).ExecuteScalar();
19
20 if (i == 1) // 登录成功
21 {
22 Session["user"] = this.tbxUserName.Text.Trim(); //用户登录成功后为其建立Session以供以后使用;
23 //--------此处建立COOKIE--------------------------------------------------------------
24
25 if (this.RadioButton1.Checked == true)
26 {
27 Tools.addCookie("www_WebPage_com", 1, "cName", this.tbxUserName.Text.Trim());
28 }
29 if (this.RadioButton2.Checked == true)
30 {
31 Tools.addCookie("www_WebPage_com", 2, "cName", this.tbxUserName.Text.Trim());
32 }
33 if (this.RadioButton3.Checked == true)
34 {
35 Tools.addCookie("www_WebPage_com", 3, "cName", this.tbxUserName.Text.Trim());
36 }
37 if (this.RadioButton4.Checked == true)
38 {
39 Tools.addCookie("www_WebPage_com", 5, "cName", this.tbxUserName.Text.Trim());
40 }
41 if (this.RadioButton5.Checked == true)
42 {
43 Tools.addCookie("www_WebPage_com", 6, "cName", this.tbxUserName.Text.Trim());
44 }
45
46 //----------------------------------------------------------------------------------
47
48 if (Session["userpage"] != null && Session["userpage"].ToString() != "")// 非首页登录时转到请求登录的页面
49 {
50 if (Session["userpage"].ToString() == HttpContext.Current.Request.Url.ToString())
51 {
52 Response.Write("<script>window.location.href='Default.aspx';</script>");
53 }
54 else
55 {
56 Response.Write("<script>window.location.href='" + Session["userpage"].ToString() + "';</script>");
57 }
58 }
59 else
60 {
61 Response.Write("<script>window.location.href='Default.aspx';</script>");
62 }
63 }
64 else
65 {
66 Response.Write("<script>alert('用户名或密码错误,请重新输入!');</script>");
67 }
68
69 }
70 catch (Exception Error)
71 {
72 File.WriteErrorLogTXT("ErrorTXT", Error.Message);
73 }
74 }
2 if (String.Compare(Request.Cookies["CheckCode"].Value, this.tbxValidate.Text.Trim(), true) != 0) //这里判断验证码
3 {
4 Response.Write("<script>alert('您输入的验证码有误!');</script>");
5 }
6 else
7 {
8 try
9 {
10 string DEStr = NetwomTools.Safe.getMD5(this.tbxPwd.Text.Trim(),8,16);//通过加密函数加密用户密码
11 SqlParameter[] parameters =
12 {
13 new SqlParameter("@username", SqlDbType.NVarChar ),
14 new SqlParameter("@userpassword", SqlDbType.NVarChar )
15 };
16 parameters[0].Value = this.tbxUserName.Text;
17 parameters[1].Value = DEStr;
18 int i = (int)DataBase.CreateSqlComm("UserLogin", parameters).ExecuteScalar();
19
20 if (i == 1) // 登录成功
21 {
22 Session["user"] = this.tbxUserName.Text.Trim(); //用户登录成功后为其建立Session以供以后使用;
23 //--------此处建立COOKIE--------------------------------------------------------------
24
25 if (this.RadioButton1.Checked == true)
26 {
27 Tools.addCookie("www_WebPage_com", 1, "cName", this.tbxUserName.Text.Trim());
28 }
29 if (this.RadioButton2.Checked == true)
30 {
31 Tools.addCookie("www_WebPage_com", 2, "cName", this.tbxUserName.Text.Trim());
32 }
33 if (this.RadioButton3.Checked == true)
34 {
35 Tools.addCookie("www_WebPage_com", 3, "cName", this.tbxUserName.Text.Trim());
36 }
37 if (this.RadioButton4.Checked == true)
38 {
39 Tools.addCookie("www_WebPage_com", 5, "cName", this.tbxUserName.Text.Trim());
40 }
41 if (this.RadioButton5.Checked == true)
42 {
43 Tools.addCookie("www_WebPage_com", 6, "cName", this.tbxUserName.Text.Trim());
44 }
45
46 //----------------------------------------------------------------------------------
47
48 if (Session["userpage"] != null && Session["userpage"].ToString() != "")// 非首页登录时转到请求登录的页面
49 {
50 if (Session["userpage"].ToString() == HttpContext.Current.Request.Url.ToString())
51 {
52 Response.Write("<script>window.location.href='Default.aspx';</script>");
53 }
54 else
55 {
56 Response.Write("<script>window.location.href='" + Session["userpage"].ToString() + "';</script>");
57 }
58 }
59 else
60 {
61 Response.Write("<script>window.location.href='Default.aspx';</script>");
62 }
63 }
64 else
65 {
66 Response.Write("<script>alert('用户名或密码错误,请重新输入!');</script>");
67 }
68
69 }
70 catch (Exception Error)
71 {
72 File.WriteErrorLogTXT("ErrorTXT", Error.Message);
73 }
74 }