/// <summary> /// 登入相關事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void LoginImgBtn_Click(object sender, ImageClickEventArgs e) { bool LoginIsVaild = false; try { ErrorMsgLabel.Text = ""; //UserNameTxtBox.Text = "admin"; //PasswordTxtBox.Text = "admin"; #region 驗證輸入 if (UserNameTxtBox.Text.Trim().Length == 0 ) { throw new Exception("使用者名稱須輸入"); } if (PasswordTxtBox.Text.Trim().Length == 0) { throw new Exception("密碼不得為空白"); } #endregion SYSModel.MaintainUser usr = new SYSModel.MaintainUser(ConnectionDB); LoginIsVaild = usr.LoginVaild(UserNameTxtBox.Text, PasswordTxtBox.Text ); if (LoginIsVaild) { //登入 PageModel.BasePage ProcessPage = new PageModel.BasePage(); ProcessPage.UserLogin(UserNameTxtBox.Text); } } catch (System.Exception ex) { ErrorMsgLabel.Text = "※ 帳號或密碼錯誤(原因:" + ex.Message +")"; } finally { if (LoginIsVaild) { Response.Redirect("FMain.aspx"); } } }