protected void Page_Load(object sender, EventArgs e) { this.user = (User)Session["User"]; this.fname = Path.GetFileNameWithoutExtension(Request.Path).Replace("Master", ""); if (!Page.IsPostBack) this.user.UserLog(this.fname + ".aspx"); try { if (!Page.IsPostBack && !user.CheckMenuPermission(this.fname)) 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"]; if (!Page.IsPostBack) { ShowMessage("閣下第一次登入,為保障安全,麻煩您修改密碼!密碼最少六個位。", MessagePanel, TB_NewPW); } }
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_UserPw.Text.Equals("")) ShowMessage("請輸入用戶密碼!", MessagePanel, TB_UserPw); else { String ShopPW = String.Empty; String ShopBU = String.Empty; Boolean ShopFirst = true; String sql = "select shop_pw, shop_first, shop_bu from rps_shopinfo where shop_id = '" + TB_UserID.Text.Trim() + "'"; try { Database db = new Database("rpsdb", sql, Database.WebConfig); SqlDataReader reader = db.GetReader(); while (reader.Read()) { ShopPW = reader["shop_pw"].ToString(); ShopFirst = reader["shop_first"].ToString().Equals("T"); ShopBU = reader["shop_bu"].ToString(); } if (!reader.HasRows || !TB_UserPw.Text.Trim().Equals(ShopPW.Trim())) { TB_UserPw.Text = String.Empty; 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, ShopBU); db.Close(); String location = ""; if (ShopFirst) location = "location.replace('/FirstLogin.aspx');"; else location = "location.replace('/Main.aspx');"; ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "ClientScript", location, true); } } catch (SqlException) { TB_UserPw.Text = String.Empty; MessagePanel.Text = "資料庫連接失敗!"; } } }