public void RegisBtn()
    {
        // 1. 先判断输入的账号合不合法
        // 2. 合法就判断该账号存不存在 不存在就注册

        string isLegal = BeginRegularPlayer(nameField.text, regularPhone, regularEmail);

        if (isLegal == "isPhone" || isLegal == "isEmail")
        {
            Debug.Log("账号输入合法 可以注册");
        }
        else
        {
            Debug.Log("不合法 重新输入 也没有必接下来的步骤了");
            return;
        }

        // 2.
        string UserNameOne = "USER where name=" + " '" + nameField.text + "'";
        int    count       = SqliteMangeToCSharp.GetInstance().selectTableDataCondition(UserNameOne, path);

        if (count > 0)
        {
            // 已经被注册 提示出现
            Debug.Log("注册失败 已经被注册");
        }
        else
        {
            SqliteMangeToCSharp.GetInstance().InsertData(string.Format("USER(name,password) values('{0}','{1}')", nameField.text, pwdField.text), path);

            Debug.Log("注册成功");
            gameObject.SetActive(false);
//			login_bg.SetActive (true);
        }
    }
 public static SqliteMangeToCSharp GetInstance()
 {
     if (_instance == null)
     {
         _instance = new SqliteMangeToCSharp();
     }
     return(_instance);
 }
Exemplo n.º 3
0
	// 登入按钮的回调

	public void LoginBtn()
	{ 
		
		string isLegal = RegistereBg.getInstance().BeginRegularPlayer (nameField.text,regularPhone,regularEmail) ;
		if (isLegal == "isPhone" || isLegal == "isEmail") {
			Debug.Log ("账号输入合法");

		} else 
		{

			Debug.Log ("不合法 重新输入 ");
			return;
		}

		// 2.
		string UserNameOne = "USER where name="+" '"+nameField.text + "'";
		int count = SqliteMangeToCSharp.GetInstance ().selectTableDataCondition (UserNameOne,path);

		// 账号存在 去验证密码
		if (count > 0) 
		{
			// 查找是否有这个账号 且密码是否一致
			string UserName = "******"+" '"+nameField.text+"'";
			Debug.Log (count);
			SqliteDataReader reader = SqliteMangeToCSharp.GetInstance().selectTaleDataAll (UserName,path);
			Debug.Log (count);
			while (reader.Read ()) {


				string name = nameField.text;
				string psw = pwdField.text;

				if (name == reader.GetString (1) && psw == reader.GetString (2)) {

					Debug.Log ("登入成功");

					gameObject.SetActive (false);
					LoadWaitingView.SetActive (true);
					Invoke ("LoadGamesLobby",2.0f);



				} else {

					Debug.Log ("密码错误");
				}


			}


		}
		else {

			Debug.Log ("账号未注册");

		}
		}
 // Use this for initialization
 void Start()
 {
     // 创建数据库
     SqliteMangeToCSharp.GetInstance().CreateDatabase(path, tableName);
 }