private void UserNametxt_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { Verify_Account(); Passwordtxt.Focus(); } }
/// <summary> /// Sets the focus on the first empty textbox /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Window_Loaded(object sender, RoutedEventArgs e) { if (iptxt.Text == "") { iptxt.Focus(); } else if (uNametxt.Text == "") { uNametxt.Focus(); } else { Passwordtxt.Focus(); } }
async void LoginAppAsync(object sender, EventArgs args) { if (string.IsNullOrEmpty(Useridtxt.Text)) { await App.Current.MainPage.DisplayAlert("Empty Values", "Please enter User ID", "OK"); Useridtxt.Focus(); } else if (string.IsNullOrEmpty(Passwordtxt.Text)) { await App.Current.MainPage.DisplayAlert("Empty Values", "Please enter Password", "OK"); Passwordtxt.Focus(); } else { WebClient client = new WebClient(); string url = "http://192.168.182.122/WMS/login.php?user1=" + Useridtxt.Text + "&" + "pass1=" + Passwordtxt.Text; byte[] html = client.DownloadData(url); res = utf.GetString(html); if (res == "upX") { await App.Current.MainPage.DisplayAlert("Login Error", "Please Check User ID and Password", "OK"); } else { string json = res; var mydata = JObject.Parse(json); string Name = mydata["Username"].ToString(); string Position = mydata["UserID"].ToString(); // await App.Current.MainPage.DisplayAlert("Info", Name, "OK"); // await App.Current.MainPage.DisplayAlert("Info", Position, "OK"); Application.Current.MainPage = new NavigationPage(new Gridview()); } } }