📄 login.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;
using RWSB.DatabaseOper;
public partial class gddl : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btn_Login_Click(object sender, ImageClickEventArgs e)
{
try
{
RWSB.DatabaseOper.DatabaseConnect dc = new DatabaseConnect();
string userName = this.txtUserName.Text.Trim();
string passWord = this.txtPwd.Text.Trim();
string userid = null;
System.Data.DataSet oDataSet = dc.getBinding("SELECT id, username, password, (SELECT rolename FROM roles WHERE roleid = qxid) AS UG,qxid,cjmc,(SELECT showorder FROM ExigenceDegree WHERE ExigenceDegree.id = cjsn) AS CJOD, cjsn FROM users WHERE UserName='" + userName + "' and passWord='" + passWord + "'", "ttt");
if (oDataSet.Tables[0].Rows.Count > 0)
{
userid = oDataSet.Tables[0].Rows[0][0].ToString();
Session["UserName"] = userName;
//用户的id号
Session["userID"] = userid;
Session["passWord"] = passWord;
//用户权限名称
Session["UserGrade"] = oDataSet.Tables[0].Rows[0][3].ToString();
//用户权限id
Session["userqxid"] = oDataSet.Tables[0].Rows[0][4];
//用户所在部门名称
Session["userbmmc"] = oDataSet.Tables[0].Rows[0][5].ToString();
//用户所在部门的显示序号
Session["userbmorder"] = oDataSet.Tables[0].Rows[0][6];
//用户所在部门的id号
Session["userbmid"] = oDataSet.Tables[0].Rows[0][7];
//string address = Request.UserHostAddress;
System.Web.Security.FormsAuthentication.SetAuthCookie(userid, false);
Page.RegisterStartupScript("", "<script> win_close();</script>");
//if (Request.QueryString["url"] != null)
//{
// this.Response.Redirect(Request.QueryString["url"].ToString());
// }
// else
// {
this.Response.Redirect("default.aspx");
// }
}
else
{
Response.Write("<script>alert('用户名或密码错误!');</script>");
}
}
catch (Exception)
{
Response.Write("<script>alert('系统错误!');</script>");
}
}
protected void btn_ReSet_Click(object sender, ImageClickEventArgs e)
{
this.txtUserName.Text = "";
this.txtPwd.Text = "";
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -