📄 masterpage.master.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 MasterPage : System.Web.UI.MasterPage
{
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
if (Session["username"] == null || Session["role"] == null)
{
Response.Redirect("login.aspx");
}
else
{
this.Label1.Text = Convert.ToString(Session["username"]);
this.Label2.Text = Convert.ToString(Session["role"]);
this.Labnum.Text = Convert.ToString(Session["loginnum"]);
this.Labtime.Text = Convert.ToString(Session["entertime"]);
this.Label3.Text = Convert.ToString(Session["loginouttime"]);
}
}
}
protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
{
Session["username"] = "";
Session["pwd"] = "";
Session["role"] = "";
System.Web.Security.FormsAuthentication.SignOut();
SqlConnection cn = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["cn"]);
cn.Open();
SqlCommand cmd1 = new SqlCommand("update userinfo set loginouttime=getdate(),attr='离线' where id=" + Convert.ToInt32(Session["id"]), cn);
cmd1.ExecuteNonQuery();
cn.Close();
Response.Redirect("login.aspx");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -