admin_login.aspx.cs
来自「企业网站前台后台源程序,用于大中小型企业网站后台程序开发」· CS 代码 · 共 131 行
CS
131 行
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using BLL;
using Socut.Data;
namespace Websystem.admin
{
/// <summary>
/// admin_login 的摘要说明。
/// </summary>
public class admin_login : System.Web.UI.Page
{
public string str = "";
public string outurl = "admin_login.aspx";
public string gourl = "administrator.aspx";
protected System.Web.UI.WebControls.Image imgCode;
private void Page_Load(object sender, System.EventArgs e)
{
other chk = new other();
if (chk.isDefined("out"))
{
chk.logout(outurl);
}
if (this.IsPostBack)
{
chklogin();
}
}
public void chklogin()
{
string name="";
string pass = "";
string sql = "";
if (System.Web.HttpContext.Current.Request.Cookies["CheckCode"] == null)
{
str = " showalert('警告','验证码已经超时,请重新刷新页面!');";
}
else if (System.Web.HttpContext.Current.Request.Cookies["CheckCode"].Value != Request["chkcode"])
{
str = " showalert('警告','验证码已经超时,请重新刷新页面!');";
}
else
{
System.Web.HttpContext.Current.Response.Cookies["CheckCode"].Value = null;
other chk = new other();
if (chk.isDefined("u_id"))
{
name = Request.Form["u_id"].ToString().Trim();
}
if (chk.isDefined("u_pas"))
{
pass = Request.Form["u_pas"].ToString().Trim();
}
DataSet ds = new DataSet();
CData myData = new CData();
sql = "select id from [user] where ";
sql += "login_name='"+name+"' and ";
sql += "login_pass='" + pass + "' ";
ds = myData.GetDataSet(sql,0,0,"后台登陆");
if (ds != null && ds.Tables["后台登陆"].Rows.Count > 0)
{
Session["u_id"] = ds.Tables["后台登陆"].Rows[0][0].ToString();
Response.Redirect(gourl);
}
else
{
str = " showalert('警告','你的用户名或者密码错误,请重新输入!');";
}
}
}
#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?