public void ConfirmButton(Button button) { //send score to DB /* totalScore(); * Debug.Log("Total score is " + total + " and Button is " + button.name); * Debug.Log(button.name + " is pressed."); * Debug.Log("total = " + total); */ addTotalScore(); string sid = PlayerPrefs.GetString("sid", "001"); string totalScore = total.ToString(); SqliteDbHelper db = new SqliteDbHelper("Data Source=./sqlite.db"); if (!db.CheckTable("test0")) { db.CreateTable("test0", new string[] { "recordID", "userId", "totalScore", "date" }, new string[] { "integer primary key autoincrement", "int not null", " text not null", " timestamp default (date('now'))" }); } db.InsertIntoSpecific("test0", new string[] { "userId", "totalScore" }, new string[] { sid, "'" + totalScore + "'" }); db.CloseSqlConnection(); Debug.Log("OK!"); GameObject.Find("Canvas").transform.Find("ResultPanels").transform.Find("Result").gameObject.SetActive(false); //for development's sake, lets user know what the total score is //can be deleted when not needed GameObject.Find("Canvas").transform.Find("ResultPanels").transform.Find("Result2").gameObject.SetActive(true); ResultText2.text = "Your total score is: " + total; }
public void LoadScene(int level) { string sid = PlayerPrefs.GetString("sid", "001"); string score = GameObject.Find("Result/Score").GetComponent <Text>().text; string result = GameObject.Find("Result/Text").GetComponent <Text>().text; SqliteDbHelper db = new SqliteDbHelper("Data Source=./sqlite.db"); if (!db.CheckTable("test" + currentLevel.ToString())) { db.CreateTable("test" + currentLevel.ToString(), new string[] { "recordID", "userId", "score", "result", "date" }, new string[] { "integer primary key autoincrement", "int not null", " text not null", "text not null", " timestamp default (date('now'))" }); } db.InsertIntoSpecific("test" + currentLevel.ToString(), new string[] { "userId", "score", "result" }, new string[] { sid, "'" + score + "'", "'" + result + "'" }); db.CloseSqlConnection(); Debug.Log("OK!"); SceneManager.LoadScene(level); }
public void register() { string firstname = GameObject.Find("FirstName/InputField/Text").GetComponent <Text>().text; string lastname = GameObject.Find("LastName/InputField/Text").GetComponent <Text>().text; string grade = GameObject.Find("Grade/InputField/Text").GetComponent <Text>().text; string sid = GameObject.Find("SID/InputField/Text").GetComponent <Text>().text; SqliteDbHelper db = new SqliteDbHelper("Data Source=./sqlite.db"); if (!db.CheckTable("user")) { db.CreateTable("user", new string[] { "userid", "firstname", "lastname", "grade" }, new string[] { "integer primary key", "text not null", "text not null", "int not null" }); } db.InsertInto("user", new string[] { sid, "'" + firstname + "'", "'" + lastname + "'", grade }); db.CloseSqlConnection(); Debug.Log("OK!"); PlayerPrefs.SetString("sid", sid); }