protected override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); //将传过来的数据 类型转换一下 mainPage = ((object[])e.Parameter)[1] as MainPage; string title = (string)((object[])e.Parameter)[2]; string id = (string)((object[])e.Parameter)[0]; if (this.id != id) { mainPage.ActiveProgressRing(); this.id = id; if (title == "回复") { FeedDetailPivot.Visibility = Visibility.Visible; TitleTextBlock.Text = title; TitleBar.Visibility = Visibility.Collapsed; reply = ((object[])e.Parameter)[3] as Feed2; LoadRepliesDetail(id); } else { LoadFeedDetail(id); } } }
private void Feed2_KeyDown(object sender, KeyEventArgs e) { if (sqlCon.State == ConnectionState.Closed) { sqlCon.Open(); } if (e.KeyCode == Keys.Enter && (Flag == 0)) { username = Feed2.Text.ToString(); Feed2.Clear(); ss.SpeakAsync("Please enter your password and terminate with an Enter key"); Flag = 1; Flag2 = 1; return; } if (Flag == 4 && e.KeyCode == Keys.Enter) { username = Feed2.Text.ToString(); Feed2.Clear(); ss.SpeakAsync("Please enter your name and terminate with an Enter key"); Flag = 7; return; } if (Flag == 7 && e.KeyCode == Keys.Enter) { name = Feed2.Text.ToString(); name = name.TrimStart('\r', '\n'); Debug.Print(name.Length.ToString()); Feed2.Clear(); ss.SpeakAsync("Please enter your password and terminate with an Enter key"); Flag = 1; return; } if (e.KeyCode == Keys.Enter && Flag == 1 && Flag2 == -1) { password = Feed2.Text.ToString(); password = password.TrimStart('\r', '\n'); Debug.Print(password + " tghis is the password"); Feed2.Clear(); usernamespeechre.RecognizeAsyncStop(); Debug.Print("This has been reached"); SqlCommand sqlcmd = new SqlCommand("CreateAccount", sqlCon); sqlcmd.CommandType = CommandType.StoredProcedure; sqlcmd.Parameters.AddWithValue("@Name", name); sqlcmd.Parameters.AddWithValue("@Username", username); sqlcmd.Parameters.AddWithValue("@Password", password); sqlcmd.ExecuteNonQuery(); ss.SpeakAsync("Greetings!" + name + " Thank you for setting up an account with us"); ss.SpeakAsync("Please press the Start Button to activate the voice controlled assistant"); return; } else if (e.KeyCode == Keys.Enter && Flag == 1 && Flag2 == 1) { password = Feed2.Text.ToString(); password = password.TrimStart('\r', '\n'); Feed2.Clear(); usernamespeechre.RecognizeAsyncStop(); Debug.Print("This has been reached2"); Debug.Print(password + " tghis is the password"); SqlCommand sqlcmd = new SqlCommand("VerifyAccount", sqlCon); sqlcmd.CommandType = CommandType.StoredProcedure; int OutputFlag = 0; String usernameee = " "; sqlcmd.Parameters.AddWithValue("@Username", username); sqlcmd.Parameters.AddWithValue("@Password", password); sqlcmd.Parameters.AddWithValue("@OutputFlag", OutputFlag).Direction = ParameterDirection.Output; sqlcmd.Parameters.Add("@OutputName", SqlDbType.VarChar, 50).Direction = ParameterDirection.Output; sqlcmd.ExecuteNonQuery(); Debug.Print(usernameee); int returntype = Convert.ToInt32(sqlcmd.Parameters["@OutputFlag"].Value); String usernameeeu = Convert.ToString((sqlcmd.Parameters["@OutputName"].Value)); Debug.Print(usernameeeu); Debug.Print(returntype.ToString()); if (returntype == -1) { ss.SpeakAsync("The password and username are invalid"); } else if (returntype == 1) { ss.SpeakAsync("The password and username are valid"); ss.SpeakAsync("Welcome back!" + usernameeeu); ss.SpeakAsync("Please press the Start Button to activate the voice controlled assistant"); } return; } }