Beispiel #1
0
        private void UiBotonExportarExcel_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            try
            {
                if (UiVistasPrincipal.DataSource == null)
                {
                    return;
                }
                if (UiVistaPrincipal.RowCount <= 0)
                {
                    return;
                }

                var dialog = new SaveFileDialog
                {
                    DefaultExt = "xlsx",
                    Filter     = @"Archivos de excel (*.xlsx)|*.xlsx"
                };

                if (dialog.ShowDialog() != DialogResult.OK)
                {
                    return;
                }
                UiVistasPrincipal.ExportToXlsx(dialog.FileName);
            }
            catch (Exception ex)
            {
                InteraccionConUsuarioServicio.Alerta(ex.Message);
            }
        }
 private void GrabarPiloto()
 {
     try
     {
         if (!ValidarDatosGenerales())
         {
             return;
         }
         UiVistasPrincipal.Focus();
         var usuarioPorPiloto = new UsuarioPorPiloto
         {
             PILOT_CODE = Piloto.PILOT_CODE,
             USER_CODE  = Piloto.USER_CODE
         };
         Piloto.LAST_UPDATE_BY = InteraccionConUsuarioServicio.ObtenerUsuario();
         if (!ExistePiloto(Piloto.PILOT_CODE))
         {
             UsuarioDeseaCrearPiloto?.Invoke(null, new PilotoArgumento {
                 Piloto = Piloto, UsuarioPorPiloto = usuarioPorPiloto
             });
         }
         else
         {
             UsuarioDeseaActualizarPiloto?.Invoke(null, new PilotoArgumento {
                 Piloto = Piloto, UsuarioPorPiloto = usuarioPorPiloto
             });
         }
     }
     catch (Exception ex)
     {
         InteraccionConUsuarioServicio.Alerta(ex.Message);
     }
 }
 private void AsociarODesasociarUsarioAPiloto(bool asociar)
 {
     try
     {
         UiVistasPrincipal.Focus();
         if (!ExistePiloto(Piloto.PILOT_CODE))
         {
             return;
         }
         var usuarioPorPiloto = new UsuarioPorPiloto
         {
             PILOT_CODE = Piloto.PILOT_CODE,
             USER_CODE  = Piloto.USER_CODE
             ,
             LAST_UPDATE_BY = InteraccionConUsuarioServicio.ObtenerUsuario()
         };
         if (asociar)
         {
             UsuarioDeseaAsociarPilotoAUsuarioDelSistema?.Invoke(null, new PilotoArgumento {
                 UsuarioPorPiloto = usuarioPorPiloto
             });
         }
         else
         {
             UsuarioDeseaDesasociarPilotoDeUsuarioDelSistema?.Invoke(null, new PilotoArgumento {
                 UsuarioPorPiloto = usuarioPorPiloto
             });
         }
     }
     catch (Exception ex)
     {
         InteraccionConUsuarioServicio.Alerta(ex.Message);
     }
 }
 private void UiListaRol_EditValueChanged(object sender, EventArgs e)
 {
     try
     {
         UiVistasPrincipal.Focus();
         ObtenerUsuariosPorRol();
     }
     catch (Exception ex)
     {
         InteraccionConUsuarioServicio.Alerta(ex.Message);
     }
 }
        private bool ValidarDatosGenerales()
        {
            try
            {
                UiVistasPrincipal.Focus();
                if (string.IsNullOrEmpty(Piloto.NAME))
                {
                    InteraccionConUsuarioServicio.Alerta("Ingrese el nombre.");
                    UiGridDePropiedadesPilotos.Focus();
                    return(false);
                }
                if (string.IsNullOrEmpty(Piloto.LAST_NAME))
                {
                    InteraccionConUsuarioServicio.Alerta("Ingrese el apellido.");
                    UiGridDePropiedadesPilotos.Focus();
                    return(false);
                }
                if (string.IsNullOrEmpty(Piloto.IDENTIFICATION_DOCUMENT_NUMBER))
                {
                    InteraccionConUsuarioServicio.Alerta("Ingrese el numero de identificacón.");
                    UiGridDePropiedadesPilotos.Focus();
                    return(false);
                }
                if (string.IsNullOrEmpty(Piloto.LICENSE_NUMBER))
                {
                    InteraccionConUsuarioServicio.Alerta("Ingrese el numero de licencia.");
                    UiGridDePropiedadesPilotos.Focus();
                    return(false);
                }
                if (string.IsNullOrEmpty(Piloto.LICESE_TYPE))
                {
                    InteraccionConUsuarioServicio.Alerta("Ingrese el tipo de licencia.");
                    UiGridDePropiedadesPilotos.Focus();
                    return(false);
                }
                if (Piloto.LICENSE_EXPIRATION_DATE == null)
                {
                    InteraccionConUsuarioServicio.Alerta("Ingrese la fecha de vencimiento.");
                    UiGridDePropiedadesPilotos.Focus();
                    return(false);
                }
                else
                {
                    if (Piloto.LICENSE_EXPIRATION_DATE <= DateTime.Now)
                    {
                        InteraccionConUsuarioServicio.Alerta("La fecha tiene que ser mayor a la fecha actual.");
                        UiGridDePropiedadesPilotos.Focus();
                        return(false);
                    }
                }

                if (string.IsNullOrEmpty(Piloto.ADDRESS))
                {
                    InteraccionConUsuarioServicio.Alerta("Ingrese la dirección.");
                    UiGridDePropiedadesPilotos.Focus();
                    return(false);
                }
                if (string.IsNullOrEmpty(Piloto.TELEPHONE))
                {
                    InteraccionConUsuarioServicio.Alerta("Ingrese el telefono.");
                    UiGridDePropiedadesPilotos.Focus();
                    return(false);
                }
                return(true);
            }
            catch (Exception ex)
            {
                InteraccionConUsuarioServicio.Alerta(ex.Message);
                return(false);
            }
        }