protected void Page_Load(object sender, EventArgs e) { if (Request.Url.AbsoluteUri.IndexOf("?") >= 0) { if (Request.Url.Query.IndexOf("User="******"User"]; TextBox_ID.ReadOnly = true; TextBox_PW.Focus(); } } else { TextBox_ID.Focus(); } if (Button_LogIn.Text == "Log In") { Panel_A.Enabled = false; Panel_B.Enabled = false; Panel_C.Enabled = false; Panel_D.Enabled = false; Panel_ON.Enabled = false; Panel_OFF.Enabled = false; } else { Panel_A.Enabled = true; Panel_B.Enabled = true; Panel_C.Enabled = true; Panel_D.Enabled = true; Panel_ON.Enabled = true; Panel_OFF.Enabled = true; } }
protected void Button_LogIn_Click(object sender, EventArgs e) { if (Button_LogIn.Text == "Log In") { if (!String.IsNullOrEmpty(TextBox_ID.Text)) { if (!String.IsNullOrEmpty(TextBox_PW.Text)) { if (SQL_TryConnect()) { TextBox_ID.ReadOnly = true; TextBox_PW.ReadOnly = true; Button_LogIn.CssClass = "btn btn-warning"; Button_LogIn.Text = "Log Out"; Panel_Information.Enabled = true; } else { ClientScript.RegisterStartupScript(GetType(), "message", "<script>alert('登入失敗!');</script>"); } } else { ClientScript.RegisterStartupScript(GetType(), "message", "<script>alert('請輸入密碼!');</script>"); TextBox_PW.Focus(); } } else { ClientScript.RegisterStartupScript(GetType(), "message", "<script>alert('請輸入ID!');</script>"); TextBox_ID.Focus(); } } else { if (Request.Url.AbsoluteUri.IndexOf("?") >= 0) { if (Request.Url.Query.IndexOf("User="******"User"]; TextBox_ID.ReadOnly = true; } else { TextBox_ID.ReadOnly = false; } } else { TextBox_ID.ReadOnly = false; } TextBox_PW.ReadOnly = false; TextBox_PW.Text = ""; Button_LogIn.CssClass = "btn btn-primary"; Button_LogIn.Text = "Log In"; Panel_Information.Enabled = false; Timer_Update.Enabled = false; } }