protected void Page_Load(object sender, EventArgs e) { this.user = (User)Session["User"]; if (!this.Page.IsPostBack) { TB_OldPassword.Focus(); MessagePanel.Text = " "; } }
protected void Button1_Click(object sender, EventArgs e) { if (TB_UserID.Text.Equals("")) ShowMessage("請輸入用戶名稱!", MessagePanel, TB_UserID); else if (TB_UserPw.Text.Equals("")) ShowMessage("請輸入用戶密碼!", MessagePanel, TB_UserPw); else { String UserPW = ""; String sql = "select user_pw from rps_userinfo where user_id = '" + TB_UserID.Text.Trim() + "'"; try { Database db = new Database("rpsdb", sql, Database.WebConfig); SqlDataReader reader = db.GetReader(); while (reader.Read()) UserPW = reader["user_pw"].ToString(); if (!reader.HasRows || !TB_UserPw.Text.Trim().Equals(UserPW.Trim())) { TB_UserPw.Text = ""; ShowMessage("登入失敗!", MessagePanel, TB_UserPw); db.Close(); } else { Session[HF_UserToken.Value] = true; Session["User"] = new User(TB_UserID.Text, TB_UserPw.Text, Request.UserHostAddress, HF_UserToken.Value); db.Close(); ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "ClientScript", "location.replace('/Main.aspx');", true); } } catch (SqlException) { TB_UserPw.Text = ""; TB_UserPw.Text = ""; MessagePanel.Text = "資料庫連接失敗!"; //MessagePanel.Text = ex.Message; } } }
protected void Page_Load(object sender, EventArgs e) { this.user = (User)Session["User"]; if (Session.Count >= 1) for (int i = 0; i < Session.Count; i++) if (Session[i].GetType().ToString().Equals("Microsoft.Reporting.WebForms.ReportHierarchy")) Session.RemoveAt(i); //this.fname = Path.GetFileNameWithoutExtension(Request.Path).Replace("Master",""); this.fname = Path.GetFileNameWithoutExtension(Request.Path); this.ModuleID = Path.GetFileNameWithoutExtension(Request.Path).Split('_')[0]; if (!Page.IsPostBack) this.user.UserLog(this.fname + ".aspx"); try { //if (!Page.IsPostBack && !user.CheckMenuPermission(this.fname)) if (!Page.IsPostBack && !user.CheckMenuPermission(this.ModuleID)) redirect("/Main.aspx"); else if (!this.user.CheckSession()) relogin("Session 錯誤!請再重新登入!"); else { Menu1.Items[0].Text = "主菜單"; Menu1.Items[0].Selectable = false; if (!Page.IsPostBack) Menu1 = user.UserMenu(Menu1); } } catch (NullReferenceException) { relogin("請先登入系統!"); } }
protected void Page_Load(object sender, EventArgs e) { this.user = (User)Session["User"]; }