Beispiel #1
0
        public static List <Empresario> GetAll()
        {
            using (MySqlConnection conn = new MySqlConnection(Properties.Settings.Default.DB))
            {
                conn.Open();
                using (MySqlCommand cmd = new MySqlCommand("Select * from empresario_view", conn))
                {
                    MySqlDataReader   reader      = cmd.ExecuteReader();
                    List <Empresario> empresarios = new List <Empresario>();

                    while (reader.Read())
                    {
                        empresarios.Add(Empresario.FromDB(reader));
                    }

                    return(empresarios);
                }
            }
        }
Beispiel #2
0
        public static Empresario GetDados(int id)
        {
            using (MySqlConnection conn = new MySqlConnection(Properties.Settings.Default.DB))
            {
                conn.Open();
                using (MySqlCommand cmd = new MySqlCommand("Select * from empresario_view WHERE idPessoa = @id", conn))
                {
                    cmd.Parameters.AddWithValue("@id", id);

                    MySqlDataReader reader = cmd.ExecuteReader();

                    if (!reader.Read())
                    {
                        return(null);
                    }

                    return(Empresario.FromDB(reader));
                }
            }
        }