Exemplo n.º 1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     //判断是否有用户登陆,如果没有登陆,则状态显示为"游客",登陆,注册按钮显示,退出按钮隐藏
     if (Session["username"] == null || Session["username"].ToString().Trim() == "")
     {
         state.Text        = "游客";
         User_Join.Visible = true;
         Exit.Visible      = false;
         ts_hl.Visible     = false;
     }
     else    //如果用户登陆,则登陆,注册按钮隐藏,退出按钮显示
     {
         state.Text        = Session["nc"].ToString();
         User_Join.Visible = false;
         Exit.Visible      = true;
         ts_hl.Visible     = true;
         Label2.Text       = Session["jf"].ToString();
         String user_id = Session["username"].ToString();
         if (Session["last_time"] == null || Session["last_time"] == "")
         {
             Label3.Text = "上次登录:" + DateTime.Now.ToString("yyyy-MM-dd");
         }
         else
         {
             Label3.Text = "上次登录:" + Session["last_time"].ToString();
         }
         if (user_id != null)
         {
             String strsql = "SELECT  count(id) FROM bbs_message WHERE  touser='******' and isread=0";
             String ts     = con.RunSqlReturnString(strsql);
             if (ts != "0")
             {
                 ts_hl.Text = ts + "条新私信";
             }
         }
     }
 }