/// <summary> /// 按下登录按钮 /// </summary> public void OnClickedLoginButton() { mysql.OpenSql(); string loginMsg = "登录成功"; DataSet ds = mysql.Select("usertable", new string[] { "level" }, new string[] { "`" + "account" + "`", "`" + "password" + "`" }, new string[] { "=", "=" }, new string[] { userNameInput.text, passwordInput.text }); if (ds != null) { DataTable table = ds.Tables[0]; if (table.Rows.Count > 0) { loginMsg = "登陆成功!"; loginMessage.color = Color.green; Debug.Log("用户权限等级:" + table.Rows[0][0]); SceneManager.LoadScene(2); Time.timeScale = 1f; } else { loginMsg = "用户名或密码错误!"; loginMessage.color = Color.red; } loginMessage.text = loginMsg; } mysql.CloseSql(); }
public void OnLogInBtnClick() { if (userNameInput.text == "") { Message("请输入用户名"); } else if (passwordInput.text == "") { Message("请输入密码"); } else { mysql.OpenSql(); //获取数据 DataSet ds = mysql.Select("users", new string[] { "user_password", "user_id" }, new string[] { "user_name" }, new string[] { "=" }, new string[] { userNameInput.text, }); if (ds != null) { DataTable table = ds.Tables[0]; List <string> data = new List <string>(); foreach (DataRow row in table.Rows) { foreach (DataColumn col in table.Columns) { data.Add(row[col].ToString()); } } if (data[0] == passwordInput.text) { mes.color = Color.green; Message("登录成功"); Manager.manager.FeaturesPanelDisplay(); } else { mes.color = Color.red; Message("登陆失败"); } } else { mes.color = Color.red; Message("登陆失败"); } mysql.CloseSql(); } }