📄 index.aspx.cs
字号:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient; ///引入命名空间
public partial class IndexFrame_Main : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnOK_Click(object sender, EventArgs e)
{
if (Request.Cookies["CheckCode"] == null)
{
Response.Write("<script language=javascript>alert('您的浏览器设置已被禁用 Cookies,您必须设置浏览器允许使用 Cookies 选项后才能使用本系统。')</script>");
return;
}
if (this.CheckBox1.Checked)
{
if (String.Compare(Request.Cookies["CheckCode"].Value, txtCheckCode.Text.ToUpper(), true) != 0)
{
Response.Write("<script language=javascript>alert('验证码错误,请重新输入!')</script>");
return;
}
else
{
SqlConnection Con = new SqlConnection(ConfigurationManager.AppSettings["ConSQL"]);
Con.Open();
SqlCommand Com = new SqlCommand("select * from tb_User where UserName='" + this.txtName.Text + "' and PassWord='" + this.txtPwd.Text + "' and Popedom='0'", Con);
SqlDataReader dr = Com.ExecuteReader();
dr.Read();
if (dr.HasRows)
{
Session["UserName"] = dr["UserName"].ToString();
Session["Name"] = dr["Name"].ToString();
Session["PassWord"] = dr["PassWord"].ToString();
Session["Popedom"] = dr["Popedom"].ToString();
Session.Timeout = 100;
string cmdtxt = "INSERT INTO tb_LoginLog(UserName,LoginTime,LoginIP)";
cmdtxt += " VALUES('" + dr["UserName"].ToString() + "','" + DateTime.Now + "','" + Request.UserHostAddress + "')";
SqlData da = new SqlData();
da.ExceSQL(cmdtxt);
Response.Redirect("Module/Index.aspx");
}
else
{
Response.Write("<script language=javascript>alert('用户名或密码不正确!');</script>");
}
dr.Close();
}
}
else
{
if (String.Compare(Request.Cookies["CheckCode"].Value, txtCheckCode.Text.ToUpper(), true) != 0)
{
Response.Write("<script language=javascript>alert('验证码错误,请重新输入!')</script>");
return;
}
else
{
SqlConnection Con = new SqlConnection(ConfigurationManager.AppSettings["ConSQL"]);
Con.Open();
SqlCommand Com = new SqlCommand("select * from tb_User where UserName='" + this.txtName.Text + "' and PassWord='" + this.txtPwd.Text + "' and Popedom='1'", Con);
SqlDataReader dr = Com.ExecuteReader();
dr.Read();
if (dr.HasRows)
{
Session["UserName"] = dr["UserName"].ToString();
Session["Name"] = dr["Name"].ToString();
Session["PassWord"] = dr["PassWord"].ToString();
Session["Popedom"] = dr["Popedom"].ToString();
string cmdtxt = "INSERT INTO tb_LoginLog(UserName,LoginTime,LoginIP)";
cmdtxt += " VALUES('" + dr["UserName"].ToString() + "','" + DateTime.Now + "','" + Request.UserHostAddress + "')";
SqlData da = new SqlData();
da.ExceSQL(cmdtxt);
Response.Redirect("Module/Index.aspx");
}
else
{
Response.Write("<script language=javascript>alert('用户名或密码不正确!');</script>");
}
dr.Close();
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -