public override void Formulario(object sender, EventArgs e)
 {
     try
     {
         Cursor.Current = Cursors.WaitCursor;
         base.Formulario(sender, e);
         usuarioInfoListBindingSource.DataSource = UsuarioInfoList.GetUsuarioInfoList();
         usuariosListGridView.BestFitColumns();
     }
     catch (DataPortalException ex)
     {
         XtraMessageBox.Show(ex.BusinessException.Message,
                             Text,
                             MessageBoxButtons.OK,
                             MessageBoxIcon.Exclamation);
     }
     catch (Exception ex)
     {
         XtraMessageBox.Show(ex.Message,
                             Text,
                             MessageBoxButtons.OK,
                             MessageBoxIcon.Exclamation);
     }
     finally
     {
         Cursor.Current = Cursors.Default;
     }
 }
Example #2
0
        public override void Buscar()
        {
            try
            {
                Cursor.Current = Cursors.WaitCursor;
                //Validamos que el N° minimo de caracteres haya sido ingresado
                base.Buscar();

                using (var crit = new FiltroCriteria {
                    NombreCampo = CriterioBusqueda, ValorBusqueda = txtFiltro.Text
                })
                {
                    usuarioInfoListBindingSource.DataSource = UsuarioInfoList.GetUsuarioInfoList(crit);
                }
                if (usuarioInfoListBindingSource.Count > 0)
                {
                    InfoListDataGridView.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;
            }
        }
Example #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);
        }