Esempio n. 1
0
        public static IList <Cliente> Listar()
        {
            using (var conn = ConnMySql.GetConnection())
            {
                try
                {
                    var sql = "SELECT * FROM cadcli where ccli_delete = ''";

                    using (var cmd = new MySqlCommand(sql, conn))
                    {
                        conn.Open();

                        var clientes = new List <Cliente>();

                        var reader = cmd.ExecuteReader();

                        if (reader.HasRows)
                        {
                            while (reader.Read())
                            {
                                clientes.Add(new Cliente
                                {
                                    Codigo      = (string)reader["cecli_cod"],
                                    Nome        = (string)reader["ccli_nome"],
                                    Endereco    = (string)reader["ccli_end"],
                                    Numero      = (string)reader["ccli_num"],
                                    Complemento = (string)reader["ccli_compl"],
                                    Bairro      = (string)reader["ccli_bairro"],
                                    Municipio   = (string)reader["ccli_mun"],
                                    Uf          = (string)reader["ccli_uf"],
                                    Latitude    = 0,
                                    Longitude   = 0
                                });
                            }
                        }

                        return(clientes);
                    }
                }
                catch (Exception)
                {
                    throw;
                }
                finally
                {
                    conn.Clone();
                }
            }
        }
Esempio n. 2
0
        public static IList <Equipe> Listar()
        {
            using (var conn = ConnMySql.GetConnection())
            {
                try
                {
                    var sql = "SELECT * FROM cadequip where cequ_delete = ''";

                    using (var cmd = new MySqlCommand(sql, conn))
                    {
                        conn.Open();

                        var equipes = new List <Equipe>();

                        var reader = cmd.ExecuteReader();

                        if (reader.HasRows)
                        {
                            while (reader.Read())
                            {
                                equipes.Add(new Equipe
                                {
                                    Codigo = (string)reader["cequ_cod"],
                                    Nome   = (string)reader["cequ_nome"]
                                });
                            }
                        }

                        return(equipes);
                    }
                }
                catch (Exception)
                {
                    throw;
                }
                finally
                {
                    conn.Clone();
                }
            }
        }