Exemplo n.º 1
0
 public override void Actualizar()
 {
     base.Actualizar();
     try
     {
         Cursor.Current = Cursors.WaitCursor;
         empresaInfoListBindingSource.DataSource     = EmpresaInfoList.GetEmpresaInfoList();
         tipoUsuarioInfoListBindingSource.DataSource = TipoUsuarioInfoList.GetTipoUsuarioInfoList();
         dominioInfoListBindingSource.DataSource     = DominioInfoList.GetDominioInfoList();
         cargoInfoListBindingSource.DataSource       = CargoInfoList.GetCargoInfoList();
     }
     catch (DataPortalException ex)
     {
         XtraMessageBox.Show(ex.BusinessException.Message,
                             "Actualizar",
                             MessageBoxButtons.OK,
                             MessageBoxIcon.Exclamation);
     }
     catch (Exception ex)
     {
         XtraMessageBox.Show(ex.Message,
                             "Actualizar",
                             MessageBoxButtons.OK,
                             MessageBoxIcon.Exclamation);
     }
     finally
     {
         Cursor.Current = Cursors.Default;
     }
 }
Exemplo n.º 2
0
 public override void Buscar()
 {
     try
     {
         Cursor.Current = Cursors.WaitCursor;
         //base.Buscar();
         //Aplicar los Filtros
         using (var filtro = new FiltroCriteria())
         {
             filtro.NombreCampo   = CriterioBusqueda;
             filtro.ValorBusqueda = txtFiltro.Text;
             cargoInfoListBindingSource.DataSource = CargoInfoList.GetCargoInfoList(filtro);
             if (cargoInfoListBindingSource.Count > 0)
             {
                 gdvCargos.BestFitColumns();
             }
         }
     }
     catch (DataPortalException ex)
     {
         XtraMessageBox.Show(ex.BusinessException.Message,
                             "Buscar",
                             MessageBoxButtons.OK,
                             MessageBoxIcon.Exclamation);
     }
     catch (Exception ex)
     {
         XtraMessageBox.Show(ex.Message,
                             "Buscar",
                             MessageBoxButtons.OK,
                             MessageBoxIcon.Exclamation);
     }
     finally
     {
         Cursor.Current = Cursors.Default;
     }
 }
Exemplo n.º 3
0
        private List <Usuario> ValidarDatosAImportar(List <Usuario> usuarioList)
        {
            TipoUsuarioInfoList tipoUsuarioInfoList = TipoUsuarioInfoList.GetTipoUsuarioInfoList();
            EmpresaInfoList     empresaInfoList     = EmpresaInfoList.GetEmpresaInfoList();
            DominioInfoList     dominioInfoList     = DominioInfoList.GetDominioInfoList();
            CargoInfoList       cargoInfoList       = CargoInfoList.GetCargoInfoList();
            UsuarioInfoList     usuarioInfoList     = UsuarioInfoList.GetUsuarioInfoList(new FiltroCriteria {
                NombreCampo = "", ValorBusqueda = ""
            });

            usuarioList.ForEach(x =>
            {
                try
                {
                    #region VALIDACIOIN VALORES OBLIGATORIOS

                    if (string.IsNullOrEmpty(x.Tipo))
                    {
                        throw new Exception("Tipo no tiene el formato correcto");
                    }

                    if (string.IsNullOrEmpty(x.Codigo))
                    {
                        throw new Exception("Código no tiene el formato correcto");
                    }

                    if (string.IsNullOrEmpty(x.Dominio))
                    {
                        throw new Exception("Dominio no tiene el formato correcto");
                    }

                    if (string.IsNullOrEmpty(x.Nombres))
                    {
                        throw new Exception("Nombres no tiene el formato correcto");
                    }

                    if (string.IsNullOrEmpty(x.ApellidoMaterno))
                    {
                        throw new Exception("ApellidoMaterno no tiene el formato correcto");
                    }

                    if (string.IsNullOrEmpty(x.ApellidoPaterno))
                    {
                        throw new Exception("ApellidoPaterno no tiene el formato correcto");
                    }

                    if (string.IsNullOrEmpty(x.IdEmpresa))
                    {
                        throw new Exception("Empresa no tiene el formato correcto");
                    }

                    if (string.IsNullOrEmpty(x.IdEmpresaPertenencia))
                    {
                        throw new Exception("EmpresaPertenencia no tiene el formato correcto");
                    }

                    if (string.IsNullOrEmpty(x.IdCargo))
                    {
                        throw new Exception("Cargo no tiene el formato correcto");
                    }

                    #endregion

                    #region VALIDACION SI DATOS EXISTE

                    if (tipoUsuarioInfoList.Where(xy => xy.Codigo == x.Codigo).Any())
                    {
                        throw new Exception("No existe el tipo descrito");
                    }

                    if (dominioInfoList.Where(xy => xy.NombreCorto == x.Dominio).Any())
                    {
                        throw new Exception("No existe el dominio descrito");
                    }

                    var empresaInfoListFilter = empresaInfoList.Where(xy => xy.RazonSocial.ToUpper().Contains(x.IdEmpresa.ToUpper())).ToList();
                    if (empresaInfoListFilter.Any())
                    {
                        x.IdEmpresa = empresaInfoListFilter.FirstOrDefault().ID;
                    }
                    else
                    {
                        throw new Exception("No existe la empresa descrita");
                    }

                    empresaInfoListFilter = empresaInfoList.Where(xy => xy.RazonSocial.ToUpper().Contains(x.IdEmpresaPertenencia.ToUpper())).ToList();
                    if (empresaInfoListFilter.Any())
                    {
                        x.IdEmpresaPertenencia = empresaInfoListFilter.FirstOrDefault().ID;
                    }
                    else
                    {
                        throw new Exception("No existe la empresa de pertenencia descrita");
                    }

                    var cargoSociedadInfoListFilter = cargoInfoList.Where(xy => xy.Descripcion.ToUpper().Contains(x.IdCargo.ToUpper())).ToList();
                    if (cargoSociedadInfoListFilter.Any())
                    {
                        x.IdCargo = cargoSociedadInfoListFilter.FirstOrDefault().ID;
                    }
                    else
                    {
                        throw new Exception("No existe el cargo descrita");
                    }

                    #endregion

                    if (usuarioInfoList.Where(xy => xy.Codigo == x.Codigo).Any())
                    {
                        throw new Exception("El usuario ya existe");
                    }

                    x.Estado = true;
                }
                catch (Exception ex)
                {
                    x.AliasAlterno = ex.Message;
                    x.Estado       = false;
                }
            });

            return(usuarioList);
        }