Exemplo n.º 1
0
        public IEnumerable <modContacto> GetContactos(FiltroContacto filtro)
        {
            var busqueda = from c in bd.Contacto
                           select c;

            if (!string.IsNullOrEmpty(filtro.Nombre))
            {
                busqueda = from c in busqueda
                           where c.nombre.Contains(filtro.Nombre)
                           select c;
            }

            if (!string.IsNullOrEmpty(filtro.Contacto))
            {
                busqueda = from c in busqueda
                           where c.contacto1.Contains(filtro.Contacto)
                           select c;
            }

            if (filtro.Leido.HasValue)
            {
                busqueda = from c in busqueda
                           where c.leido == filtro.Leido.Value
                           select c;
            }

            return(busqueda.Select(x => new modContacto()
            {
                contactoDB = x
            }));
        }
        //CONSULTA CON FILTROS
        protected void Consultar(Object sender, EventArgs e)
        {
            ContactoBLL contactoBLL = new ContactoBLL();

            FiltroContacto filtro = getFiltro();

            List <Contacto> gridData = contactoBLL.GetListContactoByFilter(filtro);

            bindGrid(gridData);
        }
        protected void GridViewConsulta_Activate(int idContacto)
        {
            ContactoBLL contactoBLL = new ContactoBLL();

            contactoBLL.Activate(idContacto);

            FiltroContacto filtro = (FiltroContacto)Application["filtro"];

            List <Contacto> gridData = contactoBLL.GetListContactoByFilter(filtro);

            bindGrid(gridData);
        }
Exemplo n.º 4
0
        public ActionResult Listado()
        {
            bool permiteAcceso = ObtenerPermisos();

            if (permiteAcceso)
            {
                var model = new FiltroContacto();
                model.Leido = false;
                return View(model);
            }
            return new EmptyResult();
        }
Exemplo n.º 5
0
        public List <Contacto> GetListContactoByFilter(FiltroContacto filtroContacto)
        {
            List <Contacto> resultado = new List <Contacto>();

            try
            {
                DataSet   ds           = da.getListContactoByFilter(filtroContacto);
                DataTable tblContactos = ds.Tables[0];

                foreach (DataRow dr in tblContactos.Rows)
                {
                    Contacto contacto = new Contacto();
                    contacto.id             = Convert.ToInt32(dr["contactID"]);
                    contacto.NombreApellido = Convert.ToString(dr["name_lastname"]);
                    contacto.Cuil           = Convert.ToString(dr["cuil"]);
                    contacto.Genero         = Convert.ToString(dr["genre"]);
                    contacto.Pais           = new Pais()
                    {
                        id = Convert.ToInt32(dr["countryID"]), nombre = Convert.ToString(dr["country_name"])
                    };
                    contacto.Localidad        = Convert.ToString(dr["location"]);
                    contacto.Contacto_interno = new SiNo()
                    {
                        id = Convert.ToInt32(dr["internal_contactID"]), valor = Convert.ToString(dr["internal_contact_value"])
                    };
                    contacto.Area = new Area()
                    {
                        id = Convert.ToInt32(dr["areaID"])
                    };
                    contacto.Activo = new SiNo()
                    {
                        id = Convert.ToInt32(dr["activeID"]), valor = Convert.ToString(dr["active_value"])
                    };
                    contacto.Direccion        = Convert.ToString(dr["adress"]);
                    contacto.Telefono_fijo    = Convert.ToInt64(dr["phone"]);
                    contacto.Telefono_celular = Convert.ToInt64(dr["cell"]);
                    contacto.Email            = Convert.ToString(dr["email"]);
                    contacto.Skype            = Convert.ToString(dr["skype"]);
                    contacto.Organizacion     = Convert.ToString(dr["organization"]);
                    contacto.Fecha_ingreso    = Convert.ToDateTime(dr["created_at"]);


                    resultado.Add(contacto);
                }
            }
            catch (Exception error)
            {
                Utils.Helpers.LogHelper.SaveError(error);
            }

            return(resultado);
        }
        private void CargarFiltros()
        {
            FiltroContacto filtro = (FiltroContacto)Application["filtro"];

            if (filtro != null)
            {
                ContactoBLL contactoBLL = new ContactoBLL();

                List <Contacto> gridData = contactoBLL.GetListContactoByFilter(filtro);

                bindGrid(gridData);
            }
        }
Exemplo n.º 7
0
        public ActionResult ResultadoContacto(FiltroContacto filtro)
        {
            bool permiteAcceso = ObtenerPermisos();

            if (permiteAcceso)
            {
                var servContacto = new ContactoService();
                var list = servContacto.GetContactos(filtro);
                return PartialView(list);
            }

            return new EmptyResult();
        }
Exemplo n.º 8
0
        public DataSet getListContactoByFilter(FiltroContacto filtroContacto)
        {
            using (SqlDataAdapter adapter = new SqlDataAdapter())
            {
                DataSet    ds  = new DataSet();
                SqlCommand cmd = new SqlCommand();

                try
                {
                    cmd.Connection  = con;
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.CommandText = "Contactos_GetByFilter";
                    cmd.Parameters.Add(new SqlParameter()
                    {
                        ParameterName = "@name_lastname", Value = filtroContacto.nombreApellido, SqlDbType = SqlDbType.VarChar
                    });
                    cmd.Parameters.Add(new SqlParameter()
                    {
                        ParameterName = "@country", Value = filtroContacto.pais, SqlDbType = SqlDbType.Int
                    });
                    cmd.Parameters.Add(new SqlParameter()
                    {
                        ParameterName = "@location", Value = filtroContacto.localidad, SqlDbType = SqlDbType.VarChar
                    });
                    cmd.Parameters.Add(new SqlParameter()
                    {
                        ParameterName = "@date_from", Value = filtroContacto.fecha_desde, SqlDbType = SqlDbType.DateTime
                    });
                    cmd.Parameters.Add(new SqlParameter()
                    {
                        ParameterName = "@date_to", Value = filtroContacto.fecha_hasta, SqlDbType = SqlDbType.DateTime
                    });
                    cmd.Parameters.Add(new SqlParameter()
                    {
                        ParameterName = "@internal_contact", Value = filtroContacto.contactoInterno, SqlDbType = SqlDbType.Bit
                    });
                    cmd.Parameters.Add(new SqlParameter()
                    {
                        ParameterName = "@organization", Value = filtroContacto.organizacion, SqlDbType = SqlDbType.VarChar
                    });
                    cmd.Parameters.Add(new SqlParameter()
                    {
                        ParameterName = "@area", Value = filtroContacto.area, SqlDbType = SqlDbType.Int
                    });
                    cmd.Parameters.Add(new SqlParameter()
                    {
                        ParameterName = "@active", Value = filtroContacto.activo, SqlDbType = SqlDbType.Bit
                    });

                    //parametros del paginado
                    cmd.Parameters.Add(new SqlParameter()
                    {
                        ParameterName = "@PageSize", Value = filtroContacto.paginacion == null ? null : filtroContacto.paginacion.pageSize, SqlDbType = SqlDbType.Int
                    });
                    cmd.Parameters.Add(new SqlParameter()
                    {
                        ParameterName = "@PageIndex", Value = filtroContacto.paginacion == null ? null : filtroContacto.paginacion.pageIndex, SqlDbType = SqlDbType.Int
                    });
                    cmd.Parameters.Add(new SqlParameter()
                    {
                        ParameterName = "@SortBy", Value = filtroContacto.paginacion == null ? null : filtroContacto.paginacion.sortBy, SqlDbType = SqlDbType.VarChar
                    });
                    cmd.Parameters.Add(new SqlParameter()
                    {
                        ParameterName = "@Order", Value = filtroContacto.paginacion == null ? null : filtroContacto.paginacion.order, SqlDbType = SqlDbType.Int
                    });


                    // Agrego esa query al adapter
                    adapter.SelectCommand = cmd;

                    // Ejecuto la query y agrego los datos al dataset
                    adapter.Fill(ds);

                    if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0 && filtroContacto.paginacion != null)
                    {
                        filtroContacto.paginacion.RecordsCount = Convert.ToInt32(ds.Tables[0].Rows[0]["total_records"]);
                    }
                }
                catch (Exception error)
                {
                    Utils.Helpers.LogHelper.SaveError(error);
                }

                return(ds);
            }
        }
        //OBTIENE LOS FILTROS PARA HACER LA CONSULTA
        private FiltroContacto getFiltro()
        {
            FiltroContacto filtro = new FiltroContacto();

            //filtro por nombre y apellido
            if (!string.IsNullOrEmpty(NombreApellido.Text))
            {
                filtro.nombreApellido = NombreApellido.Text;
            }


            //filtro por paises
            if (!string.IsNullOrEmpty(Paises.SelectedValue) && Paises.SelectedValue != "0")
            {
                filtro.pais = Convert.ToInt32(Paises.SelectedValue);
            }

            //filtro por localidad
            if (!string.IsNullOrEmpty(Localidad.Text))
            {
                filtro.localidad = Localidad.Text;
            }

            //filtro por fecha de ingreso
            if (!string.IsNullOrEmpty(FechaDesdeBox.Text))
            {
                filtro.fecha_desde = Convert.ToDateTime(FechaDesdeBox.Text);
            }

            if (!string.IsNullOrEmpty(FechaHastaBox.Text))
            {
                DateTime fechaHasta = Convert.ToDateTime(FechaHastaBox.Text);
                TimeSpan horaHasta  = new TimeSpan(23, 59, 59);
                filtro.fecha_hasta = fechaHasta.Date + horaHasta;
            }

            //filtro por contacto interno
            if (!string.IsNullOrEmpty(ContactoInternoList.SelectedValue) && ContactoInternoList.SelectedValue != "-1")
            {
                filtro.contactoInterno = Convert.ToInt32(ContactoInternoList.SelectedValue);
            }

            //filtro por organizacion
            if (!string.IsNullOrEmpty(OrganizacionBox.Text))
            {
                filtro.organizacion = OrganizacionBox.Text;
            }

            //filtro por area
            if (!string.IsNullOrEmpty(AreaList.SelectedValue) && AreaList.SelectedValue != "-1")
            {
                filtro.area = Convert.ToInt32(AreaList.SelectedValue);
            }

            //filtro por activo
            if (!string.IsNullOrEmpty(ActivoList.SelectedValue) && ActivoList.SelectedValue != "-1")
            {
                filtro.activo = Convert.ToInt32(ActivoList.SelectedValue);
            }


            Application["filtro"] = filtro;

            return(filtro);
        }