private bool Validar() { bool paso = true; MyErrorProvider.Clear(); if(NombresTextBox.Text == string.Empty) { MyErrorProvider.SetError(NombresTextBox, "El campo nombre no puede estar vacio"); NombresTextBox.Focus(); paso = false; } if (string.IsNullOrWhiteSpace(MatriculaTextBox.Text)) { MyErrorProvider.SetError(MatriculaTextBox, "El campo matricula no pude estar vacio"); MatriculaTextBox.Focus(); paso = false; } if (string.IsNullOrWhiteSpace(CedulaMaskedTextBox.Text)) { MyErrorProvider.SetError(CedulaMaskedTextBox, "El campo Cedula no puede estar vacio"); CedulaMaskedTextBox.Focus(); paso = false; } return paso; }
private bool Validar() { bool paso = true; if (InstitucionComboBox.Text == string.Empty) { MyErrorProvider.SetError(InstitucionComboBox, "Debes agreagr datos aqui."); InstitucionComboBox.Focus(); paso = false; } if (NombrePasanteTextBox.Text == string.Empty) { MyErrorProvider.SetError(NombrePasanteTextBox, "Debes agreagr datos aqui."); NombrePasanteTextBox.Focus(); paso = false; } if (MatriculaTextBox.Text == string.Empty) { MyErrorProvider.SetError(MatriculaTextBox, "Debes agreagr datos aqui."); MatriculaTextBox.Focus(); paso = false; } if (EmailTextBox.Text == string.Empty) { MyErrorProvider.SetError(EmailTextBox, "Debes agreagr datos aqui."); EmailTextBox.Focus(); paso = false; } if (HorasARealizarTextBox.Text == string.Empty) { MyErrorProvider.SetError(HorasARealizarTextBox, "Debes agreagr datos aqui."); HorasARealizarTextBox.Focus(); paso = false; } if (TelefonoTextBox.Text == string.Empty) { MyErrorProvider.SetError(TelefonoTextBox, "Debes agreagr datos aqui."); TelefonoTextBox.Focus(); paso = false; } return(paso); }
private bool Validar() { bool paso = true; MyerrorProvider.Clear(); if (string.IsNullOrWhiteSpace(MatriculaTextBox.Text)) { MyerrorProvider.SetError(MatriculaTextBox, "El campo Direccion no puede estar vacio"); MatriculaTextBox.Focus(); paso = false; } if (NombreTextbox.Text == string.Empty) { MyerrorProvider.SetError(NombreTextbox, "El campo Nombre no puede estar vacio"); NombreTextbox.Focus(); paso = false; } if (ApellidoTextbox.Text == string.Empty) { MyerrorProvider.SetError(ApellidoTextbox, "El campo Nombre no puede estar vacio"); ApellidoTextbox.Focus(); paso = false; } if (string.IsNullOrWhiteSpace(CedulaTextbox.Text.Replace("-", ""))) { MyerrorProvider.SetError(CedulaTextbox, "El campo Cedula no puede estar vacio"); CedulaTextbox.Focus(); paso = false; } if (string.IsNullOrWhiteSpace(TelefonoTextbox.Text.Replace("-", ""))) { MyerrorProvider.SetError(TelefonoTextbox, "El campo Telefono no puede estar vacio"); TelefonoTextbox.Focus(); paso = false; } if (string.IsNullOrWhiteSpace(CelularTextbox.Text.Replace("-", ""))) { MyerrorProvider.SetError(CelularTextbox, "El campo Celular no puede estar vacio"); CelularTextbox.Focus(); paso = false; } if (string.IsNullOrWhiteSpace(EmailTextbox.Text)) { MyerrorProvider.SetError(EmailTextbox, "El campo Email no puede estar vacio"); EmailTextbox.Focus(); paso = false; } if (string.IsNullOrWhiteSpace(FechaNacimientoDateTimePicker.Text)) { MyerrorProvider.SetError(FechaNacimientoDateTimePicker, "El campo Fecha de nacimiento no puede estar vacio"); FechaNacimientoDateTimePicker.Focus(); paso = false; } if (string.IsNullOrWhiteSpace(SexoComboBox.Text)) { MyerrorProvider.SetError(SexoComboBox, "El campo Sexo no puede estar vacio"); SexoComboBox.Focus(); paso = false; } if (string.IsNullOrWhiteSpace(BalanceTextBox.Text)) { MyerrorProvider.SetError(BalanceTextBox, "El campo Balance no puede estar vacio"); BalanceTextBox.Focus(); paso = false; } return(paso); }
private void GuardarButton_Click(object sender, RoutedEventArgs e) { if (!Validar()) { return; } if (VehiculoIdTextBox.Text.Trim() == string.Empty) { MessageBox.Show("El Campo (Vehiculo Id) está vacío.\n\nAsigne un Id al Vehiculo.", "Advertencia", MessageBoxButton.OK, MessageBoxImage.Warning); VehiculoIdTextBox.Text = "0"; VehiculoIdTextBox.Focus(); VehiculoIdTextBox.SelectAll(); return; } if (MarcaComboBox.Text == string.Empty) { MessageBox.Show("El Campo (Marca) está vacío.\n\nPorfavor, Seleccione La Marca del Vehiculo a Crear.", "Advertencia", MessageBoxButton.OK, MessageBoxImage.Warning); MarcaComboBox.IsDropDownOpen = true; return; } if (MatriculaTextBox.Text.Trim() == string.Empty) { MessageBox.Show("El Campo (Matricula) está vacío.\n\nAsigne una Matricula al Vehiculo.", "Advertencia", MessageBoxButton.OK, MessageBoxImage.Warning); MatriculaTextBox.Text = "0"; MatriculaTextBox.Focus(); MatriculaTextBox.SelectAll(); return; } if (ModeloTextbox.Text.Trim() == string.Empty) { MessageBox.Show("El Campo (Modelo) está vacío.\n\nAsigne un Modelo al Vehiculo.", "Advertencia", MessageBoxButton.OK, MessageBoxImage.Warning); ModeloTextbox.Clear(); ModeloTextbox.Focus(); return; } if (DescripcionTextBox.Text.Trim() == string.Empty) { MessageBox.Show("El Campo (Descripciòn) está vacío.\n\nAsigne un comentario al vehiculo.", "Advertencia", MessageBoxButton.OK, MessageBoxImage.Warning); DescripcionTextBox.Clear(); DescripcionTextBox.Focus(); return; } if (VINTextBox.Text.Trim() == string.Empty) { MessageBox.Show("El Campo (VIN Number) está vacío.\n\nAsigne un VIN al Vehiculo.", "Advertencia", MessageBoxButton.OK, MessageBoxImage.Warning); VINTextBox.Text = "0"; VINTextBox.Focus(); VINTextBox.SelectAll(); return; } if (PlacaTextBox.Text.Trim() == string.Empty) { MessageBox.Show("El Campo(Placa) esta vacio .\n\nAsigne una placa al vehiculo.", "Advertencia", MessageBoxButton.OK, MessageBoxImage.Warning); PlacaTextBox.Focus(); return; } if (AnoTextBox.Text.Trim() == string.Empty) { MessageBox.Show("El campo (Año) esta vacio .\n\nAsigne un Año al vehiculo.", "Advertencia", MessageBoxButton.OK, MessageBoxImage.Warning); AnoTextBox.Focus(); return; } if (CostoTextBox.Text.Trim() == string.Empty) { MessageBox.Show("El Campo (Costo) está vacío.\n\nAsigne un costo al Vehiculo.", "Advertencia", MessageBoxButton.OK, MessageBoxImage.Warning); CostoTextBox.Clear(); CostoTextBox.Focus(); return; } if (PrecioPorDiaTextBox.Text.Trim() == string.Empty) { MessageBox.Show("El Campo (Precio Por Dia) está vacío.\n\nAsigne un Precio al Vehiculo.", "Advertencia", MessageBoxButton.OK, MessageBoxImage.Warning); PrecioPorDiaTextBox.Clear(); PrecioPorDiaTextBox.Focus(); return; } var paso = VehiculosBLL.Guardar(vehiculos); if (paso) { Limpiar(); MessageBox.Show("Guardado correctamente!", "Exito", MessageBoxButton.OK, MessageBoxImage.Information); } else { MessageBox.Show("Transaccion Fallida", "Fallo", MessageBoxButton.OK, MessageBoxImage.Error); } }