コード例 #1
0
        private void btnMantVehiculos_Click(object sender, RoutedEventArgs e)
        {
            MantenimientoVehiculo Window = new MantenimientoVehiculo();

            this.Hide();
            Window.ShowDialog();
            Close();
        }
 private void btnModificar_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         if (txtFecha.Text.Trim() != string.Empty && txtDetalle.Text.Trim() != string.Empty && txtMatricula.Text.Trim() != string.Empty)
         {
             Car _datoVehiculo = DatosVehiculo();
             _datoVehiculo.CarID = ID;
             var verificar = from u in _Accion.CarM.GetAllData() where u.Code.ToUpper() == txtMatricula.Text.ToUpper() select u;
             if (verificar.Count() > 0)
             {
                 if (verificar.FirstOrDefault().CarID == _datoVehiculo.CarID)
                 {
                     _CarBL.UpdateCar(_datoVehiculo);
                     MessageBox.Show("Registro guardado exitosamente", "Exito CRVA-VM", MessageBoxButton.OK, MessageBoxImage.Information);
                     //Volvemos a cargar la ventana
                     MantenimientoVehiculo _window = new MantenimientoVehiculo();
                     _window.Show();
                     this.Close();
                 }
                 else
                 {
                     MessageBox.Show("Ya existe un vehículo con esa matrícula", "Alerta CRVA-VM", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                     txtMatricula.Focus();
                 }
             }
             else
             {
                 _CarBL.UpdateCar(_datoVehiculo);
                 MessageBox.Show("Registro guardado exitosamente", "Exito CRVA-VM", MessageBoxButton.OK, MessageBoxImage.Information);
                 //Volvemos a cargar la ventana
                 MantenimientoVehiculo _window = new MantenimientoVehiculo();
                 _window.Show();
                 this.Close();
             }
             //Reconfiguracion de la ventana
             LimpiarWindow();
             EstadoBotones(0);
         }
         else if (txtFecha.Text.Trim() == string.Empty)
         {
             txtFecha.Focus();
         }
         else if (txtDetalle.Text.Trim() == string.Empty)
         {
             txtDetalle.Focus();
         }
         else if (txtMatricula.Text.Trim() == string.Empty)
         {
             txtMatricula.Focus();
         }
         else
         {
             MessageBox.Show("Cargue una imagen para guardar el registro", "Alerta CRVA-VC", MessageBoxButton.OK, MessageBoxImage.Exclamation);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Algo anda mal : " + ex.Message, "Error CRVA-VG", MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }