예제 #1
0
        private void InputBox_OnKeyUp(object sender, KeyRoutedEventArgs e)
        {
            if (sender == PhoneNumberBox)
            {
                if (PhoneNumberBox.Text.Length == 10)
                {
                    EmailBox.Focus(FocusState.Programmatic);
                    return;
                }
            }

            if (e.Key == VirtualKey.Enter)
            {
                if (sender == NameBox)
                {
                    SurnameBox.Focus(FocusState.Programmatic);
                }
                if (sender == SurnameBox)
                {
                    CommandBar.Focus(FocusState.Programmatic);
                }
                else if (sender == EmailBox)
                {
                    PasswordBox.Focus(FocusState.Programmatic);
                }
                else if (sender == PasswordBox)
                {
                    PasswordRepeatBox.Focus(FocusState.Programmatic);
                }
                else if (sender == PasswordRepeatBox)
                {
                    CommandBar.Focus(FocusState.Programmatic);
                }
            }
        }
예제 #2
0
        private async Task TryToSetUserNameOrFocusInput()
        {
            var users = await User.FindAllAsync();

            if (users.Count == 1)
            {
                var list = new List <string>
                {
                    KnownUserProperties.FirstName,
                    KnownUserProperties.LastName
                };
                var propertySet = await users[0].GetPropertiesAsync(list);
                NameBox.Text    = (string)propertySet[KnownUserProperties.FirstName];
                SurnameBox.Text = (string)propertySet[KnownUserProperties.LastName];
            }

            if (string.IsNullOrEmpty(NameBox.Text))
            {
                NameBox.Focus(FocusState.Programmatic);
            }
            else if (string.IsNullOrEmpty(SurnameBox.Text))
            {
                SurnameBox.Focus(FocusState.Programmatic);
            }
        }
        // Validacia udajov v textovych poliach
        private bool StudentBoxesValidator()
        {
            if (!OnlyLetters(this.NameBox.Text, 2, 30))
            {
                MessageBox.Show("Meno nemôže mať viac ako 30 znakov a menej ako 2 nemôže obsahovať špeciálne znaky ani čísla", "Chyba");
                NameBox.SelectAll();
                NameBox.Focus();
                return(false);
            }
            else if (!OnlyLetters(this.SurnameBox.Text, 2, 35))
            {
                MessageBox.Show("Priezvisko nemôže mať viac ako 35 znakov a menej ako 2 nemôže obsahovať špeciálne znaky ani čísla", "Chyba");
                SurnameBox.SelectAll();
                SurnameBox.Focus();
                return(false);
            }
            else if (!ContainsSpecialCharacters(this.EmailBox.Text, 7, 55))
            {
                MessageBox.Show("Uistite sa, že email obsahuje @ a dĺžka nepresiahla 55 znakov.", "Chyba");
                EmailBox.SelectAll();
                EmailBox.Focus();
                return(false);
            }
            else if (!string.IsNullOrEmpty(EmailUcmBox.Text) || !string.IsNullOrWhiteSpace(EmailUcmBox.Text))
            {
                if (!ContainsSpecialCharacters(this.EmailUcmBox.Text, 7, 55))
                {
                    MessageBox.Show("Uistite sa, že email obsahuje @ a dĺžka nepresiahla 55 znakov.", "Chyba");
                    EmailUcmBox.SelectAll();
                    EmailUcmBox.Focus();
                    return(false);
                }
            }
            else if (!string.IsNullOrWhiteSpace(this.IsicBox.Text) || !string.IsNullOrEmpty(this.IsicBox.Text))
            {
                if (!OnlyNumericCharacters(this.IsicBox.Text, 17, 17))
                {
                    MessageBox.Show("Uistite sa, že ISIC obsahuje iba čísla a dĺžka nepresiahla 17 znakov.", "Chyba");

                    return(false);
                }
            }
            if (!OnlyNumericCharacters(this.GradeBox.Text, 1, 3))
            {
                MessageBox.Show("Uistite sa, že ročník obsahuje čísla a dĺžka nepresiahla 3 znaky.", "Chyba");
                return(false);
            }

            return(true);
        }