温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:商务维基网源码
当前文件:
MerchantViki/UserLogin.aspx.cs,打开代码结构图
MerchantViki/UserLogin.aspx.cs,打开代码结构图1using System; 2
using System.Data; 3
using System.Data.SqlClient; 4
using System.Configuration; 5
using System.Collections; 6
using System.Web; 7
using System.Web.Security; 8
using System.Web.UI; 9
using System.Web.UI.WebControls; 10
using System.Web.UI.WebControls.WebParts; 11
using System.Web.UI.HtmlControls; 12
13
public partial class SysConfigure : System.Web.UI.Page 14
{ 15
protected void Page_Load(object sender, EventArgs e) 16
{ 17
this.Header.Title = Application.Get("siteName") + "---" + this.Header.Title; 18
} 19
20
private string StringFilter(string inStr) 21
{ 22
string outStr; 23
outStr = inStr.Trim().Replace("\'", ""); 24
return outStr; 25
} 26
27
protected void UserLoginBtn_Click(object sender, EventArgs e) 28
{ 29
if (Page.IsValid) 30
{ 31
try 32
{ 33
string conStr = Application.Get("conStr").ToString(); 34
SqlConnection sqlCon = new SqlConnection(conStr); 35
sqlCon.Open(); 36
37
string unStr = StringFilter(userName.Text); 38
string pwdStr = StringFilter(pwd.Text); 39
string pwdMD5 = FormsAuthentication.HashPasswordForStoringInConfigFile(pwdStr,"MD5").ToString(); 40
41
string cmdStr = "select point from userInfo where name = '"+unStr+"' and pwd = '"+pwdMD5+"'"; 42
SqlCommand sqlCmd = new SqlCommand(cmdStr, sqlCon); 43
SqlDataReader sqlDR = sqlCmd.ExecuteReader(); 44
45
if (sqlDR.Read()) 46
{ 47
if (Session["userName"] != null) 48
Session["userName"] = unStr; 49
else 50
Session.Add("userName", unStr); 51
52
if (Session["userPoint"] != null) 53
Session["userPoint"] = sqlDR.GetValue(0).ToString(); 54
else 55
Session.Add("userPoint", sqlDR.GetValue(0).ToString()); 56
57
Response.Redirect("Default.aspx"); 58
} 59
else 60
{ 61
info.Text = "登陆错误!"; 62
} 63
64
sqlDR.Close(); 65
sqlCon.Close(); 66
} 67
catch (Exception ex) 68
{ 69
info.Text = "系统操纵错误:" + ex.Message; 70
} 71
} 72
} 73
} 74





}
}