masterpage.master.cs

来自「会议室管理系统,本系统是我大学毕业时候的毕业设计,一次通过的!」· CS 代码 · 共 48 行

CS
48
字号
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 + =
减小字号Ctrl + -
显示快捷键?