//Lista categoria :)
        public List<Categoria> ListaCategoria()
        {
            List<Categoria> ListaCategoria = new List<Categoria>();

            String Qry;

            SQLServer SQL = new SQLServer();
            SQL.ConectaDB();

            Qry = "select * from tblCategoria order by nomeCategoria";

            SqlDataReader Rs = SQL.DR(Qry);

            while (Rs.Read())
            {
                Categoria Catego = new Categoria();
                Catego.Cat = Rs["nomeCategoria"].ToString();
                Catego.idCategoria = Convert.ToInt32(Rs["codCategoria"].ToString());

                ListaCategoria.Add(Catego);

            }

            SQL.Cnx.Close();

            return ListaCategoria;
        }
        public List<Cidades> ListaCitys(string estados)
        {
            List<Cidades> ListaCitys = new List<Cidades>();

            String Qry;

            SQLServer SQL = new SQLServer();
            SQL.ConectaDB();

            Qry = "select * from tblCidade where codEstado = '" + estados + "' order by nomeCidade";

            SqlDataReader Rs = SQL.DR(Qry);

            while (Rs.Read())
            {
                Cidades Cdd = new Cidades();
                Cdd.City = Rs["nomeCidade"].ToString();
                Cdd.idCity = Convert.ToInt32(Rs["codCidade"].ToString());
                ListaCitys.Add(Cdd);

            }

            SQL.Cnx.Close();
            return ListaCitys;
        }
        //lista bairros
        public List<Bairros> ListaBairros(string cidade)
        {
            List<Bairros> ListaBairros = new List<Bairros>();

            String Qry;

            SQLServer SQL = new SQLServer();
            SQL.ConectaDB();

            Qry = "select * from tblBairro where codCidade = " + cidade + " order by nomeBairro";

            SqlDataReader Rs = SQL.DR(Qry);

            while (Rs.Read())
            {
                Bairros Brrs = new Bairros();

                Brrs.idBairro = Convert.ToInt32(Rs["codBairro"].ToString());
                Brrs.Bairro = Rs["nomeBairro"].ToString();

                ListaBairros.Add(Brrs);

            }

            SQL.Cnx.Close();
            return ListaBairros;
        }
        public string InsereItemEncontrado(ParametrosEncontreiPerdi Parametros)
        {
            try
            {

                //Carrega variável com strings contidas no cookie criado, caso ele exista.
                string Login = HttpContext.Current.User.Identity.Name;

                string[] Usr = Login.Split(';');
                string usuario = Usr[0];
                string senha = Usr[1];

                String Qry;

                SQLServer SQL = new SQLServer();
                SQL.ConectaDB();

                Qry = "select idUsuario from tblUsuario where emailUsuario = '" + usuario.Trim() + "' and senhaUsuario = '" + senha.Trim() + "'";

                SqlDataReader Rs = SQL.DR(Qry);

                string Id = "";

                if (Rs.Read() == true)
                {

                    Id = Rs["idUsuario"].ToString();

                }

                SQL.Cnx.Close();
                SQL.ConectaDB();

                Qry = "Insert into tblItemEncontrado " +
                    "(idUsuario, codCategoria, codSubCategoria, codPais, "
                    + "dataCadastro, descricao, Latitude, Longitude) " +
                    "values (" + Id + ", " + Parametros.Categoria + ","
                    + Parametros.Subcategoria + ", 1, getdate(), 'null', '" +
                    Parametros.lttde + "','" + Parametros.lgttde + "')";

                SQL.ExecQry(Qry);

                SQL.Cnx.Close();
                return "OK";

            }

            catch (Exception Ex)
            {
                return "ERRO: " + Ex.Message;
            }
        }
        public List<Uf> ListaUF()
        {
            List<Uf> ListaEstados = new List<Uf>();

            String Qry;

            SQLServer SQL = new SQLServer();
            string retornoCnn = SQL.ConectaDB();

            if (retornoCnn.Contains("ERRO") == true)
            {
                Erro = retornoCnn;
                return ListaEstados;

            }

            Qry = "select * from tblEstado order by nomeEstado";

            SqlDataReader Rs = SQL.DR(Qry);

            while (Rs.Read())
            {
                Uf Estado = new Uf();
                Estado.UF = Rs["nomeEstado"].ToString();
                Estado.idUF = Convert.ToInt32(Rs["codEstado"].ToString());

                ListaEstados.Add(Estado);

            }

            SQL.Cnx.Close();

            return ListaEstados;
        }
        //Lista SubCat
        public List<SubCat> ListaSubCat(string categoria)
        {
            List<SubCat> ListaSubCat = new List<SubCat>();

            String Qry;

            SQLServer SQL = new SQLServer();
            SQL.ConectaDB();

            Qry = "select codCategoria, nomeSubCategoria from tblSubCategoria where codCategoria = '" + categoria +
                "'  group by codCategoria, nomeSubCategoria order by codCategoria, nomeSubCategoria";

            SqlDataReader Rs = SQL.DR(Qry);

            while (Rs.Read())
            {
                SubCat SubCatego = new SubCat();
                SubCatego.SubCatego = Rs["nomeSubCategoria"].ToString();
                SubCatego.idSubCat = Convert.ToInt32(Rs["codCategoria"].ToString());

                ListaSubCat.Add(SubCatego);

            }

            SQL.Cnx.Close();
            return ListaSubCat;
        }
        //Lista Descrição
        public List<Descricao> ListaDescricao(string subcat)
        {
            List<Descricao> ListaDescr = new List<Descricao>();

            String Qry;

            SQLServer SQL = new SQLServer();
            SQL.ConectaDB();

            Qry = "select codSubCategoria, nomeSubCategoria, detalheSubCategoria from tblSubCategoria where nomeSubCategoria = '" + subcat + "'";

            SqlDataReader Rs = SQL.DR(Qry);

            while (Rs.Read())
            {
                Descricao Desc = new Descricao();

                Desc.Descri = Rs["detalheSubCategoria"].ToString();
                Desc.idDescricao = Rs["codSubCategoria"].ToString();

                ListaDescr.Add(Desc);

            }

            SQL.Cnx.Close();
            return ListaDescr;
        }
Beispiel #8
0
        public string RecuperarSenha(String email, RecSenha ModelRecSenha)
        {
            String Qry;

            EmailService e_mail = new EmailService();
            SQLServer SQL = new SQLServer();
            SQL.ConectaDB();

            Qry = "select senhaUsuario from tblUsuario where emailUsuario = '" + email + "'";

            SqlDataReader Rs = SQL.DR(Qry);

            //encontrou o e-mail
            if (Rs.Read() == true)
            {

                ModelRecSenha.Senha = Rs["senhaUsuario"].ToString();

                bool retorno = SendSenha("*****@*****.**", email, "Sua senha", "AchadosPerdidos\n\nSua senha é: " + ModelRecSenha.Senha);

                // // Gmail Remetente
                //var fromAddress = "*****@*****.**";

                //// Email destino
                //var toAddress = "*****@*****.**";

                ////Senha do e-mail remetente
                //const string fromPassword = "******";

                //// Assunto
                //string subject = Assunto;

                //// Corpo do e-mail
                //string body = "De: " + Nome + "\n";
                //body += "Email: " + Email + "\n";
                //body += "Assunto: " + Assunto + "\n";
                //body += "Mensagem: \n" + Msg + "\n";

                //// smtp settings
                //var smtp = new System.Net.Mail.SmtpClient();
                //{
                //	smtp.Host = "smtp.gmail.com";
                //	smtp.Port = 587;
                //	smtp.EnableSsl = true;
                //	smtp.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
                //	smtp.Credentials = new NetworkCredential(fromAddress, fromPassword);
                //	smtp.Timeout = 20000;
                //}

                //// Realiza os envios.
                //smtp.Send(fromAddress, toAddress, subject, body);

                //retorno = e_mail.Send()

                if (retorno == false)
                {

                    ModelRecSenha.Result = "Não foi possível enviar a senha para o e-mail informado, tente novamente.";

                }
                else
                {

                    ModelRecSenha.Result = "Sua senha foi enviada para o e-mail informado.";
                }

            }

            return "Ok";
        }
Beispiel #9
0
        public List<CamposItemMapa> ListaItemsMapa(string tipoItems)
        {
            List<CamposItemMapa> ListaItemsMapa = new List<CamposItemMapa>();

            String Qry;

            SQLServer SQL = new SQLServer();
            string retornoCnn = SQL.ConectaDB();

            if (retornoCnn.Contains("ERRO") == true)
            {
                Erro = retornoCnn;
                return ListaItemsMapa;

            }

            String filtros1 = null;
            String filtros2 = null;

            //verifica se parâmetro contem filtro
            if (tipoItems.Contains("-") == true)
            {

                String[] vSplit = tipoItems.Split('-');

                filtros1 = vSplit[1];
                filtros2 = vSplit[2];

            }

            if (tipoItems.Contains("Encontrados") == true)
            {

                Qry = "Select A.Latitude, A.Longitude, A.codItemPerdido, "
                    + "D.emailUsuario, C.nomeCategoria, "
                    + "B.nomeSubCategoria, D.nomeUsuario, D.sobrenomeUsuario, D.telFixo, D.telCelular"
                    + " from tblItemPerdido as A inner Join tblSubCategoria as B"
                    + " on (A.codSubCategoria = B.codSubCategoria) #filtros1 #filtros2"
                    + " inner join tblCategoria as C on (a.codCategoria = c.codCategoria)"
                    + " inner join tblUsuario as D on (a.idUsuario = d.idUsuario)";

                if (filtros1 != "0" && filtros1 != null)
                {

                    Qry = Qry.Replace("#filtros1", " and A.codCategoria = "
                        + filtros1);

                }
                else {

                    Qry = Qry.Replace("#filtros1", "");
                }

                if (filtros2 != "0" && filtros2 != null)
                {

                    Qry = Qry.Replace("#filtros2", " and A.codSubCategoria = "
                        + filtros2);

                }
                else
                {

                    Qry = Qry.Replace("#filtros2", "");
                }

            }
            else
            {

                Qry = "Select A.codItemEncontrado, A.Latitude, A.Longitude, D.emailUsuario, "
                    + " C.nomeCategoria, B.nomeSubCategoria, D.nomeUsuario, D.sobrenomeUsuario, "
                    + "D.telFixo, D.telCelular"
                    + " from tblItemEncontrado as A inner Join tblSubCategoria as B"
                    + " on (A.codSubCategoria = B.codSubCategoria) #filtros1 #filtros2"
                    + " inner join tblCategoria as C on (a.codCategoria = c.codCategoria)"
                    + " inner join tblUsuario as D on (a.idUsuario = d.idUsuario)";

                if (filtros1 != "0" && filtros1 != null)
                {

                    Qry = Qry.Replace("#filtros1", " and A.codCategoria = "
                        + filtros1);

                }
                else
                {

                    Qry = Qry.Replace("#filtros1", "");
                }

                if (filtros2 != "0" && filtros2 != null)
                {

                    Qry = Qry.Replace("#filtros2", " and A.codSubCategoria = "
                        + filtros2);

                }
                else
                {

                    Qry = Qry.Replace("#filtros2", "");
                }

            }

            SqlDataReader Rs = SQL.DR(Qry);

            while (Rs.Read())
            {
                CamposItemMapa ItemsMapa = new CamposItemMapa();

                if (tipoItems.Contains("Encontrados") == true)
                {
                    ItemsMapa.idItem = Convert.ToInt32(Rs["codItemPerdido"].ToString());
                }
                else
                {
                    ItemsMapa.idItem = Convert.ToInt32(Rs["codItemEncontrado"].ToString());
                }

                ItemsMapa.Categoria = Rs["nomeCategoria"].ToString();
                ItemsMapa.SubCategoria = Rs["nomeSubCategoria"].ToString();
                ItemsMapa.email = Rs["emailUsuario"].ToString();
                ItemsMapa.Nome = Rs["nomeUsuario"].ToString();
                ItemsMapa.Sobrenome = Rs["sobrenomeUsuario"].ToString();
                ItemsMapa.Tel = Rs["telFixo"].ToString();
                ItemsMapa.Celular = Rs["telCelular"].ToString();
                ItemsMapa.email = Rs["emailUsuario"].ToString();
                ItemsMapa.Latitude = Rs["longitude"].ToString().Replace(",",".");
                ItemsMapa.Longitude = Rs["latitude"].ToString().Replace(",", ".");

                ListaItemsMapa.Add(ItemsMapa);

            }

            SQL.Cnx.Close();

            ////********TRECHO DE TESTES - HABILITAR OS CODIGOS ACIMA QUANDO CONSTATADO QUE FUNCIONALIDADE ESTÁ OK.
            //CamposItemMapa ItemsMapa = new CamposItemMapa();

            //ItemsMapa.idItem = 1;
            //ItemsMapa.Categoria = "Animal";
            //ItemsMapa.email = "*****@*****.**";
            //ItemsMapa.Latitude = "-46.70011240000002";
            //ItemsMapa.Longitude = "-23.54984692299866";

            //ListaItemsMapa.Add(ItemsMapa);

            return ListaItemsMapa;
        }
Beispiel #10
0
        public bool ConsultaCpf(string cpf)
        {
            String Qry;

            SQLServer SQL = new SQLServer();
            string retornoCnn = SQL.ConectaDB();

            if (retornoCnn.Contains("ERRO") == true)
            {

                return false;

            }

            Qry = "select * from tblUsuario where cpf = '" + cpf + "'";

            SqlDataReader Rs = SQL.DR(Qry);

            if (Rs.Read())
            {
                return false;
            }

            SQL.Cnx.Close();

            return true;
        }
Beispiel #11
0
        public string InsereCadastro(string Nome, string SobreNome,
            string Cpf, string Tel, string Cel,
            string Email, string Senha, string ConfirmSenha)
        {
            try
            {

                String Qry = "";

                SQLServer SQL = new SQLServer();
                SQL.ConectaDB();

                Qry = "Insert into tblUsuario " +
                    "( emailUsuario, senhaUsuario, nomeUsuario, sobrenomeUsuario, telFixo, telCelular, cpf) " +
                    "values ('" + Email + "','"
                    + Senha + "','" + Nome + "','"
                    + SobreNome + "','" + Tel + "','" + Cel + "','" + Cpf + "')";

                SQL.ExecQry(Qry);

                SQL.Cnx.Close();
                return "CADASTRO REALIZADO COM SUCESSO.";

            }

            catch (Exception Ex)
            {
                return "ERRO: " + Ex.Message;
            }
        }