private void button2_Click(object sender, EventArgs e) { if (Nombre.Text == "") { Nombre.Focus(); MessageBox.Show("este campo esta vacio"); } else if (Apellido.Text == "") { Apellido.Focus(); MessageBox.Show("este campo esta vacio"); } else if (Documento.Text == "") { Documento.Focus(); MessageBox.Show("este campo esta vacio"); } else if (Fecha_nacimiento.Text == "") { Fecha_nacimiento.Focus(); MessageBox.Show("este campo esta vacio"); } else { } }
private bool Validacion() { if (Nombre.Text.Length == 0) { MessageBox.Show("Debes Digitar un Nombre de Cliente"); Nombre.Focus(); return(false); } return(true); }
public RegisterView() { InitializeComponent(); NavigationPage.SetHasBackButton(this, false); CC.ReturnCommand = new Command(() => Nombre.Focus()); Nombre.ReturnCommand = new Command(() => Apellido.Focus()); Apellido.ReturnCommand = new Command(() => typeUser.Focus()); btnLogin.Clicked += (sender, e) => { ((NavigationPage)this.Parent).PushAsync(new LoginView()); }; }
private void textboxRFC_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == ((char)(Keys.Enter))) { Nombre.Focus(); } if ((char.IsLetter(e.KeyChar)) || (char.IsDigit(e.KeyChar)) || (e.KeyChar == ((char)(Keys.Back))) || (e.KeyChar == 45)) { e.Handled = false; } else { e.Handled = true; } }
private void controlBotonNombre() { if (Nombre.Text.Trim() == "Fotocopiadora 123") { inicioSesión.Enabled = true; errorProvider1.SetError(Nombre, ""); } else { if (string.IsNullOrWhiteSpace(Nombre.Text)) { errorProvider1.SetError(Nombre, "Debe introducir el usuario"); } else { errorProvider1.SetError(Nombre, "El usuario es incorrecto"); } inicioSesión.Enabled = false; Nombre.Focus(); } }
async private void btnRegistrar_Clicked(object sender, EventArgs e) { if (string.IsNullOrEmpty(Email.Text) || string.IsNullOrEmpty(Password.Text) || string.IsNullOrEmpty(Nombre.Text)) { // se deben indicar los tres valores LabelInfo.Text = "Debes indicar los tres valores solicitados."; LabelInfo.IsVisible = true; if (string.IsNullOrEmpty(Email.Text)) { Email.Focus(); } else if (string.IsNullOrEmpty(Password.Text)) { Password.Focus(); } else if (string.IsNullOrEmpty(Nombre.Text)) { Nombre.Focus(); } } else { // Comprobar si ya existe ese usuario if (UsuarioSQL.Existe(Email.Text)) { LabelInfo.Text = "Debes indicar una cuenta de correo no registrada."; LabelInfo.IsVisible = true; Email.Focus(); return; } // registrarlo var usuario = new UsuarioSQL(); usuario.Email = Email.Text; usuario.Nombre = Nombre.Text; UsuarioSQL.GuardarUsuario(usuario, Password.Text); // Enviarlo a Login await Navigation.PushAsync(new Login(new MainMenu())); } }
// GotFocus y LostFocus para los WaterMakers de los TextBox private void comprobarFocus() { if (!string.IsNullOrEmpty(Nombre.Text)) { NombreWM.Visibility = System.Windows.Visibility.Collapsed; Nombre.Visibility = System.Windows.Visibility.Visible; Nombre.Focus(); } if (!string.IsNullOrEmpty(Apellido.Text)) { ApellidoWM.Visibility = System.Windows.Visibility.Collapsed; Apellido.Visibility = System.Windows.Visibility.Visible; Apellido.Focus(); } if (!string.IsNullOrEmpty(Telefono1.Text)) { Telefono1WM.Visibility = System.Windows.Visibility.Collapsed; Telefono1.Visibility = System.Windows.Visibility.Visible; Telefono1.Focus(); } if (!string.IsNullOrEmpty(Telefono2.Text)) { Telefono2WM.Visibility = System.Windows.Visibility.Collapsed; Telefono2.Visibility = System.Windows.Visibility.Visible; Telefono2.Focus(); } if (!string.IsNullOrEmpty(Direccion.Text)) { DireccionWM.Visibility = System.Windows.Visibility.Collapsed; Direccion.Visibility = System.Windows.Visibility.Visible; Direccion.Focus(); } if (!string.IsNullOrEmpty(email.Text)) { emailWM.Visibility = System.Windows.Visibility.Collapsed; email.Visibility = System.Windows.Visibility.Visible; email.Focus(); } }
private void NombreWM_GotFocus(object sender, RoutedEventArgs e) { NombreWM.Visibility = System.Windows.Visibility.Collapsed; Nombre.Visibility = System.Windows.Visibility.Visible; Nombre.Focus(); }
private void Window_ContentRendered(object sender, EventArgs e) { Nombre.SelectAll(); Nombre.Focus(); }
private async void EventModificar_Clicked(object sender, EventArgs e) { string connectionString = ConfigurationManager.AppSettings["ipServer"]; try { var id = IdEmpleado.Text; var nombreV = Nombre.Text; var apellidoV = Apellido.Text; var sexoV = Sexo.SelectedIndex; var direccionV = Direccion.Text; var telefonoV = telefono.Text; var cedulaV = cedula.Text; var fnV = FN.Date; if (string.IsNullOrEmpty(nombreV)) { await DisplayAlert("Validacion", "Ingrese el nombre de Usuario", "Aceptar"); Nombre.Focus(); return; } if (string.IsNullOrEmpty(apellidoV)) { await DisplayAlert("Validacion", "Ingresar el apellido del empleado", "Aceptar"); Apellido.Focus(); return; } if (string.IsNullOrEmpty(direccionV)) { await DisplayAlert("Validacion", "Ingreser la direccion del empleado", "Aceptar"); Direccion.Focus(); return; } if (string.IsNullOrEmpty(telefonoV)) { await DisplayAlert("Validacion", "Ingresar el numero telefonico del empleado", "Aceptar"); telefono.Focus(); return; } if (string.IsNullOrEmpty(cedulaV)) { await DisplayAlert("Validacion", "Ingreser la cedula del empleado", "Aceptar"); cedula.Focus(); return; } if (string.IsNullOrEmpty(fnV.ToString())) { await DisplayAlert("Validacion", "Ingresar la fecha de nacimiento del usuario", "Aceptar"); FN.Focus(); return; } HttpClient client = new HttpClient(); client.BaseAddress = new Uri(connectionString); var empleados = new Emple() { EmpleadoID = int.Parse(id), Nombres = nombreV, Apellidos = apellidoV, Sexo = (Sexo.SelectedIndex == 0) ? false : true, Direccion = direccionV, Telefono = telefonoV, Fecha_Nacimiento = fnV, Cedula = cedulaV, Edad = DateTime.Now.Year - fnV.Value.Year }; var json = JsonConvert.SerializeObject(empleados); StringContent stringContent = new StringContent(json, Encoding.UTF8, "application/json"); var request = await client.PostAsync("/api/Empleados/modificar", stringContent); if (request.IsSuccessStatusCode) { var responseJson = await request.Content.ReadAsStringAsync(); var respuesta = JsonConvert.DeserializeObject <Request>(responseJson); if (respuesta.status) { await MaterialDialog.Instance.AlertAsync(message : "Usuario se modifico correctamente", title : "Registro", acknowledgementText : "Aceptar"); } else { await MaterialDialog.Instance.AlertAsync(message : "Usuario no pudo modificarse correctamente", title : "Registro", acknowledgementText : "Aceptar"); } } else { await MaterialDialog.Instance.AlertAsync(message : "Error", title : "Error", acknowledgementText : "Aceptar"); } } catch (Exception ex) { await MaterialDialog.Instance.AlertAsync(message : ex.Message, title : ex.Message, acknowledgementText : "Aceptar"); } }
private bool validar() { if (Nombre.Text.Length == 0) { MessageBox.Show("El Campo nombre esta vacio", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Warning); Nombre.Focus(); return(false); } if (Apellido.Text.Length == 0) { MessageBox.Show("El Campo Apellido esta vacio", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Warning); Apellido.Focus(); return(false); } if (PaisID.Text.Length == 0 || PaisID.SelectedValue == null) { MessageBox.Show("El Campo Pais esta vacio", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Warning); PaisID.Focus(); return(false); } if (ProvinciaID.Text.Length == 0 || ProvinciaID.SelectedValue == null) { MessageBox.Show("El Campo Provincia esta vacio", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Warning); ProvinciaID.Focus(); return(false); } if (PerfilID.Text.Length == 0 || PerfilID.SelectedValue == null) { MessageBox.Show("El Campo Prefil esta vacio", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Warning); PerfilID.Focus(); return(false); } if (User.Text.Length == 0) { MessageBox.Show("El Campo Usuario esta vacio", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Warning); User.Focus(); return(false); } if (PassWord.Text.Length == 0) { MessageBox.Show("El Campo Contraseña esta vacio", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Warning); PassWord.Focus(); return(false); } if (CofPassWord.Text.Length == 0) { MessageBox.Show("El Campo Confirmar Contraseña esta vacio", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Warning); CofPassWord.Focus(); return(false); } if (CofPassWord.Text != PassWord.Text) { MessageBox.Show("La Contraseña no coinciden favor confirme", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Warning); PassWord.Focus(); return(false); } return(true); }
//private void btnPrivacidad_Clicked(object sender, EventArgs e) //{ // _ = App.MostrarPoliticaPrivacidad(); //} async void OnSaveButtonClicked(object sender, EventArgs e) { LabelAviso.IsVisible = false; var usuario = (UsuarioSQL)BindingContext; // no guardar el email en blanco if (string.IsNullOrEmpty(Email.Text)) { LabelAviso.Text = "El Email no puede estar en blanco."; LabelAviso.IsVisible = true; Email.Focus(); return; } if (string.IsNullOrEmpty(Nombre.Text)) { LabelAviso.Text = "El Nombre no puede estar en blanco."; LabelAviso.IsVisible = true; Nombre.Focus(); return; } if (ClaveSHA.Text.ToUpper() != _usuario.ClaveSHA) { LabelAviso.Text = "La clave SHA no es modificable."; LabelAviso.IsVisible = true; ClaveSHA.Text = _usuario.ClaveSHA; ClaveSHA.Focus(); return; } // Si cambia de email no se guardan los cambios. if (usuario.Email.ToLower() != _usuario.Email.ToLower()) { var sb = new StringBuilder(); sb.AppendLine($"Hola {_usuario.Nombre},"); sb.AppendLine($"Has solicitado cambiar el email usado en el programa: '{_usuario.Email}',"); sb.AppendLine($"por otro diferente: '{usuario.Email}'."); sb.AppendLine(); sb.AppendLine("Si no has sido tú, seguramente deberías cambiar el password porque alguien ha accedido con tus datos."); sb.AppendLine(); sb.AppendLine("Si has sido tú, te mando otro mensaje a la nueva cuenta que quieres usar."); sb.AppendLine("Por favor, confirma (respondiendo a los dos mensajes) que es correcto ese cambio."); sb.AppendLine("También indicame el nuevo password a usar cuando respondas al mensaje recibido en la nueva cuenta de email."); sb.AppendLine("Después podrás cambiarlo usando esta misma página del Perfil del usuario."); sb.AppendLine(); sb.AppendLine("Gracias."); sb.AppendLine("Guillermo"); sb.AppendLine("---------"); sb.AppendLine($"{App.AppName} {App.AppVersion}"); await App.SendEmail("Cambio de email", sb.ToString(), _usuario.Email); sb.Clear(); sb.AppendLine($"Hola {_usuario.Nombre},"); sb.AppendLine($"El usuario de la aplicación {App.AppName} con email '{_usuario.Email}' ha solicitado cambiar el email"); sb.AppendLine($"por este al que te mando este correo: '{usuario.Email}'."); sb.AppendLine(); sb.AppendLine("Si no has sido tú, por favor, indícamelo y procederé como vea conveniente."); sb.AppendLine(); sb.AppendLine("Si has sido tú, te he mandado otro mensaje a la cuenta desde la que has solicitado el cambio."); sb.AppendLine("Por favor, confirma (respondiendo a los dos mensajes) que es correcto ese cambio."); sb.AppendLine("También indicame aquí el nuevo password a usar."); sb.AppendLine("Después podrás cambiarlo usando esta misma página del Perfil del usuario."); sb.AppendLine(); sb.AppendLine("Gracias."); sb.AppendLine("Guillermo"); sb.AppendLine("---------"); sb.AppendLine($"{App.AppName} {App.AppVersion}"); await App.SendEmail("Cambio de email", sb.ToString(), usuario.Email); btnGuardar.IsEnabled = false; LabelAviso.Text = "Has indicado un nuevo email. No se guardan los cambios. Responde a los 2 emails enviados. Gracias."; LabelAviso.IsVisible = true; Email.Focus(); } else { // Guardar los cambios y asignar el usuario actual con los nuevos datos. if (Password.Text.Any()) { // Cambiar el password y guardar la nueva clave SHA usuario.ClaveSHA = UsuarioSQL.GenerarClaveSHA1(usuario.Email, Password.Text); usuario.Password = Password.Text; App.UltimoPassword = usuario.Password; } UsuarioSQL.GuardarUsuario(usuario); UsuarioSQL.UsuarioLogin = usuario; App.UltimoUsuario = usuario.Email; LabelAviso.Text = "Se han guardado correctamente los nuevos datos."; LabelAviso.IsVisible = true; } }