// Checking the values that come from textbox private bool FormValidation() { bool hasError = false; bool success = int.TryParse(TxtPhoneNumber.Text, out _); if (string.IsNullOrEmpty(TxtEmail.Text) || string.IsNullOrEmpty(TxtPassword.Text) || string.IsNullOrEmpty(TxtName.Text) || string.IsNullOrEmpty(TxtSurname.Text) || string.IsNullOrEmpty(TxtPhoneNumber.Text)) { MessageBox.Show("Zəhmət olmasa bütün xanaları doldurun"); hasError = true; } else if (!Regex.IsMatch(TxtEmail.Text, @"^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$")) { MessageBox.Show("E-poçt ünvani düzgün yazın"); TxtEmail.Select(0, TxtEmail.Text.Length); TxtEmail.Focus(); hasError = true; } else if (!success) { MessageBox.Show("Nömrəni düzgün daxil edin"); TxtPhoneNumber.Select(0, TxtPhoneNumber.Text.Length); TxtPhoneNumber.Focus(); hasError = true; } return(hasError); }
private bool ValidaCampos() { if (CboFuncao.Text == string.Empty) { MessageBox.Show("o campo deve ser preenchido", "Sistema Friend of the Owner", MessageBoxButtons.OK, MessageBoxIcon.Warning); CboFuncao.Select(); return(false); } if (TxtSenha.Text == string.Empty) { MessageBox.Show("o campo deve ser preenchido", "Sistema Friend of the Owner", MessageBoxButtons.OK, MessageBoxIcon.Warning); TxtSenha.Select(); return(false); } if (TxtNome.Text == string.Empty) { MessageBox.Show("o campo deve ser preenchido", "Sistema Friend of the Owner", MessageBoxButtons.OK, MessageBoxIcon.Warning); TxtNome.Select(); return(false); } if (TxtEmail.Text == string.Empty) { MessageBox.Show("o campo deve ser preenchido", "Sistema Friend of the Ownero", MessageBoxButtons.OK, MessageBoxIcon.Warning); TxtEmail.Select(); return(false); } //if (MskCelular.MaskCompleted) //{ // MessageBox.Show("o campo deve ser preenchido", "Sistema Friend of the Owner", MessageBoxButtons.OK, MessageBoxIcon.Warning); // MskCelular.Select(); // return false; //} return(true); }
private void Button_Click(object sender, RoutedEventArgs e) { if (TxtEmail.Text.Length == 0) { errormessage.Text = "Enter an email."; TxtEmail.Focus(); } else if (!Regex.IsMatch(TxtEmail.Text, @"^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$")) { errormessage.Text = "Enter a valid email."; TxtEmail.Select(0, TxtEmail.Text.Length); TxtEmail.Focus(); } else { string firstname = TxtName.Text; string lastname = TxtSurname.Text; string email = TxtEmail.Text; string password = Password.Password; if (Password.Password.Length == 0) { errormessage.Text = "Enter password."; Password.Focus(); } else if (PasswordRecover.Password.Length == 0) { errormessage.Text = "Enter Confirm password."; PasswordRecover.Focus(); } else if (Password.Password != PasswordRecover.Password) { errormessage.Text = "Confirm password must be same as password."; PasswordRecover.Focus(); } else { var user = new User { Email = email, Password = password, CreatedDate = DateTime.Now, Name = firstname, Surname = lastname, UpdatedDate = DateTime.Now }; errormessage.Text = ""; dbContext.Users.Add(user); dbContext.SaveChanges(); MainWindow mainWindow = new MainWindow(); mainWindow.Show(); Close(); } } }
private void BtnSignIn_Click(object sender, RoutedEventArgs e) { //Admin login if (TxtEmail.Text == "admin" && TxtPassword.Password == "12345") { AdminPanel adminPanel = new AdminPanel(); adminPanel.ShowDialog(); TxtEmail.Clear(); TxtPassword.Clear(); return; } //Manager login Database if (string.IsNullOrEmpty(TxtEmail.Text)) { MessageBox.Show("E-poçt ünvani boş ola bilməz"); return; } else if (!Regex.IsMatch(TxtEmail.Text, @"^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$")) { MessageBox.Show("E-poçt ünvani düzgün yazın"); TxtEmail.Select(0, TxtEmail.Text.Length); TxtEmail.Focus(); return; } else if (string.IsNullOrEmpty(TxtPassword.Password)) { MessageBox.Show("Şifrə boş ola bilməz"); return; } var modelEmail = _libraryContext.Managers.FirstOrDefault(m => m.Email == TxtEmail.Text); if (modelEmail == null || modelEmail.Password != TxtPassword.Password) { MessageBox.Show("E-poçt ünvani və ya Şifrə yanlışdır"); return; } else { DashboardWindow dashboard = new DashboardWindow(); dashboard.Show(); this.Close(); } }
private bool ValidaCampos() { if (TxtDenunciante.Text == string.Empty) { MessageBox.Show("o campo Denunciante deve ser preenchido", "Sistema Friend of the Owner", MessageBoxButtons.OK, MessageBoxIcon.Warning); TxtDenunciante.Select(); return(false); } if (TxtNomeLogradouro.Text == string.Empty) { MessageBox.Show("o campo logradouro deve ser preenchido", "Sistema Friend of the Owner", MessageBoxButtons.OK, MessageBoxIcon.Warning); TxtNomeLogradouro.Select(); return(false); } if (TxtEmail.Text == string.Empty) { MessageBox.Show("o campo Email deve ser preenchido", "Sistema Friend of the Owner", MessageBoxButtons.OK, MessageBoxIcon.Warning); TxtEmail.Select(); return(false); } if (TxtTestoDenuncia.Text == string.Empty) { MessageBox.Show("o campo Denuncia deve ser preenchido", "Sistema Friend of the Owner", MessageBoxButtons.OK, MessageBoxIcon.Warning); TxtTestoDenuncia.Select(); return(false); } if (TxtBairro.Text == string.Empty) { MessageBox.Show("o campo Bairro deve ser preenchido", "Sistema Friend of the Owner", MessageBoxButtons.OK, MessageBoxIcon.Warning); TxtBairro.Select(); return(false); } if (TxtCidade.Text == string.Empty) { MessageBox.Show("o campo Cidade deve ser preenchido", "Sistema Friend of the Owner", MessageBoxButtons.OK, MessageBoxIcon.Warning); TxtCidade.Select(); return(false); } return(true); }