關閉瀏覽器按鈕退出系統問題

xiangchengboy發表於2011-01-10

Top.aspx頁面:

<body onunload="LogOut()">

</body>

 

<script type="javascript/text" >

function LogOut()
{
 var c= Ufida.T.UI._top.RecordLogOut();
 
}

</script>

 

Top.aspx.cs:

 namespace Ufida.T.UI
{

    public partial class _top : BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            this.CheckLogin();
            AjaxPro.Utility.RegisterTypeForAjax(typeof(_top));
            this.labUserName.Text = this.userDTO.UserName;

            if (Session["usercount"] != null)
            {
                this.lblzds.Text = Session["usercount"].ToString();
            }

            //this.labOrgName.Text = strUserOrgName
        }
        [AjaxPro.AjaxMethod()]
        public string RecordLogOut()
        {
            //add by yxh 2010-12-02 登出加密站點
            UserDTO udto = Session["userdto"] as UserDTO;
            bool b = LDHTSCManager.Logout(udto.UserName);
            try
            {
               
                string id = Session["loginid"].ToString();
                string logTime = DateTime.Now.ToString();
                SQLDataModuleService module = new SQLDataModuleService();
                int count = module.ExecuteSql("update LOG_LOGIN set ENDDATE='" + DateTime.Parse(logTime) + "' where ID='" + id + "'");
                Session.Clear();
                return "1";
            }
            catch (Exception ex)
            {
                Session.Clear();
                return "0";
            }
           

        }
      
    }
}

 

相關文章